This repository contains the backend server for the EyeDentify mobile application, built using the Ktor framework in Kotlin. Its primary function is to securely manage user data, handle file uploads, and orchestrate calls to multiple specialized AI services.
| Technology | Purpose |
|---|---|
| Ktor Framework | Asynchronous server engine (Netty) for routing and handling multipart requests. |
| PostgreSQL / JDBC | Data persistence for users (BCrypt hashing) and history storage (BLOB/BYTEA). |
| BCrypt | Used for secure, one-way hashing of user passwords during registration and login. |
| Google Vision API | Primary general object identification service. |
| OpenAI (GPT-4o) | Advanced multi-modal identification and structured JSON response generation. |
| Pl@ntNet API | Specialized identification service for plants, flowers, and trees. |
- JVM (Java Development Kit) installed.
- A running PostgreSQL instance.
- API Keys for Google Vision, OpenAI, and Pl@ntNet.
-
Clone the repository:
git clone https://github.com/JPR420/EyeDentifyAPI.git cd EyeDentifyAPI -
Database Setup: Ensure your PostgreSQL instance is running. The server attempts to create the required
usersandcapture_resultstables on startup (code is commented out inmainfor safety, may need manual execution). -
Credential Management: You must configure your database and API credentials in the
DatabaseConfig.ktfile (or a secure environment variable system):jdbcUrl,username,password(for PostgreSQL)googleKey,openAiKey,plantNetKey
-
Start the Server: Run the
mainfunction in your IDE, or use Gradle:./gradlew run # Server will start on http://localhost:8080
| Endpoint | Method | Role | Body/Params |
|---|---|---|---|
/register |
POST |
Creates a new user with BCrypt hashed password. | email, password (Form Parameters) |
/login |
POST |
Authenticates user and returns id and tier. |
email, password (Form Parameters) |
/identify |
POST |
General object recognition via Google Vision. | Multipart (Image File) |
/identify_openai |
POST |
Detailed object recognition via GPT-4o-mini. | Multipart (Image File) |
/identify_plantnet |
POST |
Plant/Nature identification via Pl@ntNet. | Multipart (Image File, optional organs) |
/saveResult |
POST |
Saves captured data and image to user history. | Multipart (Image File + Form data: user_id, object_name, etc.) |
/getUserHistory |
POST |
Retrieves history for a user, returning images as Base64. | user_id (Form Parameter) |