How lokeshreddydodla/wtlossinahealth-server works
AiHealth Server is a FastAPI backend for patient and care-provider health services, including AI-assisted health queries, cohort research, profile onboarding, and health-data reporting. A typical query enters through an API route, is authorized and shaped for an agent, then streams a response; patient and provider APIs expose the broader health-data workflows. The repository also contains clinical, meal-analysis, voice, and monitoring capabilities. The graph emphasizes documented route wiring and indexed module references; several internal services and integrations are represented only at subsystem level because their source was not sampled.
Main entry points: import_routes.py Route registry · services Patient health services · query_v3.py Health-query API · query.py Cohort research API
Components 22
API and access
- FastAPI application
app/main.py - Route registry
app/import_routes.py - Patient API
rest_server/patients/router.py - Care-provider API
rest_server/care_provider/router.py - Health-query API
rest_server/v1/health_query_agent/query_v3.py - Cohort research API
rest_server/v1/research_agent/query.py - Profile-agent API
rest_server/profile_agent/router.py
AI experiences
- Health-query agent
lib/ai_foundation/agents/health_query - Research agent
lib/ai_foundation/agents/research_agent - Meal analysis
lib/ai_foundation/agents/meal_analysis - Voice interaction
lib/ai_foundation/voice
Health services
- Profile onboarding
lib/services/profile_agent - Metabolic assessment
lib/ai_foundation/clinical/metabolic - Patient health services
lib/services - Health reports
lib/services/reports
Platform services
- Relational storage
lib/core/postgres_store.py - Model gateway
lib/ai_foundation/models/gateway.py - SSE streaming
lib/ai_foundation/streaming/sse.py - Event bus
lib/ai_foundation/events/bus.py
Background work
- Task manager
lib/managers/arq_task_manager.py - Background tasks
lib/workers/tasks
Other components
- Patient or provider
Connections 25
- Patient or provider → FastAPI application: requests API
- FastAPI application → Route registry: registers routes
app/main.py - Route registry → Patient API: includes router
app/import_routes.py - Route registry → Care-provider API: includes router
app/import_routes.py - Route registry → Health-query API: includes v1 routes
app/import_routes.py - Route registry → Cohort research API: includes v1 routes
app/import_routes.py - Route registry → Profile-agent API: includes router
app/import_routes.py - Patient or provider → Health-query API: asks health question
rest_server/v1/health_query_agent/query_v3.py - Health-query API → Health-query agent: resolves agent
rest_server/v1/health_query_agent/query_v3.py - Health-query agent → Model gateway: requests completion
lib/ai_foundation/agents/health_query/reasoning_engine.py - Health-query API → SSE streaming: streams response
rest_server/v1/health_query_agent/query_v3.py - Patient or provider → Cohort research API: asks cohort question
rest_server/v1/research_agent/query.py - Cohort research API → Research agent: runs research
rest_server/v1/research_agent/query.py - Research agent → Model gateway: requests completion
lib/ai_foundation/agents/research_agent/reasoning_engine.py - Cohort research API → SSE streaming: streams response
rest_server/v1/research_agent/query.py - Profile-agent API → Profile onboarding: calls service
rest_server/profile_agent/router.py - Patient API → Patient health services: exposes health routes
rest_server/patients/router.py - Care-provider API → Patient health services: exposes patient routes
rest_server/care_provider/router.py - Patient health services → Relational storage: persists health data
lib/services/package_query_service.py - Patient health services → Health reports: supports reporting
- Meal analysis → Model gateway: uses model
- Voice interaction → SSE streaming: streams audio interactions
- Metabolic assessment → Patient health services: assesses patient data
- Task manager → Background tasks: enqueues tasks
lib/managers/arq_task_manager.py - FastAPI application → Relational storage: initializes storage
app/main.py