Logo Lanfrica

oussamaUks/darija-translator

Domaine:

natural language processing

Type de record:

software
Créateur:
ous
Hôte:
# Translator Service (Jakarta EE / Open Liberty) REST endpoint that translates text (e.g. English) into Moroccan Arabic Dialect (Darija) using Google Gemini, secured with HTTP Basic Authentication via Jakarta Security. ## Requirements - JDK 17+ (Java 25 used during development) - No local Maven install needed — use the bundled wrapper (`./mvnw` / `mvnw.cmd`), which downloads Maven and Open Liberty automatically on first run. - A Gemini API key from Google AI Studio. ## Configuration All configuration is read via MicroProfile Config, so everything can be set with environment variables — no secrets are stored in files. | Property | Env var | Default | Notes | |-----------------------|-------------------------|------------------|------------------------------------------| | `gemini.api.key` | `GEMINI_API_KEY` | *(required)* | Your Gemini API key | | `gemini.model` | `GEMINI_MODEL` | `gemini-2.0-flash` | Any model returned by `GET /v1beta/models` | | `app.security.username` | `APP_SECURITY_USERNAME` | `translator` | Basic Auth username | | `app.security.password` | `APP_SECURITY_PASSWORD` | `darija123` | Basic Auth password | ## Run ```bash export GEMINI_API_KEY=your-key-here ./mvnw liberty:run ``` The service listens on `localhost` (HTTPS on 9443). Dev mode (`liberty:dev`) also works and hot-reloads on code changes. Stop with `./mvnw liberty:stop` (or Ctrl+C if running in the foreground). ## Endpoint ``` POST /translator/api/translate Authorization: Basic (translator:darija123 by default) Content-Type: application/json { "text": "Good morning, how are you?" } ``` Response: ```json { "original": "Good morning, how are you?", "translation": "صباح الخير، كيف داير؟" } ``` - Missing/invalid credentials → `401 Unauthorized` - Missing `text` field → `400 Bad Request` …