How rohit-p27/healthcare-ai-india works
Purpose and Entry Points
AI Sarthi is an India-focused healthcare-governance intelligence platform: operational data, analytics, RAG, and agent workflows support budget, epidemic, supply, insurance, geographic, and district analysis. Runtime entry points are the FastAPI backend at core_platform/backend/main.py (with application setup in core_platform/backend/app/main.py), Next.js UI under core_platform/frontend/app, and CLI-oriented ETL/RAG packages via core_platform/etl/__main__.py and core_platform/rag/__main__.py.
User Interface and API Boundary
The Next.js/TypeScript frontend presents dashboards, geographic drilldowns, domain screens, and an AI copilot/query experience. Shared API access is centralized in core_platform/frontend/lib/api.ts; app routes include core_platform/frontend/app/ask/page.tsx, core_platform/frontend/app/districts/page.tsx, and core_platform/frontend/app/knowledge-graph/page.tsx. It communicates with versioned FastAPI routes rather than accessing data stores directly.
Backend Domain Services
FastAPI route handlers define the external contract and delegate domain logic to service modules. The central route composition is core_platform/backend/api/v1/router.py; representative boundaries are chat/orchestration (core_platform/backend/api/v1/chat.py, core_platform/backend/api/v1/orchestrator.py), RAG (core_platform/backend/api/v1/rag.py), and analytical domains such as budget, epidemic, insurance, supply, district, and geo. Services own application-level queries and calculations, e.g. core_platform/backend/services/budget_service.py, core_platform/backend/services/epidemic_service.py, and core_platform/backend/services/rag_service.py.
Persistent Data and Governance Model
The backend separates ORM persistence models from request/response schemas: core_platform/backend/models covers health, governance, coordination, geo, RAG, and analytic domains, while core_platform/backend/schemas is the API serialization boundary. Database initialization/session handling lives in core_platform/backend/db/session.py; Alembic migrations establish core schemas, district-profile fields, and pgvector support in core_platform/backend/alembic/versions/0001_create_schemas_and_core_tables.py through 0003_rag_pgvector.py. SQLite database files are present for development; the intended production relational/vector target is PostgreSQL with pgvector.
Data Ingestion and Curated Marts
ETL converts source health/governance data into normalized, validated data products. The CLI orchestrates pipelines from core_platform/etl/cli.py; shared ingestion and normalization are in core_platform/etl/common/ingestor.py and core_platform/etl/common/normalize.py. Geographic identity is a cross-domain join boundary via core_platform/etl/transform/geo_spine.py; district profiles derive from it in core_platform/etl/transform/district_profile.py. Curated Parquet marts in datasets/curated/mart_geo_spine_v1/data.parquet and datasets/curated/mart_district_profile_v1/data.parquet feed operational loading and analytics.
AI, RAG, and Agent Control Flow
Natural-language requests enter API chat/orchestration, then the agentic gateway and orchestrator select specialized budget, epidemic, insurance, policy, research, or supply agents. Coordination and memory abstractions are in core_platform/agents/core/orchestrator.py, core_platform/agents/core/memory.py, and core_platform/agents/workflows/agentic_gateway.py. RAG ingestion loads documents, chunks, embeds, and indexes them; retrieval performs hybrid search, reranking, context construction, and citations via core_platform/rag/indexing/embedder.py, core_platform/rag/retrieval/pipeline.py, and core_platform/rag/retrieval/hybrid_search.py. The repository also contains Neo4j-oriented graph integration at core_platform/knowledge_graph/connector.py and ontology definitions at core_platform/knowledge_graph/ontology.py.
Analytics and Model Operations
Domain APIs/services expose predictive and anomaly-oriented functions described by the platform: epidemic detection, budget forecasting, and insurance analysis. MLOps primitives for features, registry, monitoring, and serving are isolated in core_platform/mlops/feature_store.py, core_platform/mlops/registry.py, and core_platform/mlops/serving.py. Healthcare SLM training assets are separate from serving infrastructure under healthcare_slm/training, including healthcare_slm/training/llm/finetune_qlora.py.
Deployment and External Dependencies
The main material runtimes are Python/FastAPI, Node.js/Next.js, PostgreSQL/pgvector, and optionally Neo4j for GraphRAG. Docker deployment artifacts are deployment/Dockerfile.backend, deployment/Dockerfile.frontend, and deployment/docker-compose.yml. External knowledge inputs are local policy, budget, and health PDFs/CSVs under data/raw; embedding/vector artifacts also exist in vector_store/chroma.sqlite3, indicating a local Chroma-style development vector store alongside the PostgreSQL vector migration path.
Main entry points: router.py Versioned route contract · orchestrator.py Agent orchestration & memory · budget_service.py Domain services · session.py PostgreSQL + pgvector
Components 19
User Experience
- Next.js dashboards & copilot · Domain dashboards, drilldowns, and AI query screens.
core_platform/frontend/app - API client
core_platform/frontend/lib/api.ts
Platform API
- FastAPI application
core_platform/backend/main.py - Versioned route contract · Composes domain, chat, orchestration, and RAG endpoints.
core_platform/backend/api/v1/router.py - Domain services · Budget, epidemic, insurance, supply, district, geo, and RAG logic.
core_platform/backend/services/budget_service.py - API schemas
core_platform/backend/schemas - ORM domain models
core_platform/backend/models
Data & AI Pipelines
- Agent gateway · Routes requests to specialized domain agents.
core_platform/agents/workflows/agentic_gateway.py - Agent orchestration & memory
core_platform/agents/core/orchestrator.py - Hybrid RAG retrieval · Hybrid search, reranking, context assembly, and citations.
core_platform/rag/retrieval/pipeline.py - RAG embedding & indexing
core_platform/rag/indexing/embedder.py - ETL orchestration
core_platform/etl/cli.py - Geographic identity spine · Cross-domain geographic join boundary.
core_platform/etl/transform/geo_spine.py - District profile mart
datasets/curated/mart_district_profile_v1/data.parquet - Model serving · Serves predictive and anomaly-oriented model functions.
core_platform/mlops/serving.py
Data Stores
- PostgreSQL + pgvector · Production operational, analytic, and vector persistence target.
core_platform/backend/db/session.py - Local Chroma vector store
vector_store/chroma.sqlite3 - Neo4j knowledge graph · Optional graph store backed by ontology definitions.
core_platform/knowledge_graph/connector.py - Policy, budget & health sources
data/raw
Connections 22
- Next.js dashboards & copilot → API client: uses
- API client → FastAPI application: versioned HTTP API
- FastAPI application → Versioned route contract: mounts
- Versioned route contract → API schemas: serializes
- Versioned route contract → Domain services: delegates
- Domain services → ORM domain models: queries
- ORM domain models → PostgreSQL + pgvector: persists
- Versioned route contract → Agent gateway: chat and orchestration
- Agent gateway → Agent orchestration & memory: coordinates
- Agent orchestration & memory → Hybrid RAG retrieval: requests evidence
- Hybrid RAG retrieval → PostgreSQL + pgvector: searches vectors
- Hybrid RAG retrieval → Local Chroma vector store: development retrieval
- Agent orchestration & memory → Domain services: uses domain analysis
- Domain services → Model serving: invokes models
- Agent orchestration & memory → Neo4j knowledge graph: optional GraphRAG
- Policy, budget & health sources → ETL orchestration: ingests
- ETL orchestration → Geographic identity spine: normalizes and joins
- Geographic identity spine → District profile mart: derives
- District profile mart → PostgreSQL + pgvector: operational loading
- Policy, budget & health sources → RAG embedding & indexing: documents
- RAG embedding & indexing → PostgreSQL + pgvector: indexes embeddings
- RAG embedding & indexing → Local Chroma vector store: local index