# shivanetha1/ai-doc-analyser architecture

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

- Interactive diagram: https://gitdiagram.com/shivanetha1/ai-doc-analyser
- Repository: https://github.com/shivanetha1/ai-doc-analyser

## Overview

AI Doc Analyzer is a Streamlit application for indexing PDF/text collections and answering conversational questions using semantic search. Its documented workflow moves from document upload through loading, embedding, and vector storage, then from user questions through routing, retrieval or calculation, and answer validation. The repository also includes query-history condensation and source-grounded prompts. The app source was not sampled, so UI orchestration links are based on README descriptions; links from the app to particular runtime modules are shown as unverified rather than asserted as inspected calls.

Main entry points: [`app.py`](https://github.com/shivanetha1/ai-doc-analyser/blob/main/app.py) (Streamlit app), [`core/prompts.py`](https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/prompts.py) (Prompt templates), [`agents/router_agent.py`](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/router_agent.py) (Query router), [`agents/retrieval_agent.py`](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/retrieval_agent.py) (Retrieval agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Document ingestion"]
  node_pdf["PDF loader<br/>[pdf_loader.py]"]
  node_text["Text loader<br/>[text_loader.py]"]
  node_chunk["Text chunking<br/>[helpers.py]"]
end

subgraph group_knowledge["Search and context"]
  node_embed["Embeddings<br/>[embeddings.py]"]
  node_store[("Vector store<br/>[vectorstore.py]")]
end

subgraph group_agents["Question agents"]
  node_router["Query router<br/>[router_agent.py]"]
  node_retrieval["Retrieval agent<br/>[retrieval_agent.py]"]
  node_calculator["Calculator agent"]
  node_validator["Structured validator<br/>[validator_agent.py]"]
  node_validator0["Prompt validator"]
end

subgraph group_shared["Shared reasoning"]
  node_memory["Query memory<br/>[memory.py]"]
  node_prompts["Prompt templates<br/>[prompts.py]"]
end

node_user(("User"))
node_app["Streamlit app<br/>[app.py]"]
node_groq{{"Groq API"}}

node_user -->|"uses"| node_app
node_app -.->|"ingests PDFs"| node_pdf
node_app -.->|"ingests text"| node_text
node_app -.->|"creates embeddings"| node_embed
node_app -.->|"stores vectors"| node_store
node_app -.->|"condenses queries"| node_memory
node_app -.->|"routes questions"| node_router
node_app -.->|"requests answers"| node_retrieval
node_app -.->|"handles calculations"| node_calculator
node_app -.->|"checks answers"| node_validator
node_app -.->|"checks answers"| node_validator0
node_router -->|"uses prompt"| node_prompts
node_retrieval -->|"uses prompt"| node_prompts
node_memory -->|"uses prompt"| node_prompts
node_validator0 -->|"uses prompt"| node_prompts
node_router -->|"calls chat"| node_groq
node_retrieval -->|"calls chat"| node_groq
node_memory -->|"calls chat"| node_groq
node_validator -->|"calls chat"| node_groq
node_validator0 -->|"calls chat"| node_groq

click node_app "https://github.com/shivanetha1/ai-doc-analyser/blob/main/app.py"
click node_pdf "https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/pdf_loader.py"
click node_text "https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/text_loader.py"
click node_chunk "https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/helpers.py"
click node_embed "https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/embeddings.py"
click node_store "https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/vectorstore.py"
click node_memory "https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/memory.py"
click node_prompts "https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/prompts.py"
click node_router "https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/router_agent.py"
click node_retrieval "https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/retrieval_agent.py"
click node_calculator "https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/calculator_agent.py"
click node_validator "https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/validator_agent.py"
click node_validator0 "https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/validator_agent0.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_pdf,node_text,node_chunk,node_user toneBlue
class node_embed,node_store toneAmber
class node_router,node_retrieval,node_calculator,node_validator,node_validator0,node_groq toneMint
class node_memory,node_prompts toneRose
class node_app toneTeal
```

## Components

### Document ingestion

- [PDF loader](https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/pdf_loader.py): `utils/pdf_loader.py`
- [Text loader](https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/text_loader.py): `utils/text_loader.py`
- [Text chunking](https://github.com/shivanetha1/ai-doc-analyser/blob/main/utils/helpers.py): `utils/helpers.py`

### Search and context

- [Embeddings](https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/embeddings.py): `core/embeddings.py`
- [Vector store](https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/vectorstore.py): `core/vectorstore.py`

### Question agents

- [Query router](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/router_agent.py): `agents/router_agent.py`
- [Retrieval agent](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/retrieval_agent.py): `agents/retrieval_agent.py`
- [Calculator agent](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/calculator_agent.py): `agents/calculator_agent.py`
- [Structured validator](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/validator_agent.py): `agents/validator_agent.py`
- [Prompt validator](https://github.com/shivanetha1/ai-doc-analyser/blob/main/agents/validator_agent0.py): `agents/validator_agent0.py`

### Shared reasoning

- [Query memory](https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/memory.py): `core/memory.py`
- [Prompt templates](https://github.com/shivanetha1/ai-doc-analyser/blob/main/core/prompts.py): `core/prompts.py`

### Other components

- **User**
- [Streamlit app](https://github.com/shivanetha1/ai-doc-analyser/blob/main/app.py): `app.py`
- **Groq API**

## Connections

- User → Streamlit app: uses (evidence: `README.md`)
- Streamlit app → PDF loader: ingests PDFs
- Streamlit app → Text loader: ingests text
- Streamlit app → Embeddings: creates embeddings
- Streamlit app → Vector store: stores vectors
- Streamlit app → Query memory: condenses queries
- Streamlit app → Query router: routes questions
- Streamlit app → Retrieval agent: requests answers
- Streamlit app → Calculator agent: handles calculations
- Streamlit app → Structured validator: checks answers
- Streamlit app → Prompt validator: checks answers
- Query router → Prompt templates: uses prompt (evidence: `agents/router_agent.py`)
- Retrieval agent → Prompt templates: uses prompt (evidence: `agents/retrieval_agent.py`)
- Query memory → Prompt templates: uses prompt (evidence: `core/memory.py`)
- Prompt validator → Prompt templates: uses prompt (evidence: `agents/validator_agent0.py`)
- Query router → Groq API: calls chat (evidence: `agents/router_agent.py`)
- Retrieval agent → Groq API: calls chat (evidence: `agents/retrieval_agent.py`)
- Query memory → Groq API: calls chat (evidence: `core/memory.py`)
- Structured validator → Groq API: calls chat (evidence: `agents/validator_agent.py`)
- Prompt validator → Groq API: calls chat (evidence: `agents/validator_agent0.py`)
