How shisir2024/cureo_medi works
Purpose and Runtime
MediAssist AI is a health-information assistant that accepts consultation input, applies safety-oriented triage and specialist analysis, and returns structured JSON. The Python backend is the primary runtime; static HTML/CSS/JavaScript pages provide patient, learning, and doctor-facing interfaces. Deployment is indicated by Procfile; local startup is supported by run.sh.
Paths: backend/main.py, Procfile, frontend/consultation.html
API Entry and Session Boundaries
The backend application is initialized in backend/main.py and exposes domain routers for agent execution, authentication, consultations, and doctor workflows. Route modules form the HTTP boundary between frontend clients and application services. WebSocket state/connection handling is separated for real-time interactions.
Paths: backend/main.py, backend/routers/consult_routes.py, backend/ws_manager.py
Authentication and Persistence
Authentication is isolated from consultation logic, while database access is centralized behind a dedicated module. This creates a boundary for user identity, protected doctor/patient workflows, and persisted consultation-related records without coupling agents directly to storage.
Paths: backend/auth.py, backend/database.py, backend/routers/auth_routes.py
Orchestration Pipeline
backend/orchestrator.py is the central control-flow layer. It coordinates specialized agents rather than exposing their implementation details to routes. The expected flow starts with triage, proceeds to symptom analysis, conditionally invokes diagnosis/treatment/referral and visualization/scoring agents, then compiles a final response.
Paths: backend/orchestrator.py, backend/agents/triage.py, backend/agents/report.py
Safety and Emergency Handling
Triage is the first decision stage and governs safety-sensitive branching. Emergency cases are escalated through symptom analysis and visualization-oriented outputs, with an emergency fallback path rather than routine diagnostic/treatment progression. Global safety behavior and response framing are likely shared through the system prompt and agent prompts.
Paths: backend/agents/triage.py, backend/agents/symptom_analyzer.py, backend/system_prompt.py
Specialist Agent Layer
Each clinical-information concern is encapsulated as an agent: diagnosis, treatment, referral, vitals, symptom web, health score, heatmap, radar, and comparison. This supports parallel or selectively invoked analysis stages under orchestrator control. The report agent is the aggregation boundary that converts heterogeneous agent results into the final structured JSON contract.
Paths: backend/agents/diagnosis.py, backend/agents/treatment.py, backend/agents/health_score.py
LLM and Client Integration
LLM provider access is centralized in backend/llm.py, keeping model/API-key integration outside individual route handlers and likely reusable across agents. The frontend uses standalone pages and browser JavaScript; consultation and doctor portal pages are distinct clients of backend APIs.
Paths: backend/llm.py, frontend/consultation.js, frontend/doctor.js
Main entry points: main.py Backend application · consult_routes.py Consultation routes · report.py Report compiler · triage.py Safety triage
Components 20
Browser clients
- Consultation UI
frontend/consultation.html - Consultation client
frontend/consultation.js - Doctor portal client
frontend/doctor.js
Backend boundary
- Backend application · Initializes domain routers.
backend/main.py - Consultation routes
backend/routers/consult_routes.py - Authentication routes
backend/routers/auth_routes.py - WebSocket manager
backend/ws_manager.py
Clinical pipeline
- Agent orchestrator · Coordinates triage, selective specialist analysis, and response assembly.
backend/orchestrator.py - Safety triage · First decision stage for safety-sensitive branching.
backend/agents/triage.py - Symptom analysis
backend/agents/symptom_analyzer.py - Diagnosis agent
backend/agents/diagnosis.py - Treatment agent
backend/agents/treatment.py - Health scoring
backend/agents/health_score.py - Report compiler · Produces the structured JSON response contract.
backend/agents/report.py
Platform services
- Identity service
backend/auth.py - Persistence · Centralized access for consultation-related records.
backend/database.py - LLM integration · Centralizes model and API-key access.
backend/llm.py - Safety prompt · Provides global safety framing.
backend/system_prompt.py - Process deployment
Procfile - Local startup
run.sh
Connections 24
- Consultation UI → Consultation client: loads
- Consultation client → Consultation routes: HTTP
- Doctor portal client → Backend application: doctor APIs
- Backend application → Consultation routes: mounts
- Backend application → Authentication routes: mounts
- Backend application → WebSocket manager: real-time state
- Authentication routes → Identity service: authenticates
- Identity service → Persistence: user records
- Consultation routes → Agent orchestrator: consultation request
- Consultation routes → Persistence: consultation records
- Agent orchestrator → Safety triage: first stage
- Safety triage → Symptom analysis: analyze or emergency path
- Symptom analysis → Diagnosis agent: routine analysis
- Symptom analysis → Treatment agent: routine analysis
- Symptom analysis → Health scoring: scoring
- Safety triage → Report compiler: emergency fallback
- Diagnosis agent → Report compiler: findings
- Treatment agent → Report compiler: guidance
- Health scoring → Report compiler: score
- Report compiler → Consultation routes: structured JSON
- Agent orchestrator → LLM integration: model access
- Safety triage → Safety prompt: safety framing
- Process deployment → Backend application: runs
- Local startup → Backend application: starts