Skip to content

ClinifyCo/Clinify-Analytics-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Clinify Analytics API (Microservice)

FastAPI Docker Redis Gemini Tests

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.

🚀 Key Features

1. ⚡ High-Performance Analytics (Cached)

  • 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.

2. 🔮 Predictive Machine Learning

  • 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.

3. 🧬 Generative AI (LLM)

  • 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.

🛠️ Tech Stack

  • 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

🔌 Setup & Usage

Prerequisites

  • Docker
  • A .env file with credentials.

Environment Variables

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=...

Run with Docker Compose

# Build and run (with hot reload for development)
docker-compose up --build

🧪 Running Tests

This 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 pytest

🔗 Documentation (Swagger UI)

Once running, verify endpoints at: http://localhost:8000/docs


2025 Clinify Team - CodeUp Riwi Project

About

High-performance Intelligence Microservice. Delivers real-time BI dashboards, Machine Learning predictions (No-Show risk), and Generative AI medical explanations using FastAPI, Redis, and Scikit-learn.

Topics

Resources

License

Stars

Watchers

Forks

Contributors