# mohammedsunoqrot/healdar architecture

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

- Interactive diagram: https://gitdiagram.com/mohammedsunoqrot/healdar
- Repository: https://github.com/mohammedsunoqrot/healdar

## Overview

Healdar is a bilingual regulatory-question assistant. Its user workflow runs from the Streamlit interface through query planning and hybrid retrieval to a cited, coverage-aware answer, with references rendered in the UI or exported. The repository also includes a corpus-preparation path from regulatory PDFs to chunk data and a searchable vector index, plus private usage analytics. The README documents comparison, follow-up, jurisdiction balancing, and refusal behavior; some detailed wiring is not visible in the sampled excerpts, so those relationships are cited to the README rather than inferred from module names.

Main entry points: [`src/app.py`](https://github.com/mohammedsunoqrot/healdar/blob/main/src/app.py) (Streamlit app), [`src/rag_pipeline.py`](https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py) (RAG orchestration), [`src/retrieval.py`](https://github.com/mohammedsunoqrot/healdar/blob/main/src/retrieval.py) (Hybrid retrieval), [`src/vectorstore.py`](https://github.com/mohammedsunoqrot/healdar/blob/main/src/vectorstore.py) (Vector store lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User experience"]
  node_app["Streamlit app<br/>[app.py]"]
  node_conversation["Conversation and comparison<br/>[app.py]"]
end

subgraph group_answering["Question answering"]
  node_pipeline["RAG orchestration<br/>[rag_pipeline.py]"]
  node_planning["Query planning<br/>[rag_pipeline.py]"]
  node_translation["Language translation<br/>[rag_pipeline.py]"]
  node_retrieval["Hybrid retrieval<br/>[retrieval.py]"]
  node_answer["Cited answer<br/>[rag_pipeline.py]"]
end

subgraph group_corpus["Regulatory corpus"]
  node_ingest["PDF ingestion<br/>[ingest.py]"]
  node_chunks["Passage corpus<br/>[chunks.json]"]
  node_embed["Index builder<br/>[embed.py]"]
  node_vectorstore["Vector store lifecycle<br/>[vectorstore.py]"]
  node_chroma[("Chroma index")]
end

subgraph group_support["Output and operations"]
  node_formatting["Answer formatting<br/>[formatting.py]"]
  node_export["PDF and Word export<br/>[export.py]"]
  node_analytics["Usage analytics<br/>[analytics.py]"]
  node_analyticsdb[("Analytics database<br/>[analytics.py]")]
end

node_visitor(("Visitor"))
node_groq{{"Groq models"}}
node_pdfsources["Regulatory PDFs"]

node_visitor -->|"asks question"| node_app
node_app -->|"submits query"| node_pipeline
node_app -->|"manages sessions"| node_conversation
node_conversation -->|"runs queries"| node_pipeline
node_pipeline -->|"translates Arabic"| node_translation
node_pipeline -->|"plans searches"| node_planning
node_planning -->|"requests plan"| node_groq
node_translation -->|"requests translation"| node_groq
node_pipeline -->|"searches passages"| node_retrieval
node_retrieval -->|"dense search"| node_chroma
node_pipeline -->|"generates response"| node_answer
node_answer -->|"generates answer"| node_groq
node_pipeline -->|"returns answer"| node_app
node_pdfsources -->|"provides documents"| node_ingest
node_ingest -->|"writes chunks"| node_chunks
node_embed -->|"loads chunks"| node_chunks
node_embed -->|"builds index"| node_vectorstore
node_vectorstore -->|"writes and opens"| node_chroma
node_retrieval -->|"uses index helpers"| node_vectorstore
node_app -->|"renders answers"| node_formatting
node_export -->|"parses answer"| node_formatting
node_app -->|"exports reports"| node_export
node_app -->|"records usage"| node_analytics
node_analytics -->|"stores and queries"| node_analyticsdb

click node_app "https://github.com/mohammedsunoqrot/healdar/blob/main/src/app.py"
click node_conversation "https://github.com/mohammedsunoqrot/healdar/blob/main/src/app.py"
click node_pipeline "https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py"
click node_planning "https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py"
click node_translation "https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py"
click node_retrieval "https://github.com/mohammedsunoqrot/healdar/blob/main/src/retrieval.py"
click node_answer "https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py"
click node_ingest "https://github.com/mohammedsunoqrot/healdar/blob/main/src/ingest.py"
click node_chunks "https://github.com/mohammedsunoqrot/healdar/blob/main/data/processed/chunks.json"
click node_embed "https://github.com/mohammedsunoqrot/healdar/blob/main/src/embed.py"
click node_vectorstore "https://github.com/mohammedsunoqrot/healdar/blob/main/src/vectorstore.py"
click node_chroma "https://github.com/mohammedsunoqrot/healdar/tree/main/data/processed/vectorstore"
click node_formatting "https://github.com/mohammedsunoqrot/healdar/blob/main/src/formatting.py"
click node_export "https://github.com/mohammedsunoqrot/healdar/blob/main/src/export.py"
click node_analytics "https://github.com/mohammedsunoqrot/healdar/blob/main/src/analytics.py"
click node_analyticsdb "https://github.com/mohammedsunoqrot/healdar/blob/main/src/analytics.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_app,node_conversation toneBlue
class node_pipeline,node_planning,node_translation,node_retrieval,node_answer toneAmber
class node_ingest,node_chunks,node_embed,node_vectorstore,node_chroma toneMint
class node_formatting,node_export,node_analytics,node_analyticsdb toneRose
class node_visitor,node_groq,node_pdfsources toneIndigo
```

## Components

### User experience

- [Streamlit app](https://github.com/mohammedsunoqrot/healdar/blob/main/src/app.py): `src/app.py`
- [Conversation and comparison](https://github.com/mohammedsunoqrot/healdar/blob/main/src/app.py): `src/app.py`

### Question answering

- [RAG orchestration](https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Query planning](https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Language translation](https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Hybrid retrieval](https://github.com/mohammedsunoqrot/healdar/blob/main/src/retrieval.py): `src/retrieval.py`
- [Cited answer](https://github.com/mohammedsunoqrot/healdar/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`

### Regulatory corpus

- [PDF ingestion](https://github.com/mohammedsunoqrot/healdar/blob/main/src/ingest.py): `src/ingest.py`
- [Passage corpus](https://github.com/mohammedsunoqrot/healdar/blob/main/data/processed/chunks.json): `data/processed/chunks.json`
- [Index builder](https://github.com/mohammedsunoqrot/healdar/blob/main/src/embed.py): `src/embed.py`
- [Vector store lifecycle](https://github.com/mohammedsunoqrot/healdar/blob/main/src/vectorstore.py): `src/vectorstore.py`
- [Chroma index](https://github.com/mohammedsunoqrot/healdar/tree/main/data/processed/vectorstore): `data/processed/vectorstore`

### Output and operations

- [Answer formatting](https://github.com/mohammedsunoqrot/healdar/blob/main/src/formatting.py): `src/formatting.py`
- [PDF and Word export](https://github.com/mohammedsunoqrot/healdar/blob/main/src/export.py): `src/export.py`
- [Usage analytics](https://github.com/mohammedsunoqrot/healdar/blob/main/src/analytics.py): `src/analytics.py`
- [Analytics database](https://github.com/mohammedsunoqrot/healdar/blob/main/src/analytics.py): `src/analytics.py`

### Other components

- **Visitor**
- **Groq models**
- **Regulatory PDFs**

## Connections

- Visitor → Streamlit app: asks question (evidence: `README.md`)
- Streamlit app → RAG orchestration: submits query (evidence: `src/app.py`)
- Streamlit app → Conversation and comparison: manages sessions (evidence: `README.md`)
- Conversation and comparison → RAG orchestration: runs queries (evidence: `README.md`)
- RAG orchestration → Language translation: translates Arabic (evidence: `README.md`)
- RAG orchestration → Query planning: plans searches (evidence: `README.md`)
- Query planning → Groq models: requests plan (evidence: `README.md`)
- Language translation → Groq models: requests translation (evidence: `README.md`)
- RAG orchestration → Hybrid retrieval: searches passages (evidence: `src/rag_pipeline.py`)
- Hybrid retrieval → Chroma index: dense search (evidence: `src/retrieval.py`)
- RAG orchestration → Cited answer: generates response (evidence: `README.md`)
- Cited answer → Groq models: generates answer (evidence: `README.md`)
- RAG orchestration → Streamlit app: returns answer (evidence: `README.md`)
- Regulatory PDFs → PDF ingestion: provides documents (evidence: `README.md`)
- PDF ingestion → Passage corpus: writes chunks (evidence: `README.md`)
- Index builder → Passage corpus: loads chunks (evidence: `src/embed.py`)
- Index builder → Vector store lifecycle: builds index (evidence: `src/embed.py`)
- Vector store lifecycle → Chroma index: writes and opens (evidence: `src/vectorstore.py`)
- Hybrid retrieval → Vector store lifecycle: uses index helpers (evidence: `src/retrieval.py`)
- Streamlit app → Answer formatting: renders answers (evidence: `src/app.py`)
- PDF and Word export → Answer formatting: parses answer (evidence: `src/export.py`)
- Streamlit app → PDF and Word export: exports reports (evidence: `src/app.py`)
- Streamlit app → Usage analytics: records usage (evidence: `src/app.py`)
- Usage analytics → Analytics database: stores and queries (evidence: `src/analytics.py`)
