# ajay-1011-git/cureva architecture

> Architecture diagram of the GitHub repository ajay-1011-git/cureva, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ajay-1011-git/cureva
- Repository: https://github.com/ajay-1011-git/cureva

## Overview

Cureva is a clinical-study review system: Atlas answers questions over study records and produces evidence-backed findings; later stages review and monitor those findings, with forecasts and drafted paperwork. The web app exposes Atlas, multilingual avatar intake, review, and surveillance. The README documents the major capabilities, while sampled source confirms selected ownership and isolation boundaries; some subsystem wiring is therefore shown only where documented or directly supported.

Main entry points: [`webapp/server.py`](https://github.com/ajay-1011-git/cureva/blob/main/webapp/server.py) (API server), [`stage2/crew.py`](https://github.com/ajay-1011-git/cureva/blob/main/stage2/crew.py) (Review cycle), [`stage1/atlas.py`](https://github.com/ajay-1011-git/cureva/blob/main/stage1/atlas.py) (Atlas), [`stage3/watch.py`](https://github.com/ajay-1011-git/cureva/blob/main/stage3/watch.py) (Period surveillance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_atlas["Study analysis"]
  node_atlas["Atlas<br/>[atlas.py]"]
  node_study["Study loader<br/>[study.py]"]
  node_schemas["Answer schemas<br/>[schemas.py]"]
  node_finding_graph["Finding graph<br/>[finding_graph.py]"]
end

subgraph group_intake["Patient intake"]
  node_speech["Speech services<br/>[sarvam_client.py]"]
  node_patient_context["Patient context<br/>[patient_context.py]"]
  node_avatar_turn["Avatar response<br/>[groq_client.py]"]
  node_pro_records[("PRO records<br/>[atlas.py]")]
end

subgraph group_review["Finding review"]
  node_crew["Review cycle<br/>[crew.py]"]
  node_review_memory[("Review memory<br/>[memory.py]")]
  node_tribunal["Tribunal rounds<br/>[round1.py]"]
  node_tribunal_client["Tribunal model client<br/>[client.py]"]
end

subgraph group_surveillance["Study surveillance"]
  node_watch["Period surveillance<br/>[watch.py]"]
  node_watch_memory[("Surveillance memory<br/>[memory.py]")]
  node_forecast["Deviation forecast<br/>[montecarlo.py]"]
  node_artifacts["Drafted artifacts<br/>[templates.py]"]
  node_polish["Artifact polishing<br/>[polish.py]"]
end

subgraph group_interface["Web interface"]
  node_avatar_ui["Avatar intake UI<br/>[AvatarTest.jsx]"]
  node_server["API server<br/>[server.py]"]
  node_web_ui["Study dashboard<br/>[App.jsx]"]
end

node_reviewer(("Reviewer"))
node_study_data[("Study CSVs")]
node_sarvam{{"Sarvam speech API"}}
node_groq{{"Groq model API"}}

node_reviewer -->|"uses"| node_web_ui
node_reviewer -->|"asks"| node_server
node_study_data -->|"loads"| node_study
node_study -->|"provides records"| node_atlas
node_atlas -->|"validates answers"| node_schemas
node_server -->|"dispatches questions"| node_atlas
node_atlas -->|"returns answers"| node_server
node_server -->|"observes findings"| node_finding_graph
node_server -->|"runs cycles"| node_crew
node_crew -->|"requests detections"| node_atlas
node_crew -->|"records review state"| node_review_memory
node_crew -.->|"requests deliberation"| node_tribunal
node_tribunal -->|"requests model calls"| node_tribunal_client
node_tribunal_client -.->|"calls"| node_groq
node_server -->|"runs period walk"| node_watch
node_watch -->|"runs review cycles"| node_crew
node_watch -->|"records period state"| node_watch_memory
node_watch -->|"requests forecasts"| node_forecast
node_server -->|"serves artifact drafts"| node_artifacts
node_artifacts -->|"drafts for polishing"| node_polish
node_avatar_ui -->|"sends turns"| node_server
node_server -->|"transcribes and speaks"| node_speech
node_speech -.->|"calls"| node_sarvam
node_server -->|"loads context"| node_patient_context
node_server -->|"requests response"| node_avatar_turn
node_avatar_turn -.->|"calls"| node_groq
node_server -->|"adds intake records"| node_pro_records

click node_atlas "https://github.com/ajay-1011-git/cureva/blob/main/stage1/atlas.py"
click node_study "https://github.com/ajay-1011-git/cureva/blob/main/study.py"
click node_schemas "https://github.com/ajay-1011-git/cureva/blob/main/schemas.py"
click node_finding_graph "https://github.com/ajay-1011-git/cureva/blob/main/graph/finding_graph.py"
click node_avatar_ui "https://github.com/ajay-1011-git/cureva/blob/main/webapp/frontend/src/pages/AvatarTest.jsx"
click node_server "https://github.com/ajay-1011-git/cureva/blob/main/webapp/server.py"
click node_web_ui "https://github.com/ajay-1011-git/cureva/blob/main/webapp/frontend/src/App.jsx"
click node_speech "https://github.com/ajay-1011-git/cureva/blob/main/intake/sarvam_client.py"
click node_patient_context "https://github.com/ajay-1011-git/cureva/blob/main/intake/patient_context.py"
click node_avatar_turn "https://github.com/ajay-1011-git/cureva/blob/main/intake/groq_client.py"
click node_pro_records "https://github.com/ajay-1011-git/cureva/blob/main/stage1/atlas.py"
click node_crew "https://github.com/ajay-1011-git/cureva/blob/main/stage2/crew.py"
click node_review_memory "https://github.com/ajay-1011-git/cureva/blob/main/stage2/memory.py"
click node_tribunal "https://github.com/ajay-1011-git/cureva/blob/main/tribunal/round1.py"
click node_tribunal_client "https://github.com/ajay-1011-git/cureva/blob/main/tribunal/client.py"
click node_watch "https://github.com/ajay-1011-git/cureva/blob/main/stage3/watch.py"
click node_watch_memory "https://github.com/ajay-1011-git/cureva/blob/main/stage3/memory.py"
click node_forecast "https://github.com/ajay-1011-git/cureva/blob/main/forecast/montecarlo.py"
click node_artifacts "https://github.com/ajay-1011-git/cureva/blob/main/execute/templates.py"
click node_polish "https://github.com/ajay-1011-git/cureva/blob/main/execute/polish.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_atlas,node_study,node_schemas,node_finding_graph,node_reviewer toneBlue
class node_speech,node_patient_context,node_avatar_turn,node_pro_records,node_study_data toneAmber
class node_crew,node_review_memory,node_tribunal,node_tribunal_client,node_sarvam,node_groq toneMint
class node_watch,node_watch_memory,node_forecast,node_artifacts,node_polish toneRose
class node_avatar_ui,node_server,node_web_ui toneIndigo
```

## Components

### Study analysis

- [Atlas](https://github.com/ajay-1011-git/cureva/blob/main/stage1/atlas.py): `stage1/atlas.py`
- [Study loader](https://github.com/ajay-1011-git/cureva/blob/main/study.py): `study.py`
- [Answer schemas](https://github.com/ajay-1011-git/cureva/blob/main/schemas.py): `schemas.py`
- [Finding graph](https://github.com/ajay-1011-git/cureva/blob/main/graph/finding_graph.py): `graph/finding_graph.py`

### Patient intake

- [Speech services](https://github.com/ajay-1011-git/cureva/blob/main/intake/sarvam_client.py): `intake/sarvam_client.py`
- [Patient context](https://github.com/ajay-1011-git/cureva/blob/main/intake/patient_context.py): `intake/patient_context.py`
- [Avatar response](https://github.com/ajay-1011-git/cureva/blob/main/intake/groq_client.py): `intake/groq_client.py`
- [PRO records](https://github.com/ajay-1011-git/cureva/blob/main/stage1/atlas.py): `stage1/atlas.py`

### Finding review

- [Review cycle](https://github.com/ajay-1011-git/cureva/blob/main/stage2/crew.py): `stage2/crew.py`
- [Review memory](https://github.com/ajay-1011-git/cureva/blob/main/stage2/memory.py): `stage2/memory.py`
- [Tribunal rounds](https://github.com/ajay-1011-git/cureva/blob/main/tribunal/round1.py): `tribunal/round1.py`
- [Tribunal model client](https://github.com/ajay-1011-git/cureva/blob/main/tribunal/client.py): `tribunal/client.py`

### Study surveillance

- [Period surveillance](https://github.com/ajay-1011-git/cureva/blob/main/stage3/watch.py): `stage3/watch.py`
- [Surveillance memory](https://github.com/ajay-1011-git/cureva/blob/main/stage3/memory.py): `stage3/memory.py`
- [Deviation forecast](https://github.com/ajay-1011-git/cureva/blob/main/forecast/montecarlo.py): `forecast/montecarlo.py`
- [Drafted artifacts](https://github.com/ajay-1011-git/cureva/blob/main/execute/templates.py): `execute/templates.py`
- [Artifact polishing](https://github.com/ajay-1011-git/cureva/blob/main/execute/polish.py): `execute/polish.py`

### Web interface

- [Avatar intake UI](https://github.com/ajay-1011-git/cureva/blob/main/webapp/frontend/src/pages/AvatarTest.jsx): `webapp/frontend/src/pages/AvatarTest.jsx`
- [API server](https://github.com/ajay-1011-git/cureva/blob/main/webapp/server.py): `webapp/server.py`
- [Study dashboard](https://github.com/ajay-1011-git/cureva/blob/main/webapp/frontend/src/App.jsx): `webapp/frontend/src/App.jsx`

### Other components

- **Reviewer**
- **Study CSVs**
- **Sarvam speech API**
- **Groq model API**

## Connections

- Reviewer → Study dashboard: uses
- Reviewer → API server: asks
- Study CSVs → Study loader: loads
- Study loader → Atlas: provides records
- Atlas → Answer schemas: validates answers
- API server → Atlas: dispatches questions
- Atlas → API server: returns answers
- API server → Finding graph: observes findings
- API server → Review cycle: runs cycles
- Review cycle → Atlas: requests detections
- Review cycle → Review memory: records review state
- Review cycle → Tribunal rounds: requests deliberation
- Tribunal rounds → Tribunal model client: requests model calls
- Tribunal model client → Groq model API: calls
- API server → Period surveillance: runs period walk
- Period surveillance → Review cycle: runs review cycles
- Period surveillance → Surveillance memory: records period state
- Period surveillance → Deviation forecast: requests forecasts
- API server → Drafted artifacts: serves artifact drafts
- Drafted artifacts → Artifact polishing: drafts for polishing
- Avatar intake UI → API server: sends turns
- API server → Speech services: transcribes and speaks
- Speech services → Sarvam speech API: calls
- API server → Patient context: loads context
- API server → Avatar response: requests response
- Avatar response → Groq model API: calls
- API server → PRO records: adds intake records
