# Hausa Translator Backend API (v2.0)
A production-grade, highly scalable, and fully decoupled FastAPI backend featuring three modular processing pipelines. This backend is optimized to run on GPU-enabled hosting environments (such as a Lightning AI GPU Studio) while persisting transaction and progress metadata to a managed Supabase PostgreSQL instance.
---
## 🚀 Key Features
* **Clean Separation of Concerns:** Rigid domain layering (`models`, `schema`, `crud`, `services`, and `api/endpoints`) ensures maximum maintainability and code clarity.
* **Fully Decoupled Architecture:** Users can chain outputs or run individual pipeline stages completely standalone.
* **No In-Memory Dependencies:** Built on PostgreSQL using SQLAlchemy and Alembic, allowing infinite application scaling and seamless recovery on restarts.
* **Decoupled Audio Extraction:** Stage 1 is fully decoupled. You can download and extract audio from public URLs (YouTube, Vimeo, etc.) OR upload raw video files directly to the server.
* **Interactive Transcription & Translation Flow:** Stage 2 is split into distinct, modular operations. Transcribe English audio to English text, review or copy it, and then submit it for segment-by-segment Hausa translation preserving all timestamps.
* **Robust Security:** Endpoint operations are protected via custom `X-API-KEY` authorization headers to prevent GPU compute resource exhaustion.
* **Lazy Singleton Model Cache:** Deep learning models (Whisper, NLLB-200, MMS-TTS) load lazily on demand and stay cached efficiently in GPU memory.
---
## 📂 Codebase Directory Layout
```
english_to_hausa/
├── api/
│ ├── endpoints/
│ │ ├── video_to_audio.py # URL extraction & Direct file upload pipelines
│ │ ├── translate.py # Whisper transcription & NLLB translation pipelines
│ │ └── tts.py # MMS-TTS synthesis pipeline
│ └── deps.py # API Key security validation & DB dependency injection
├── crud/
│ └── job …