# LLM-powered RESTful Web Service for Translation to Moroccan Darija
This university mini project translates input text into Moroccan Darija through a secure Java REST backend and several client applications.
## Gemini free-tier choice
The backend is implemented with these fixed choices:
1. Free-tier model: `gemini-2.0-flash-lite`
2. API path: `POST
generativelanguage.googleap…`
3. Required secret: `GEMINI_API_KEY`
Why this choice:
- It satisfies the requirement to use the Google Gemini Developer API with a normal Google AI Studio API key.
- It keeps the implementation on a low-cost Flash/Lite path instead of a Pro model.
- The provider is isolated behind `TranslationProvider`, so another provider can be added later without changing the REST API.
## Architecture summary
- Backend: Java 17 + Maven + Open Liberty + Jakarta REST + Jakarta Security Basic Auth
- LLM provider: `TranslationProvider` interface with `GeminiTranslationProvider`
- Browser client: Chrome extension using Manifest V3 and `chrome.sidePanel`
- Other clients: PHP page, Python CLI, React Native app
- Documentation: README, Postman collection, PlantUML diagrams, demo script
The full tree is documented in docs/architecture.md.
## Backend API
### Base URL
`
localhost`
### Endpoints
- `GET /health`
- `POST /translate`
### Authentication
`POST /translate` is protected by Basic Authentication.
Default development credentials:
- Username: `translator`
- Password: `translator123`
Override them with these environment variables before starting the backend:
- `TRANSLATOR_BASIC_AUTH_USERNAME`
- `TRANSLATOR_BASIC_AUTH_PASSWORD`
### Request example
```json
{
"text": "How are you today?",
"sourceLanguage": "en",
"targetLanguage": "darija"
}
```
### Success response example
```json
{
"success": true,
"sourceText": "How are you today?",
"translatedText": "Kidayr lyoum?",
"sourceLanguage": "en",
"targetLanguage": "d …