System Architecture
Six explicit layers separate presentation, data, reasoning, governance, and evaluation. Each layer can be inspected, audited, and replaced independently.
Frontend
— React + TanStack Start- Clinical intake form (TH/EN)
- AI Analysis & Evidence Panel
- Clinician review & override UI
- Case report export (Markdown / PDF)
Backend
— Lovable Cloud (managed Postgres + Auth)- patient_cases, ai_results
- clinician_observations
- case_outcomes
- expert_validations
Knowledge Base
— Curated TTM ontology tables- explainability_traces
- therapeutic_directions
- clinical_safety_rules
- knowledge_consensus
- ml_feature_schema / ai_response_schema
AI / Reasoning Layer
— Rule-based syndrome prediction- Deterministic rules over symptom features
- Outputs syndrome_id, risk_level, referral
- Confidence + reasoning text
- Hook-points for future ML models
Governance Layer
— Safety + clinician oversight- Safety rule triggers → urgent_referral
- Clinician override always wins
- Override comparison & audit log
- Mandatory disclaimers
Validation Layer
— Expert evaluation- 1–5 ratings across 5 dimensions
- Reviewer role + free-text comments
- Dashboard aggregates by dimension/role
- Drives thesis evaluation
Data flow
Clinician input ──▶ Frontend form
│
▼
patient_cases ──▶ Rule engine ──▶ ai_results (syndrome_id, risk, confidence)
│
▼
Knowledge base lookup (syndrome_id)
├─ explainability_traces
├─ therapeutic_directions
├─ clinical_safety_rules ──▶ Safety escalation?
└─ knowledge_consensus
│
▼
Evidence Panel (UI)
│
▼
Clinician review / override ──▶ clinician_observations
│
▼
Case report (Markdown / PDF)
│
▼
Expert validation ──▶ expert_validations