FastAPI backend for NOVA, a smartphone-based assistive vision system for blind and visually impaired users in Cameroon. Provides REST endpoints for scene description, face recognition, usage log sync, and OTA model delivery. Built with Python 3.11, SQLAlchemy, PostgreSQL, and Docker.
# NOVA Backend
FastAPI backend for **NOVA — Navigational Object and Voice Assistant**. Handles
authentication, cloud scene description, server-side face matching, usage-log
sync, and OTA TFLite model distribution for the NOVA Flutter mobile app.
See `D:\nova\docs` for the full SRS, database design, and mobile implementation
guides this backend implements.
## Stack
- FastAPI 0.111 (async) + Uvicorn/Gunicorn
- SQLAlchemy 2.0 (async) + Alembic migrations
- PostgreSQL 15 (production), SQLite/aiosqlite (tests)
- Redis 7 (rate limiting)
- InsightFace (server-side face matching), BLIP-2 or GPT-4V (scene description)
- JWT auth (python-jose) + bcrypt (passlib)
- AES-256/Fernet encryption for biometric embeddings and PII at rest
## Project layout
```
app/
main.py FastAPI app factory + lifespan (loads ML models on startup)
config.py Pydantic Settings (all config via env vars)
database.py Async engine/session factory
logging_config.py Structured JSON logging + audit_log() for security events
middleware.py Request logging + security headers
rate_limit.py Shared slowapi Limiter instance
dependencies.py get_current_user (JWT bearer auth)
exceptions.py Global exception handlers (consistent JSON error envelope)
models/ SQLAlchemy ORM models
schemas/ Pydantic request/response models
routers/ HTTP endpoints (auth, scene, faces, logs, model_registry, emergency_contact)
services/ Business logic (DB + audit logging, no HTTP concerns)
ml/ SceneDescriber (BLIP-2/cloud VLM), FaceMatcher (InsightFace)
security/ jwt.py, hashing.py, crypto.py (Fernet)
alembic/ Migrations (0001_initial_schema, 0002_add_user_is_operator)
tests/ pytest + httpx async test suite (SQLite by default, Postgres via TEST_DATABASE_URL, ML mocked)
.github/workflows/ci.yml Lint + tests (SQLite + Postgres) + coverage gate (NFR-42)
```
## Local setup
```bash …