# risasaragula/zaravya-knowledge-assist architecture

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

- Interactive diagram: https://gitdiagram.com/risasaragula/zaravya-knowledge-assist
- Repository: https://github.com/risasaragula/zaravya-knowledge-assist

## Overview

Zaravya Knowledge Assist provides two user workflows: questions over the bundled company knowledge base, and questions about an uploaded company document. The Flask app serves the web interface and routes requests; `rag.py` handles knowledge-base chunking, embedding, retrieval and Gemini answers, while uploaded-document questions use Gemini with the uploaded file. The README also documents product Q&A, document upload, and the company policy template. Source excerpts show the main request paths; template presentation details are not sampled.

Main entry points: [`main.py`](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/main.py) (Flask routes), [`script.js`](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/script.js) (Web client), [`rag.py`](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py) (Knowledge answering), [`company_policy_template.html`](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/company_policy_template.html) (Policy template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Web client<br/>[script.js]"]
  node_page["Assistant page<br/>[index.html]"]
  node_template["Policy template"]
end

subgraph group_app["Flask application"]
  node_routes["Flask routes<br/>[main.py]"]
  node_upload_store[("Uploaded file<br/>[main.py]")]
end

subgraph group_knowledge["Knowledge assistant"]
  node_kb["Zaravya knowledge base<br/>[zaravya.txt]"]
  node_chunking["Chunk preparation<br/>[rag.py]"]
  node_embeddings["Embedding generation<br/>[rag.py]"]
  node_retrieval["Vector retrieval<br/>[rag.py]"]
  node_kb_answer["Knowledge answering<br/>[rag.py]"]
end

subgraph group_company["Company document assistant"]
  node_company_answer["Uploaded-document answering<br/>[rag.py]"]
end

subgraph group_external["External services"]
  node_gemini{{"Gemini API"}}
  node_filesystem[("Local file storage")]
end

node_user(("User"))

node_user -->|"uses"| node_browser
node_browser -->|"posts questions"| node_routes
node_routes -->|"calls"| node_kb_answer
node_routes -->|"calls"| node_company_answer
node_browser -->|"uploads file"| node_routes
node_routes -->|"saves file"| node_upload_store
node_routes -->|"writes file"| node_filesystem
node_routes -->|"serves template"| node_template
node_routes -->|"serves page"| node_page
node_kb -->|"provides text"| node_chunking
node_chunking -->|"embeds chunks"| node_embeddings
node_embeddings -->|"requests embeddings"| node_gemini
node_kb_answer -->|"requests matches"| node_retrieval
node_retrieval -->|"embeds question"| node_embeddings
node_kb_answer -->|"generates answer"| node_gemini
node_company_answer -->|"uses saved path"| node_upload_store
node_company_answer -->|"uploads file and prompts"| node_gemini
node_user -.->|"views policy template"| node_template

click node_browser "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/script.js"
click node_page "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/index.html"
click node_template "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/company_policy_template.html"
click node_routes "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/main.py"
click node_upload_store "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/main.py"
click node_kb "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/zaravya.txt"
click node_chunking "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py"
click node_embeddings "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py"
click node_retrieval "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py"
click node_kb_answer "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py"
click node_company_answer "https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.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_browser,node_page,node_template,node_user toneBlue
class node_routes,node_upload_store toneAmber
class node_kb,node_chunking,node_embeddings,node_retrieval,node_kb_answer toneMint
class node_company_answer toneRose
class node_gemini,node_filesystem toneIndigo
```

## Components

### Web interface

- [Web client](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/script.js): `script.js`
- [Assistant page](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/index.html): `index.html`
- [Policy template](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/company_policy_template.html): `company_policy_template.html`

### Flask application

- [Flask routes](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/main.py): `main.py`
- [Uploaded file](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/main.py): `main.py`

### Knowledge assistant

- [Zaravya knowledge base](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/zaravya.txt): `zaravya.txt`
- [Chunk preparation](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py): `rag.py`
- [Embedding generation](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py): `rag.py`
- [Vector retrieval](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py): `rag.py`
- [Knowledge answering](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py): `rag.py`

### Company document assistant

- [Uploaded-document answering](https://github.com/risasaragula/zaravya-knowledge-assist/blob/main/rag.py): `rag.py`

### External services

- **Gemini API**
- **Local file storage**

### Other components

- **User**

## Connections

- User → Web client: uses (evidence: `README.md`)
- Web client → Flask routes: posts questions (evidence: `script.js`)
- Flask routes → Knowledge answering: calls (evidence: `main.py`)
- Flask routes → Uploaded-document answering: calls (evidence: `main.py`)
- Web client → Flask routes: uploads file (evidence: `script.js`)
- Flask routes → Uploaded file: saves file (evidence: `main.py`)
- Flask routes → Local file storage: writes file (evidence: `main.py`)
- Flask routes → Policy template: serves template (evidence: `main.py`)
- Flask routes → Assistant page: serves page (evidence: `main.py`)
- Zaravya knowledge base → Chunk preparation: provides text (evidence: `rag.py`)
- Chunk preparation → Embedding generation: embeds chunks (evidence: `rag.py`)
- Embedding generation → Gemini API: requests embeddings (evidence: `rag.py`)
- Knowledge answering → Vector retrieval: requests matches (evidence: `rag.py`)
- Vector retrieval → Embedding generation: embeds question (evidence: `rag.py`)
- Knowledge answering → Gemini API: generates answer (evidence: `rag.py`)
- Uploaded-document answering → Uploaded file: uses saved path (evidence: `main.py`)
- Uploaded-document answering → Gemini API: uploads file and prompts (evidence: `rag.py`)
- User → Policy template: views policy template (evidence: `README.md`)
