# siddu-nandula/dia architecture

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

- Interactive diagram: https://gitdiagram.com/siddu-nandula/dia
- Repository: https://github.com/siddu-nandula/dia

## Overview

This is a document intelligence and analytics application: users upload PDF, CSV, or XLSX documents, then ask questions, request summaries or numerical analysis, and generate charts. The documented interface is Streamlit, with a FastAPI backend and an agent routing requests among document QA, analytics, and chart tools. The shown QA pipeline builds and searches a FAISS index before generating a grounded answer with Ollama. Some API and tool implementation details were not excerpted, so those links are documented or marked unverified rather than presented as inspected call paths.

Main entry points: [`app/agent_tools.py`](https://github.com/siddu-nandula/dia/blob/master/app/agent_tools.py) (Tool execution), [`app/api.py`](https://github.com/siddu-nandula/dia/blob/master/app/api.py) (REST API), [`app/llm_client.py`](https://github.com/siddu-nandula/dia/blob/master/app/llm_client.py) (Local model client), [`app/agent.py`](https://github.com/siddu-nandula/dia/blob/master/app/agent.py) (Intent router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interfaces"]
  node_streamlit["Streamlit interface<br/>[frontend.py]"]
  node_fastapi["REST API<br/>[api.py]"]
end

subgraph group_orchestration["Request orchestration"]
  node_agent["Intent router<br/>[agent.py]"]
  node_tools["Tool execution<br/>[agent_tools.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

subgraph group_documents["Document intelligence"]
  node_loader["Document ingestion<br/>[document_loader.py]"]
  node_pdfdata["PDF data extraction"]
  node_qa["Grounded QA<br/>[qa_pipeline.py]"]
  node_retriever["Passage retrieval<br/>[retrieval.py]"]
  node_llm["Local model client<br/>[llm_client.py]"]
end

subgraph group_analysis["Analytics and visualization"]
  node_analyticsqa["Numerical Q&amp;A<br/>[analytics_qa.py]"]
  node_analytics["Data analysis<br/>[data_analytics.py]"]
  node_charts["Chart generation<br/>[chart_generator.py]"]
end

node_user(("User"))
node_ollama["Ollama / Qwen"]
node_faiss[("FAISS index")]

node_user -->|"uploads and asks"| node_streamlit
node_streamlit -.->|"uses backend"| node_fastapi
node_user -->|"calls endpoints"| node_fastapi
node_fastapi -.->|"dispatches requests"| node_agent
node_agent -.->|"routes tool requests"| node_tools
node_agent -.->|"routes document questions"| node_qa
node_tools -.->|"uses loaded documents"| node_loader
node_tools -.->|"delegates numerical Q&amp;A"| node_analyticsqa
node_tools -.->|"requests charts"| node_charts
node_tools -.->|"extracts PDF tables"| node_pdfdata
node_qa -->|"builds index and searches"| node_retriever
node_retriever -.->|"indexes passages"| node_faiss
node_qa -->|"generates grounded answer"| node_llm
node_llm -->|"sends prompts"| node_ollama
node_pdfdata -.->|"structures extracted data"| node_llm
node_analyticsqa -->|"calculates statistics"| node_analytics
node_charts -.->|"uses tabular data"| node_analytics
node_fastapi -.->|"accepts documents"| node_loader
node_fastapi -.->|"reads settings"| node_settings
node_llm -->|"reads model configuration"| node_settings
node_loader -.->|"reads upload settings"| node_settings

click node_streamlit "https://github.com/siddu-nandula/dia/blob/master/frontend.py"
click node_fastapi "https://github.com/siddu-nandula/dia/blob/master/app/api.py"
click node_agent "https://github.com/siddu-nandula/dia/blob/master/app/agent.py"
click node_tools "https://github.com/siddu-nandula/dia/blob/master/app/agent_tools.py"
click node_settings "https://github.com/siddu-nandula/dia/blob/master/app/config.py"
click node_loader "https://github.com/siddu-nandula/dia/blob/master/app/document_loader.py"
click node_pdfdata "https://github.com/siddu-nandula/dia/blob/master/app/pdf_data_extractor.py"
click node_qa "https://github.com/siddu-nandula/dia/blob/master/app/qa_pipeline.py"
click node_retriever "https://github.com/siddu-nandula/dia/blob/master/app/retrieval.py"
click node_llm "https://github.com/siddu-nandula/dia/blob/master/app/llm_client.py"
click node_analyticsqa "https://github.com/siddu-nandula/dia/blob/master/app/analytics_qa.py"
click node_analytics "https://github.com/siddu-nandula/dia/blob/master/app/data_analytics.py"
click node_charts "https://github.com/siddu-nandula/dia/blob/master/app/chart_generator.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_streamlit,node_fastapi,node_user toneBlue
class node_agent,node_tools,node_settings,node_faiss toneAmber
class node_loader,node_pdfdata,node_qa,node_retriever,node_llm toneMint
class node_analyticsqa,node_analytics,node_charts toneRose
class node_ollama toneIndigo
```

## Components

### User interfaces

- [Streamlit interface](https://github.com/siddu-nandula/dia/blob/master/frontend.py): `frontend.py`
- [REST API](https://github.com/siddu-nandula/dia/blob/master/app/api.py): `app/api.py`

### Request orchestration

- [Intent router](https://github.com/siddu-nandula/dia/blob/master/app/agent.py): `app/agent.py`
- [Tool execution](https://github.com/siddu-nandula/dia/blob/master/app/agent_tools.py): `app/agent_tools.py`
- [Runtime settings](https://github.com/siddu-nandula/dia/blob/master/app/config.py): `app/config.py`

### Document intelligence

- [Document ingestion](https://github.com/siddu-nandula/dia/blob/master/app/document_loader.py): `app/document_loader.py`
- [PDF data extraction](https://github.com/siddu-nandula/dia/blob/master/app/pdf_data_extractor.py): `app/pdf_data_extractor.py`
- [Grounded QA](https://github.com/siddu-nandula/dia/blob/master/app/qa_pipeline.py): `app/qa_pipeline.py`
- [Passage retrieval](https://github.com/siddu-nandula/dia/blob/master/app/retrieval.py): `app/retrieval.py`
- [Local model client](https://github.com/siddu-nandula/dia/blob/master/app/llm_client.py): `app/llm_client.py`

### Analytics and visualization

- [Numerical Q&A](https://github.com/siddu-nandula/dia/blob/master/app/analytics_qa.py): `app/analytics_qa.py`
- [Data analysis](https://github.com/siddu-nandula/dia/blob/master/app/data_analytics.py): `app/data_analytics.py`
- [Chart generation](https://github.com/siddu-nandula/dia/blob/master/app/chart_generator.py): `app/chart_generator.py`

### Other components

- **User**
- **Ollama / Qwen**
- **FAISS index**

## Connections

- User → Streamlit interface: uploads and asks (evidence: `README.md`)
- Streamlit interface → REST API: uses backend (evidence: `README.md`)
- User → REST API: calls endpoints (evidence: `README.md`)
- REST API → Intent router: dispatches requests (evidence: `app/api.py`)
- Intent router → Tool execution: routes tool requests (evidence: `app/agent.py`)
- Intent router → Grounded QA: routes document questions (evidence: `app/agent.py`)
- Tool execution → Document ingestion: uses loaded documents (evidence: `app/agent_tools.py`)
- Tool execution → Numerical Q&A: delegates numerical Q&A (evidence: `app/agent_tools.py`)
- Tool execution → Chart generation: requests charts (evidence: `app/agent_tools.py`)
- Tool execution → PDF data extraction: extracts PDF tables (evidence: `app/agent_tools.py`)
- Grounded QA → Passage retrieval: builds index and searches (evidence: `app/qa_pipeline.py`)
- Passage retrieval → FAISS index: indexes passages
- Grounded QA → Local model client: generates grounded answer (evidence: `app/qa_pipeline.py`)
- Local model client → Ollama / Qwen: sends prompts (evidence: `README.md`)
- PDF data extraction → Local model client: structures extracted data (evidence: `app/pdf_data_extractor.py`)
- Numerical Q&A → Data analysis: calculates statistics (evidence: `app/analytics_qa.py`)
- Chart generation → Data analysis: uses tabular data (evidence: `app/chart_generator.py`)
- REST API → Document ingestion: accepts documents (evidence: `app/api.py`)
- REST API → Runtime settings: reads settings (evidence: `app/api.py`)
- Local model client → Runtime settings: reads model configuration (evidence: `app/llm_client.py`)
- Document ingestion → Runtime settings: reads upload settings (evidence: `app/document_loader.py`)
