# sandy-hax/multilingual-chatbot-with-rag- architecture

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

- Interactive diagram: https://gitdiagram.com/sandy-hax/multilingual-chatbot-with-rag-
- Repository: https://github.com/sandy-hax/multilingual-chatbot-with-rag-

## Overview

This is a multilingual citizen-services assistant with a web interface and a hands-free voice CLI. Citizens submit text, speech, or documents; the web API or CLI routes queries through the LLM, which can retrieve local scheme material, search the web, or guide grievance filing. Answers can be spoken aloud, while completed grievances are stored for PACS follow-up. The graph preserves the separately documented PACS dashboard and document-ingestion capabilities. Several subsystem links rely on README statements or SOURCE INDEX references because their full implementations were not shown.

Main entry points: [`llm_service.py`](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/llm_service.py) (LLM Agent), [`app.py`](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py) (Web API), [`chatbot.py`](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/chatbot.py) (Voice CLI), [`rag_service.py`](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py) (Document Ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_web_ui["Web Chat UI<br/>[app.js]"]
  node_pacs_ui["PACS Dashboard<br/>[pacs.js]"]
  node_web_api["Web API<br/>[app.py]"]
  node_voice_cli["Voice CLI<br/>[chatbot.py]"]
end

subgraph group_assistant["Assistant Runtime"]
  node_language_speech["Speech and Language<br/>[chatbot.py]"]
  node_llm_agent["LLM Agent<br/>[llm_service.py]"]
  node_web_search["Web Search<br/>[llm_service.py]"]
  node_speech_output["Edge-TTS Output<br/>[app.py]"]
end

subgraph group_knowledge["Knowledge Retrieval"]
  node_document_ingest["Document Ingestion<br/>[rag_service.py]"]
  node_ocr["OCR Extraction<br/>[ocr_service.py]"]
  node_hybrid_rag["Hybrid Retrieval<br/>[rag_service.py]"]
  node_rag_store[("Local RAG Index<br/>[rag_service.py]")]
end

subgraph group_grievances["Grievance Operations"]
  node_grievance_flow["Grievance Filing"]
  node_pacs_ops["PACS Case Management<br/>[app.py]"]
  node_grievance_db[("Grievance Database<br/>[db.py]")]
end

node_citizen(("Citizen"))
node_opencode["OpenCode Zen"]
node_serper["Serper"]
node_duckduckgo["DuckDuckGo"]
node_cpgrams["CPGRAMS Portal"]

node_citizen -->|"uses"| node_web_ui
node_citizen -->|"speaks to"| node_voice_cli
node_web_ui -->|"sends requests"| node_web_api
node_web_api -->|"invokes"| node_llm_agent
node_web_api -->|"uploads documents"| node_document_ingest
node_web_api -->|"serves PACS routes"| node_pacs_ops
node_voice_cli -->|"processes audio"| node_language_speech
node_voice_cli -->|"requests answers"| node_llm_agent
node_language_speech -->|"speaks replies"| node_speech_output
node_web_api -->|"generates audio"| node_speech_output
node_llm_agent -->|"calls model"| node_opencode
node_llm_agent -->|"searches local knowledge"| node_hybrid_rag
node_llm_agent -->|"dispatches searches"| node_web_search
node_web_search -.->|"searches web"| node_serper
node_web_search -.->|"fallback search"| node_duckduckgo
node_document_ingest -->|"extracts text"| node_ocr
node_document_ingest -->|"indexes chunks"| node_rag_store
node_hybrid_rag -->|"retrieves chunks"| node_rag_store
node_pacs_ui -->|"manages tickets"| node_pacs_ops
node_llm_agent -->|"routes complaints"| node_grievance_flow
node_grievance_flow -->|"creates tickets"| node_grievance_db
node_pacs_ops -->|"updates cases"| node_grievance_db
node_grievance_flow -->|"guides filing"| node_cpgrams

click node_web_ui "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/static/js/app.js"
click node_pacs_ui "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/static/js/pacs.js"
click node_web_api "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py"
click node_voice_cli "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/chatbot.py"
click node_language_speech "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/chatbot.py"
click node_llm_agent "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/llm_service.py"
click node_web_search "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/llm_service.py"
click node_speech_output "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py"
click node_document_ingest "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py"
click node_ocr "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/ocr_service.py"
click node_hybrid_rag "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py"
click node_rag_store "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py"
click node_grievance_flow "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/grievance_service.py"
click node_pacs_ops "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py"
click node_grievance_db "https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/db.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_web_ui,node_pacs_ui,node_web_api,node_voice_cli toneBlue
class node_language_speech,node_llm_agent,node_web_search,node_speech_output toneAmber
class node_document_ingest,node_ocr,node_hybrid_rag,node_rag_store toneMint
class node_grievance_flow,node_pacs_ops,node_grievance_db toneRose
class node_citizen,node_opencode,node_serper,node_duckduckgo,node_cpgrams toneIndigo
```

## Components

### User Interfaces

- [Web Chat UI](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/static/js/app.js): `static/js/app.js`
- [PACS Dashboard](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/static/js/pacs.js): `static/js/pacs.js`
- [Web API](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py): `app.py`
- [Voice CLI](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/chatbot.py): `chatbot.py`

### Assistant Runtime

- [Speech and Language](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/chatbot.py): `chatbot.py`
- [LLM Agent](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/llm_service.py): `llm_service.py`
- [Web Search](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/llm_service.py): `llm_service.py`
- [Edge-TTS Output](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py): `app.py`

### Knowledge Retrieval

- [Document Ingestion](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py): `rag_service.py`
- [OCR Extraction](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/ocr_service.py): `ocr_service.py`
- [Hybrid Retrieval](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py): `rag_service.py`
- [Local RAG Index](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/rag_service.py): `rag_service.py`

### Grievance Operations

- [Grievance Filing](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/grievance_service.py): `grievance_service.py`
- [PACS Case Management](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/app.py): `app.py`
- [Grievance Database](https://github.com/sandy-hax/multilingual-chatbot-with-rag-/blob/main/db.py): `db.py`

### Other components

- **Citizen**
- **OpenCode Zen**
- **Serper**
- **DuckDuckGo**
- **CPGRAMS Portal**

## Connections

- Citizen → Web Chat UI: uses (evidence: `README.md`)
- Citizen → Voice CLI: speaks to (evidence: `README.md`)
- Web Chat UI → Web API: sends requests (evidence: `README.md`)
- Web API → LLM Agent: invokes (evidence: `app.py`)
- Web API → Document Ingestion: uploads documents (evidence: `README.md`)
- Web API → PACS Case Management: serves PACS routes (evidence: `app.py`)
- Voice CLI → Speech and Language: processes audio (evidence: `README.md`)
- Voice CLI → LLM Agent: requests answers (evidence: `chatbot.py`)
- Speech and Language → Edge-TTS Output: speaks replies (evidence: `README.md`)
- Web API → Edge-TTS Output: generates audio (evidence: `app.py`)
- LLM Agent → OpenCode Zen: calls model (evidence: `README.md`)
- LLM Agent → Hybrid Retrieval: searches local knowledge (evidence: `llm_service.py`)
- LLM Agent → Web Search: dispatches searches (evidence: `README.md`)
- Web Search → Serper: searches web (evidence: `README.md`)
- Web Search → DuckDuckGo: fallback search (evidence: `README.md`)
- Document Ingestion → OCR Extraction: extracts text (evidence: `rag_service.py`)
- Document Ingestion → Local RAG Index: indexes chunks (evidence: `README.md`)
- Hybrid Retrieval → Local RAG Index: retrieves chunks (evidence: `README.md`)
- PACS Dashboard → PACS Case Management: manages tickets (evidence: `static/js/pacs.js`)
- LLM Agent → Grievance Filing: routes complaints (evidence: `README.md`)
- Grievance Filing → Grievance Database: creates tickets (evidence: `grievance_service.py`)
- PACS Case Management → Grievance Database: updates cases (evidence: `app.py`)
- Grievance Filing → CPGRAMS Portal: guides filing (evidence: `README.md`)
