Clinify Analytics API is the intelligence layer of the Clinify ecosystem. It exposes high-performance endpoints for Business Intelligence, Predictive Modeling, and Generative AI explanations, decoupling heavy computation from the core backend.
- Endpoint:
GET /api/v1/dashboard/overview - Source: Aggregates data from the Star Schema (OLAP) in Supabase.
- Optimization: Implements a Cache-Aside strategy using Redis (Upstash) to reduce database load and serve metrics in <50ms.
- Endpoint:
POST /api/v1/predict/no-show - Algorithm: Random Forest Classifier (
scikit-learn). - Function: Predicts the probability of a patient missing an appointment based on lead time, specialty, and day of the week.
- MLOps: Auto-training pipeline on startup if the model artifact is missing.
- Endpoint:
POST /api/v1/explain-diagnosis - Engine: Google Gemini 1.5 Flash Lite.
- Function: Translates complex CIE-10 medical codes into empathetic, easy-to-understand language for patients.
- Framework: FastAPI (Python 3.11)
- ORM: SQLAlchemy (Async/Sync hybrid approach)
- Caching: Upstash Redis (Serverless)
- AI/ML: Scikit-learn, Pandas, Google Generative AI SDK
- Quality Assurance: Pytest, HTTPX
- Container: Docker
- Docker
- A
.envfile with credentials.
Create a .env file in the root directory. All variables are required:
# Database (Supabase)
DATABASE_URL=postgresql://user:pass@host:5432/postgres
# Generative AI (Google AI Studio)
GEMINI_API_KEY=AIzaSy...
# Caching (Upstash Redis)
UPSTASH_REDIS_REST_URL=https://...
UPSTASH_REDIS_REST_TOKEN=...# Build and run (with hot reload for development)
docker-compose up --buildThis project includes an automated integration test suite ensuring API health and data consistency.
# Run tests inside Docker (Recommended)
docker run --rm --env-file .env -v "$(pwd):/app" clinify-api pytestOnce running, verify endpoints at:
http://localhost:8000/docs
2025 Clinify Team - CodeUp Riwi Project