You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Offline-first retinal disease screening platform for rural Uganda. Classifies 24 retinal diseases from fundus photographs using RETFound ViT-Large with LoRA adapters, clinical knowledge graph reasoning, and a LangGraph agentic workflow. Designed for community health workers on mid-range Android phones with intermittent connectivity.
Production model (v2): Precision 0.312 (12.5x over v1), F1 0.362 (7.9x), AUC 0.888, Accuracy 95.4%.
v4.0 additions: On-device MobileNetV3 student model (5.2M params, INT8 ONNX), Flutter mobile app with Drift database, voice-first interface (Whisper + Piper TTS) with Luganda support, DHIS2/FHIR/DICOM integration, mobile money referral payments, federated learning with LoRA adapter exchange, and ISO 14971 risk management.
SaaS / billing layer (Phase 6). OptiscanAI now runs as a multi-tenant
SaaS at www.optiscan.makstartup.com
with a 4-tier subscription model (Free · Clinician · Practice · Health
System), built-in auth (JWT + magic link + refresh-token rotation), monthly
scan quotas with paywall + upsell UX, team-seat management, and four
payment rails (Stripe + MTN MoMo + Airtel Money + Flutterwave). Marketing
site, /pricing, /legal/{privacy,terms}, and a superuser admin
ops view at /app/admin/webhooks all ship in the same Next.js app.
The full architecture and runbook is in
docs/23-billing-platform.md. All of it is
opt-in — flip BILLING__ENABLED=false and the layer goes dormant,
preserving the original on-prem / research deployment story.
# Install (core)
uv sync &&cd frontend && bun install &&cd ..
# Install with production features (Phase 1-3)
pip install -e ".[observability,drift-detection,ray-serve,edge]"# Development (backend:8080 + frontend:3000)
make dev
# Run tests (198 tests)
make test# Train on 8 GPUs
make train
# Export to all formats (ONNX, TorchScript, INT8, FP16)
make export-all
# Full MLOps pipeline (validate -> train -> export -> model card)
make mlops-pipeline
Enable 2026 Production Features
# Phase 1: Start observability + MLflow stack
make up-phase1
# API automatically connects to OTEL Collector + MLflow# Jaeger UI: http://localhost:16686 | MLflow UI: http://localhost:5000# Phase 2: Add Ray Serve + Kafka
make up-phase2
# Full stack (all phases)
make up-full
# Teardown
make down-full
All features are opt-in via environment variables and disabled by default. See Migration Guide for step-by-step activation.
Deploy to Hugging Face Spaces
# Automated deployment (requires HF_TOKEN)
make deploy-hf
# Local test (full stack: backend + frontend + nginx on :7860)
docker compose -f deploy/docker-compose.yml --profile hf up --build
The HF Spaces deployment uses deploy/Dockerfile.hf — a CPU-optimized single container with supervisord orchestrating nginx (:7860), FastAPI backend (:8080), and Next.js standalone (:3000). See Frontend Setup for architecture details.
Resolve a review decision (triggers active learning)
GET
/api/v1/review/stats
Review queue statistics
Explainability
Method
Path
Description
POST
/api/v1/explain/gradcam
GradCAM heatmap for target diseases
POST
/api/v1/explain/lime
LIME superpixel importance
POST
/api/v1/explain/shap
SHAP feature importance
POST
/api/v1/explain/integrated-gradients
Attribution-based explanation
POST
/api/v1/explain/eli5
Human-readable explanation
POST
/api/v1/explain/comprehensive
All methods combined
GET
/api/v1/explain/available
Available explainability methods
Clinical & Agents
Method
Path
Description
GET
/api/v1/clinical/disease-info/{code}
Disease information from knowledge graph
POST
/api/v1/clinical/explain-reasoning
KG-based clinical reasoning
POST
/api/v1/agents/screen
Full LangGraph agentic screening pipeline
GET
/api/v1/agents/status
Agent orchestrator status
Governance (Phase 1+3)
Method
Path
Description
GET
/api/v1/governance/drift
Drift detection status + history
GET
/api/v1/governance/active-learning-stats
Active learning queue + fine-tune history
GET
/api/v1/governance/model-registry
MLflow registry status
GET
/api/v1/governance/fairness
Fairness dashboard with demographic breakdowns
GET
/api/v1/governance/model-card
Current model card (JSON or Markdown)
GET
/api/v1/governance/audit
Query immutable audit log
GET
/api/v1/governance/audit/integrity
Verify audit chain integrity (SHA-256)
Voice (Phase 5)
Method
Path
Description
WS
/v1/voice/stream
WebSocket for streaming ASR/TTS with Luganda support
Uganda Health Ecosystem (Phase 5)
Method
Path
Description
GET
/api/v1/dhis2/patient/search
Search patients in DHIS2 by name or NIN
POST
/api/v1/dhis2/referral
Create referral event (offline queue fallback)
POST
/api/v1/payments/request
Initiate MTN MoMo or Airtel Money payment
POST
/api/v1/sms/send-referral
Send bilingual referral SMS
POST
/api/v1/sms/ussd
USSD session callback for feature phones
GET
/api/v1/fhir/DiagnosticReport/{id}
FHIR R4 DiagnosticReport with SNOMED CT codes
GET
/api/v1/fhir/Bundle/{id}
FHIR R4 Bundle (report + observations)
POST
/api/v1/dicom/upload
Upload DICOM file, extract fundus images
POST
/api/v1/offline/bundle/delta
Delta sync for mobile bundle updates
Edge Inference (Phase 3)
Method
Path
Description
POST
/api/v1/predict/onnx
ONNX Runtime inference
POST
/api/v1/predict/coreml
Core ML inference (Apple Silicon)
POST
/api/v1/predict/quantized
INT8/FP16 quantized inference
GET
/api/v1/predict/edge/status
Loaded edge formats + config
Make Targets
# Development
make install # Install backend (uv) + frontend (bun)
make install-backend # Install backend only (uv sync)
make install-frontend # Install frontend only (bun install)
make dev # Run backend + frontend in parallel
make backend # Run backend only (uvicorn, port 8080)
make frontend # Run frontend only (bun dev, port 3000)
make build-frontend # Build frontend for production
make test# Run 210+ tests
make test-fast # Run tests (fail-fast mode)# Training
make train # 8-GPU DDP training
make train-4gpu # 4-GPU DDP training
make train-1gpu # Single GPU training (CUDA:2)
make validate-data # Data quality validation
make hpo # Optuna hyperparameter optimization
make pipeline # Full pipeline: train + plots# Production
make export# ONNX + TorchScript export
make export-all # Export all formats with parity validation
make model-card # Generate model & dataset cards
make sbom # Generate SBOM (Syft + Grype)
make mlops-pipeline # Full: validate -> train -> export -> model card# 2026 Infrastructure
make up-phase1 # OTEL + Jaeger + Prometheus + MLflow
make up-phase2 # Phase 1 + Ray Serve + Kafka
make up-full # Full 2026 stack (all phases)
make down-full # Teardown full stack# Mobile/Offline
make distill # Distill teacher to MobileNetV3-Large student (GPU required)
make export-mobile # Export student + gate ONNX INT8 + bundle
make pilot-readiness # Validate national pilot readiness (12 checks)# Governance
make bias-audit-uganda # Uganda-specific bias audit (F1 disparity < 0.08)
make federated-sim # Simulate federated learning (5 clients, Dirichlet split)
make moh-package # Generate Uganda MoH regulatory submission# Fundus Gate V2
make test-gate # Run 57 gate tests (24 unit + 33 adversarial)
make benchmark-gate # Gate latency benchmarks (p50/p95/p99)# Deployment
make deploy-hf # Deploy to Hugging Face Spaces
make hf-login # Authenticate with HuggingFace CLI
make hf-local # Local test of HF Spaces Docker image# Utilities
make check-retrain # Check if retraining is needed
make dvc-repro # Reproduce DVC pipeline
make plots # Generate IEEE publication plots
make plots-eda # Generate EDA plots only
make clean # Remove checkpoints, cache
2026 Production Features
All features are opt-in via environment variables (FEATURE__ENABLED=true). Disabled by default for backward compatibility.