# sanduniudissanayake/agentic-rag-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/sanduniudissanayake/agentic-rag-copilot
- Repository: https://github.com/sanduniudissanayake/agentic-rag-copilot

## Overview

Annual Report Copilot answers questions about four company reports through a Streamlit chat UI and FastAPI endpoint. The request path delegates to an agent that can search a shared index, perform company-filtered searches, and invoke safe arithmetic; it returns an answer, tool trace, provider details, and separately retrieved source passages. Ingestion builds the on-disk index, while Groq/Gemini fallback and RAGAS evaluation are documented or represented in the repository. Edges reflect shown calls or README wiring; evaluation is a separate product-support capability, not part of each query.

Main entry points: [`core.py`](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py) (Agent orchestration), [`ingest.py`](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/ingest.py) (PDF ingestion), [`app.py`](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/app.py) (Streamlit chat), [`api.py`](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/api.py) (Query API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface and API"]
  node_chat["Streamlit chat<br/>[app.py]"]
  node_service["Query API<br/>[api.py]"]
end

subgraph group_answering["Agent and retrieval"]
  node_orchestrator["Agent orchestration<br/>[core.py]"]
  node_shared_search["All-report search<br/>[core.py]"]
  node_company_search["Company-filtered search<br/>[core.py]"]
  node_sources["Source passages<br/>[core.py]"]
end

subgraph group_knowledge["Report knowledge base"]
  node_index_runtime["Index loader<br/>[core.py]"]
  node_index_store[("Persisted vector index")]
  node_ingestion["PDF ingestion<br/>[ingest.py]"]
  node_reports["Annual report PDFs"]
end

subgraph group_integrations["Models and arithmetic"]
  node_calculator["Safe calculator<br/>[tools.py]"]
  node_provider_choice["LLM selection and fallback<br/>[core.py]"]
end

subgraph group_evaluation["Answer evaluation"]
  node_eval_questions["Evaluation questions<br/>[testset.py]"]
  node_evaluation["RAGAS evaluation<br/>[evaluate.py]"]
end

node_user(("Report questioner"))
node_groq{{"Groq"}}
node_gemini{{"Gemini"}}

node_user -->|"asks"| node_chat
node_chat -->|"sends query"| node_service
node_service -->|"calls"| node_orchestrator
node_orchestrator -->|"selects provider"| node_provider_choice
node_orchestrator -->|"registers tool"| node_shared_search
node_orchestrator -->|"registers tool"| node_company_search
node_orchestrator -->|"registers tool"| node_calculator
node_orchestrator -->|"retrieves separately"| node_sources
node_shared_search -->|"queries"| node_index_runtime
node_company_search -->|"queries filtered"| node_index_runtime
node_sources -->|"retrieves passages"| node_index_runtime
node_index_runtime -->|"loads"| node_index_store
node_ingestion -->|"extracts text"| node_reports
node_ingestion -->|"builds and saves"| node_index_store
node_provider_choice -->|"connects"| node_groq
node_provider_choice -->|"fallback"| node_gemini
node_eval_questions -->|"scores"| node_evaluation
node_evaluation -->|"loads for queries"| node_index_store

click node_chat "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/app.py"
click node_service "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/api.py"
click node_orchestrator "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_shared_search "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_company_search "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_sources "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_index_runtime "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_ingestion "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/ingest.py"
click node_calculator "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/tools.py"
click node_provider_choice "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py"
click node_eval_questions "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/eval/testset.py"
click node_evaluation "https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/evaluate.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_chat,node_service toneBlue
class node_orchestrator,node_shared_search,node_company_search,node_sources toneAmber
class node_index_runtime,node_index_store,node_ingestion,node_reports toneMint
class node_calculator,node_provider_choice toneRose
class node_eval_questions,node_evaluation,node_user,node_groq,node_gemini toneIndigo
```

## Components

### User interface and API

- [Streamlit chat](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/app.py): `app.py`
- [Query API](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/api.py): `api.py`

### Agent and retrieval

- [Agent orchestration](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`
- [All-report search](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`
- [Company-filtered search](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`
- [Source passages](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`

### Report knowledge base

- [Index loader](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`
- **Persisted vector index**
- [PDF ingestion](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/ingest.py): `ingest.py`
- **Annual report PDFs**

### Models and arithmetic

- [Safe calculator](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/tools.py): `tools.py`
- [LLM selection and fallback](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/core.py): `core.py`

### Answer evaluation

- [Evaluation questions](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/eval/testset.py): `eval/testset.py`
- [RAGAS evaluation](https://github.com/sanduniudissanayake/agentic-rag-copilot/blob/main/evaluate.py): `evaluate.py`

### Other components

- **Report questioner**
- **Groq**
- **Gemini**

## Connections

- Report questioner → Streamlit chat: asks (evidence: `README.md`)
- Streamlit chat → Query API: sends query (evidence: `README.md`)
- Query API → Agent orchestration: calls (evidence: `api.py`)
- Agent orchestration → LLM selection and fallback: selects provider (evidence: `core.py`)
- Agent orchestration → All-report search: registers tool (evidence: `core.py`)
- Agent orchestration → Company-filtered search: registers tool (evidence: `core.py`)
- Agent orchestration → Safe calculator: registers tool (evidence: `core.py`)
- Agent orchestration → Source passages: retrieves separately (evidence: `core.py`)
- All-report search → Index loader: queries (evidence: `core.py`)
- Company-filtered search → Index loader: queries filtered (evidence: `core.py`)
- Source passages → Index loader: retrieves passages (evidence: `core.py`)
- Index loader → Persisted vector index: loads (evidence: `core.py`)
- PDF ingestion → Annual report PDFs: extracts text (evidence: `README.md`)
- PDF ingestion → Persisted vector index: builds and saves (evidence: `ingest.py`)
- LLM selection and fallback → Groq: connects (evidence: `core.py`)
- LLM selection and fallback → Gemini: fallback (evidence: `core.py`)
- Evaluation questions → RAGAS evaluation: scores (evidence: `evaluate.py`)
- RAGAS evaluation → Persisted vector index: loads for queries (evidence: `evaluate.py`)
