Moroccan Legal AI Platform in Darija with RAG
# حقي (Haqqi) — Moroccan Legal AI Platform
> **حقي** is an AI-powered legal assistant for Moroccan citizens, answering legal questions in **Moroccan Darija** using Retrieval-Augmented Generation (RAG) over 3,777 articles from 5 Moroccan law codes.
---
## Features ✨
| Feature | Description |
|---------|-------------|
| **🤖 Darija Legal Chat** | Ask legal questions in Moroccan Darija, get answers citing specific articles |
| **📚 3,777 Legal Articles** | 5 codes: Penal, Civil Obligations, Commercial, Family, Labour |
| **⚡ RAG Pipeline** | ChromaDB → Supabase (pgvector) → JSON keyword → Groq LLM with 3 fallback levels |
| **⚡ Streaming Responses** | See answers appear word-by-word — first token in ~1s |
| **📄 PDF Contract Generation** | Generate rent, employment, and partnership contracts |
| **⚖️ Court Decisions** | 30+ Moroccan Cassation decisions with search/filter |
| **🔐 Auth** | Email/password via Supabase Auth |
| **📱 PWA** | Installable as mobile app, works offline via service worker |
| **🐳 Docker** | Production-ready container with health checks |
| **🌐 RTL UI** | Full Arabic right-to-left support with Tajawal font |
---
## Architecture 🏗️
```
┌─────────────────────────────────────────────────────────┐
│ Browser (PWA) │
│ Jinja2 Templates + Tailwind CSS │
└──────────────────────┬──────────────────────────────────┘
│ HTTP / SSE Stream
┌──────────────────────▼──────────────────────────────────┐
│ FastAPI (Python 3.12) │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────────┐ │
│ │ Auth │ │ Chat │ │ Contracts API │ │
│ │ Routes │ │ (SSE) │ │ PDF Generation │ │
│ └──────────┘ └────┬─────┘ └──────────────────────┘ │
└──────────────────────┼──────────────────────────────────┘
│
┌──────────────────┼──────────────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────────┐ ┌─────────── …