# Moroccan Darija Translator
> An AI-powered REST web service that translates English text into Moroccan Darija using Google Gemini 2.5 Flash.
> Supervised by **Pr. El Habib Nfaoui**
---
## Features
- Powered by **Google Gemini 2.5 Flash** AI
- **Chrome Extension** with side panel and auto-fill on text selection
- Basic Authentication security
- Built with **Jakarta EE / JAX-RS** deployed on WildFly
---
## Architecture
```
Chrome Extension (content.js)
↓ HTTP POST + Basic Auth
Java REST API — WildFly Server
↓ Prompt + API Key
Google Gemini AI
↓
Darija Translation
```
---
## Project Structure
```
├── src/main/java/com/darija/
│ ├── ApplicationConfig.java # Activates JAX-RS at /rest
│ ├── SecurityConfig.java # HTTP Basic Auth setup
│ └── TranslatorResource.java # POST /rest/translate endpoint
├── chrome-extension/
│ ├── manifest.json
│ ├── content.js # Detects text selection
│ ├── sidepanel.html / .js / .css
│ └── background.js
├── translate.php # CLI client
└── pom.xml
```
---
## Getting Started
### 1. Prerequisites
- Java 21
- Maven
- WildFly
- Google Gemini API Key
### 2. Set Environment Variable
```bash
export GOOGLE_API_KEY=your_key_here
```
### 3. Create WildFly User
```bash
./bin/add-user.sh
# Type: Application User
# Username: your_username
# Password: your_password
# Role: user
```
### 5. Load the Chrome Extension
- Open Chrome → `chrome://extensions`
- Enable Developer Mode
- Click **Load unpacked** → select the `chrome-extension/` folder
---
**Status Codes:**
| Code | Meaning |
|------|---------|
| 200 | Translation successful |
| 400 | Empty input |
| 401 | Invalid credentials |
| 403 | Missing "user" role |
| 500 | Missing API key or Gemini error |
## Authors
- **HASSNIOUI Amine**
- **MANSOURI Salma**
## Academic Context
Developed as part of the SOA Technology course – Cycle 5 IDWM
ISGA Fès – 2025/2026