a language model
# Kalabari AI
AI-powered translation and language detection for Nigerian languages.
This is a **pnpm monorepo** with two apps that run as one system:
```
┌────────────┐ same-origin ┌──────────────────┐ server→server ┌────────────────────┐
│ Browser │ ───────────────────▶ │ Next.js (BFF) │ ────────────────▶ │ Spring backend │
│ (React) │ /api/translate… │ route handlers │ /api/v1/… │ AI gateway │
└────────────┘ └──────────────────┘ └─────────┬──────────┘
│ │
│ auth + history │ chat/completions
▼ ▼
┌────────────┐ ┌──────────────┐
│ Supabase │ │ Model server │
│ (auth, DB) │ │ (Gemma, TBD) │
└────────────┘ └──────────────┘
```
## Responsibilities
- **`frontend/` — Next.js 16 / React 19.** The UI plus a thin **BFF (backend-for-frontend)** layer.
Route handlers under `app/api/*` call the backend **server-to-server** (the backend URL stays
server-only). Supabase is the single owner of **auth** and **translation history**.
- **`backend/` — Spring Boot.** A **stateless AI inference gateway** exposing `POST /api/v1/translate`,
`/detect`, and `/generate`. It forwards to an OpenAI-compatible model server and caches translations
in Redis. Until the fine-tuned model is deployed it runs an in-memory **mock client** (`MODEL_SERVER_MOCK=true`).
The frontend's old in-browser Transformers.js inference was removed — translation/detection now have a
single implementation, in the backend.
## Prerequisites
- Node.js 18+ and **pnpm 9+** (`corepack enable` then `corepack prepare pnpm@9 --activate`)
- Java 21 + Maven (for the backend)
- A Supabase project (auth + history)
- Optional: Docker (for backend + Redis via `docker-compose.yml`)
## Setup
```bash
# 1. Install JS dependencies (workspace ro …