# rachanna/cardio4cities architecture

> Architecture diagram of the GitHub repository rachanna/cardio4cities, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rachanna/cardio4cities
- Repository: https://github.com/rachanna/cardio4cities

## Overview

CARDIO4Cities is a city cardiovascular research assistant: a user asks about a city, the system researches public sources, checks evidence, and presents a cited brief. The graph preserves the documented live-research and Wave 0 capabilities, plus the sampled question-answering and coverage paths. Several workflow stages and integrations are represented at their exact tree paths, but their internal calls were not sampled; those connections are therefore documented at product level or left unverified.

Main entry points: [`app/workflow/runner.py`](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/runner.py) (Research workflow), [`app/query/pipeline.py`](https://github.com/rachanna/cardio4cities/blob/main/app/query/pipeline.py) (Question pipeline), [`app/report/assemble.py`](https://github.com/rachanna/cardio4cities/blob/main/app/report/assemble.py) (Brief assembly), [`app/api/routers/ask.py`](https://github.com/rachanna/cardio4cities/blob/main/app/api/routers/ask.py) (Ask endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_web["Web interface<br/>[page.tsx]"]
  node_api["FastAPI application<br/>[main.py]"]
  node_ask_api["Ask endpoint<br/>[ask.py]"]
  node_auth["Session access<br/>[auth.py]"]
end

subgraph group_research["City research"]
  node_city_workflow["Research workflow<br/>[runner.py]"]
  node_plan_search["Plan and search<br/>[search.py]"]
  node_source_select["Select sources<br/>[select_sources.py]"]
  node_fetch_parse["Fetch and parse<br/>[fetch_parse.py]"]
  node_extract["Extract claims<br/>[extract.py]"]
  node_verify["Verify claims<br/>[verify.py]"]
  node_coverage["Assess coverage<br/>[coverage.py]"]
  node_wave0["National baseline<br/>[wave0.py]"]
end

subgraph group_answers["Answers and reports"]
  node_qa_pipeline["Question pipeline<br/>[pipeline.py]"]
  node_qa_routes["Evidence retrieval routes"]
  node_fact_cards["Fact cards<br/>[cards.py]"]
  node_report["Brief assembly<br/>[assemble.py]"]
  node_report_render["Report rendering<br/>[render.py]"]
end

subgraph group_platform["Data and providers"]
  node_postgres[("Postgres research data<br/>[research.py]")]
  node_web_search["Web search providers"]
  node_fetch_provider["Web fetcher<br/>[httpx_pinned.py]"]
  node_document_parser["Document parser<br/>[documents.py]"]
  node_llm["Language model providers"]
  node_graph_store[("Knowledge graph<br/>[graphiti.py]")]
  node_vector_store[("Vector search<br/>[qdrant.py]")]
  node_structured_data["WHO and World Bank data"]
end

node_user(("City researcher"))

node_user -->|"asks about city"| node_web
node_web -.->|"uses API"| node_api
node_api -->|"routes requests"| node_ask_api
node_ask_api -->|"checks session"| node_auth
node_ask_api -->|"invokes answering"| node_qa_pipeline
node_user -.->|"starts city research"| node_city_workflow
node_city_workflow -.->|"dispatches stages"| node_plan_search
node_plan_search -.->|"searches web"| node_web_search
node_city_workflow -.->|"selects sources"| node_source_select
node_city_workflow -.->|"retrieves documents"| node_fetch_parse
node_fetch_parse -.->|"fetches pages"| node_fetch_provider
node_fetch_parse -.->|"parses documents"| node_document_parser
node_city_workflow -.->|"extracts evidence"| node_extract
node_city_workflow -.->|"checks claims"| node_verify
node_city_workflow -->|"assesses sufficiency"| node_coverage
node_coverage -->|"saves slot results"| node_postgres
node_coverage -->|"replans or advances"| node_city_workflow
node_city_workflow -.->|"loads baseline"| node_wave0
node_wave0 -.->|"reads health indicators"| node_structured_data
node_qa_pipeline -->|"runs retrieval routes"| node_qa_routes
node_qa_pipeline -->|"reads research facts"| node_postgres
node_qa_pipeline -.->|"drafts answer"| node_llm
node_qa_pipeline -->|"builds evidence cards"| node_fact_cards
node_city_workflow -->|"uses model roles"| node_llm
node_qa_pipeline -.->|"retrieves relations"| node_graph_store
node_qa_pipeline -.->|"retrieves similar claims"| node_vector_store
node_user -.->|"requests cited brief"| node_report
node_report -.->|"assembles research"| node_postgres
node_report -->|"uses fact presentation"| node_fact_cards
node_report -.->|"renders brief"| node_report_render

click node_web "https://github.com/rachanna/cardio4cities/blob/main/web/app/city/page.tsx"
click node_api "https://github.com/rachanna/cardio4cities/blob/main/app/main.py"
click node_ask_api "https://github.com/rachanna/cardio4cities/blob/main/app/api/routers/ask.py"
click node_auth "https://github.com/rachanna/cardio4cities/blob/main/app/api/auth.py"
click node_city_workflow "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/runner.py"
click node_plan_search "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/search.py"
click node_source_select "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/select_sources.py"
click node_fetch_parse "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/fetch_parse.py"
click node_extract "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/extract.py"
click node_verify "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/verify.py"
click node_coverage "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/coverage.py"
click node_wave0 "https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/wave0.py"
click node_qa_pipeline "https://github.com/rachanna/cardio4cities/blob/main/app/query/pipeline.py"
click node_qa_routes "https://github.com/rachanna/cardio4cities/tree/main/app/query/routes"
click node_fact_cards "https://github.com/rachanna/cardio4cities/blob/main/app/domain/cards.py"
click node_report "https://github.com/rachanna/cardio4cities/blob/main/app/report/assemble.py"
click node_report_render "https://github.com/rachanna/cardio4cities/blob/main/app/report/render.py"
click node_postgres "https://github.com/rachanna/cardio4cities/blob/main/app/adapters/postgres/repos/research.py"
click node_web_search "https://github.com/rachanna/cardio4cities/tree/main/app/adapters/search"
click node_fetch_provider "https://github.com/rachanna/cardio4cities/blob/main/app/adapters/fetch/httpx_pinned.py"
click node_document_parser "https://github.com/rachanna/cardio4cities/blob/main/app/adapters/parse/documents.py"
click node_llm "https://github.com/rachanna/cardio4cities/tree/main/app/adapters/llm"
click node_graph_store "https://github.com/rachanna/cardio4cities/blob/main/app/adapters/graph/graphiti.py"
click node_vector_store "https://github.com/rachanna/cardio4cities/blob/main/app/adapters/vector/qdrant.py"
click node_structured_data "https://github.com/rachanna/cardio4cities/tree/main/app/adapters/structured"

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_web,node_api,node_ask_api,node_auth toneBlue
class node_city_workflow,node_plan_search,node_source_select,node_fetch_parse,node_extract,node_verify,node_coverage,node_wave0 toneAmber
class node_qa_pipeline,node_qa_routes,node_fact_cards,node_report,node_report_render toneMint
class node_postgres,node_web_search,node_fetch_provider,node_document_parser,node_llm,node_graph_store,node_vector_store,node_structured_data toneRose
class node_user toneIndigo
```

## Components

### User experience

- [Web interface](https://github.com/rachanna/cardio4cities/blob/main/web/app/city/page.tsx): `web/app/city/page.tsx`
- [FastAPI application](https://github.com/rachanna/cardio4cities/blob/main/app/main.py): `app/main.py`
- [Ask endpoint](https://github.com/rachanna/cardio4cities/blob/main/app/api/routers/ask.py): `app/api/routers/ask.py`
- [Session access](https://github.com/rachanna/cardio4cities/blob/main/app/api/auth.py): `app/api/auth.py`

### City research

- [Research workflow](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/runner.py): `app/workflow/runner.py`
- [Plan and search](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/search.py): `app/workflow/nodes/search.py`
- [Select sources](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/select_sources.py): `app/workflow/nodes/select_sources.py`
- [Fetch and parse](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/fetch_parse.py): `app/workflow/nodes/fetch_parse.py`
- [Extract claims](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/extract.py): `app/workflow/nodes/extract.py`
- [Verify claims](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/verify.py): `app/workflow/nodes/verify.py`
- [Assess coverage](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/coverage.py): `app/workflow/nodes/coverage.py`
- [National baseline](https://github.com/rachanna/cardio4cities/blob/main/app/workflow/nodes/wave0.py): `app/workflow/nodes/wave0.py`

### Answers and reports

- [Question pipeline](https://github.com/rachanna/cardio4cities/blob/main/app/query/pipeline.py): `app/query/pipeline.py`
- [Evidence retrieval routes](https://github.com/rachanna/cardio4cities/tree/main/app/query/routes): `app/query/routes`
- [Fact cards](https://github.com/rachanna/cardio4cities/blob/main/app/domain/cards.py): `app/domain/cards.py`
- [Brief assembly](https://github.com/rachanna/cardio4cities/blob/main/app/report/assemble.py): `app/report/assemble.py`
- [Report rendering](https://github.com/rachanna/cardio4cities/blob/main/app/report/render.py): `app/report/render.py`

### Data and providers

- [Postgres research data](https://github.com/rachanna/cardio4cities/blob/main/app/adapters/postgres/repos/research.py): `app/adapters/postgres/repos/research.py`
- [Web search providers](https://github.com/rachanna/cardio4cities/tree/main/app/adapters/search): `app/adapters/search`
- [Web fetcher](https://github.com/rachanna/cardio4cities/blob/main/app/adapters/fetch/httpx_pinned.py): `app/adapters/fetch/httpx_pinned.py`
- [Document parser](https://github.com/rachanna/cardio4cities/blob/main/app/adapters/parse/documents.py): `app/adapters/parse/documents.py`
- [Language model providers](https://github.com/rachanna/cardio4cities/tree/main/app/adapters/llm): `app/adapters/llm`
- [Knowledge graph](https://github.com/rachanna/cardio4cities/blob/main/app/adapters/graph/graphiti.py): `app/adapters/graph/graphiti.py`
- [Vector search](https://github.com/rachanna/cardio4cities/blob/main/app/adapters/vector/qdrant.py): `app/adapters/vector/qdrant.py`
- [WHO and World Bank data](https://github.com/rachanna/cardio4cities/tree/main/app/adapters/structured): `app/adapters/structured`

### Other components

- **City researcher**

## Connections

- City researcher → Web interface: asks about city (evidence: `README.md`)
- Web interface → FastAPI application: uses API
- FastAPI application → Ask endpoint: routes requests (evidence: `app/main.py`)
- Ask endpoint → Session access: checks session (evidence: `app/api/routers/ask.py`)
- Ask endpoint → Question pipeline: invokes answering (evidence: `app/api/routers/ask.py`)
- City researcher → Research workflow: starts city research
- Research workflow → Plan and search: dispatches stages
- Plan and search → Web search providers: searches web
- Research workflow → Select sources: selects sources
- Research workflow → Fetch and parse: retrieves documents
- Fetch and parse → Web fetcher: fetches pages
- Fetch and parse → Document parser: parses documents
- Research workflow → Extract claims: extracts evidence
- Research workflow → Verify claims: checks claims
- Research workflow → Assess coverage: assesses sufficiency (evidence: `app/workflow/nodes/coverage.py`)
- Assess coverage → Postgres research data: saves slot results (evidence: `app/workflow/nodes/coverage.py`)
- Assess coverage → Research workflow: replans or advances (evidence: `app/workflow/nodes/coverage.py`)
- Research workflow → National baseline: loads baseline
- National baseline → WHO and World Bank data: reads health indicators
- Question pipeline → Evidence retrieval routes: runs retrieval routes (evidence: `app/query/pipeline.py`)
- Question pipeline → Postgres research data: reads research facts (evidence: `app/query/pipeline.py`)
- Question pipeline → Language model providers: drafts answer
- Question pipeline → Fact cards: builds evidence cards (evidence: `app/query/pipeline.py`)
- Research workflow → Language model providers: uses model roles
- Question pipeline → Knowledge graph: retrieves relations
- Question pipeline → Vector search: retrieves similar claims
- City researcher → Brief assembly: requests cited brief
- Brief assembly → Postgres research data: assembles research
- Brief assembly → Fact cards: uses fact presentation (evidence: `app/report/assemble.py`)
- Brief assembly → Report rendering: renders brief
