# aasim78/finagent architecture

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

- Interactive diagram: https://gitdiagram.com/aasim78/finagent
- Repository: https://github.com/aasim78/finagent

## Overview

FinAgent presents financial summaries and charts, and answers natural-language questions using an LLM that selects deterministic data and calculation tools. The query path runs from the React dashboard through FastAPI to the agent, which calls Ollama and dispatches requested tools; those tools read the CSV-backed data layer. The dashboard also loads a separate summary endpoint. README capabilities include comparisons, growth, missing-data handling, and local Qwen3/Ollama execution. backend/prompts.py guides answers; backend/main.py and backend/agent.py show the runtime wiring, while unsampled implementation links are omitted.

Main entry points: [`backend/agent.py`](https://github.com/aasim78/finagent/blob/main/backend/agent.py) (Agent orchestration), [`backend/main.py`](https://github.com/aasim78/finagent/blob/main/backend/main.py) (FastAPI endpoints), [`frontend/src/App.jsx`](https://github.com/aasim78/finagent/blob/main/frontend/src/App.jsx) (React Dashboard), [`backend/tools.py`](https://github.com/aasim78/finagent/blob/main/backend/tools.py) (Financial tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["React Dashboard<br/>[App.jsx]"]
end

subgraph group_api["API"]
  node_api["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_agent["Agent and LLM"]
  node_agent["Agent orchestration<br/>[agent.py]"]
  node_prompts["Answer guidance<br/>[prompts.py]"]
end

subgraph group_analysis["Financial Analysis"]
  node_tools["Tool dispatch<br/>[agent.py]"]
  node_financial_tools["Financial tools<br/>[tools.py]"]
end

subgraph group_data["Financial Data"]
  node_data_access["CSV data access<br/>[data.py]"]
  node_dataset[("Financial dataset<br/>[financial_data.csv]")]
end

node_user(("User"))
node_ollama{{"Ollama / Qwen3"}}

node_user -->|"asks / views"| node_dashboard
node_dashboard -->|"requests summary"| node_api
node_dashboard -->|"posts question"| node_api
node_api -->|"calls agent"| node_agent
node_api -->|"requests analysis"| node_financial_tools
node_agent -->|"uses guidance"| node_prompts
node_agent -->|"sends messages"| node_ollama
node_ollama -->|"returns tool requests"| node_agent
node_agent -->|"dispatches calls"| node_tools
node_tools -->|"invokes functions"| node_financial_tools
node_financial_tools -->|"reads records"| node_data_access
node_data_access -->|"loads CSV"| node_dataset

click node_dashboard "https://github.com/aasim78/finagent/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/aasim78/finagent/blob/main/backend/main.py"
click node_agent "https://github.com/aasim78/finagent/blob/main/backend/agent.py"
click node_prompts "https://github.com/aasim78/finagent/blob/main/backend/prompts.py"
click node_tools "https://github.com/aasim78/finagent/blob/main/backend/agent.py"
click node_financial_tools "https://github.com/aasim78/finagent/blob/main/backend/tools.py"
click node_data_access "https://github.com/aasim78/finagent/blob/main/backend/data.py"
click node_dataset "https://github.com/aasim78/finagent/blob/main/data/financial_data.csv"

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_dashboard,node_user toneBlue
class node_api toneAmber
class node_agent,node_prompts toneMint
class node_tools,node_financial_tools toneRose
class node_data_access,node_dataset,node_ollama toneIndigo
```

## Components

### Dashboard

- [React Dashboard](https://github.com/aasim78/finagent/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API

- [FastAPI endpoints](https://github.com/aasim78/finagent/blob/main/backend/main.py): `backend/main.py`

### Agent and LLM

- [Agent orchestration](https://github.com/aasim78/finagent/blob/main/backend/agent.py): `backend/agent.py`
- [Answer guidance](https://github.com/aasim78/finagent/blob/main/backend/prompts.py): `backend/prompts.py`

### Financial Analysis

- [Tool dispatch](https://github.com/aasim78/finagent/blob/main/backend/agent.py): `backend/agent.py`
- [Financial tools](https://github.com/aasim78/finagent/blob/main/backend/tools.py): `backend/tools.py`

### Financial Data

- [CSV data access](https://github.com/aasim78/finagent/blob/main/backend/data.py): `backend/data.py`
- [Financial dataset](https://github.com/aasim78/finagent/blob/main/data/financial_data.csv): `data/financial_data.csv`

### Other components

- **User**
- **Ollama / Qwen3**

## Connections

- User → React Dashboard: asks / views (evidence: `frontend/src/App.jsx`)
- React Dashboard → FastAPI endpoints: requests summary (evidence: `frontend/src/App.jsx`)
- React Dashboard → FastAPI endpoints: posts question (evidence: `frontend/src/App.jsx`)
- FastAPI endpoints → Agent orchestration: calls agent (evidence: `backend/main.py`)
- FastAPI endpoints → Financial tools: requests analysis (evidence: `backend/main.py`)
- Agent orchestration → Answer guidance: uses guidance (evidence: `backend/agent.py`)
- Agent orchestration → Ollama / Qwen3: sends messages (evidence: `backend/agent.py`)
- Ollama / Qwen3 → Agent orchestration: returns tool requests (evidence: `backend/agent.py`)
- Agent orchestration → Tool dispatch: dispatches calls (evidence: `backend/agent.py`)
- Tool dispatch → Financial tools: invokes functions (evidence: `backend/agent.py`)
- Financial tools → CSV data access: reads records (evidence: `backend/tools.py`)
- CSV data access → Financial dataset: loads CSV (evidence: `backend/data.py`)
