# sbalakumar98/ai-expense-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/sbalakumar98/ai-expense-analyzer
- Repository: https://github.com/sbalakumar98/ai-expense-analyzer

## Overview

This is a single-file Streamlit expense-analysis app. Users upload CSV or Excel data, preview the loaded rows, then ask questions answered by a LangChain Pandas DataFrame agent using local Llama 3 through Ollama. The distinct stages are upload, file parsing, agent setup, question analysis, and result display. These components share app.py; the graph reflects calls and data flow visible there, without assuming additional subsystems.

Main entry points: [`app.py`](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py) (DataFrame agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit_app["Streamlit app<br/>[app.py]"]
  node_file_upload["File upload<br/>[app.py]"]
  node_data_preview["Data preview<br/>[app.py]"]
  node_question_input["Question input<br/>[app.py]"]
  node_result_display["Analysis result<br/>[app.py]"]
end

subgraph group_analysis["Data analysis"]
  node_data_loader["CSV / Excel loader<br/>[app.py]"]
  node_pandas["Pandas DataFrame<br/>[app.py]"]
  node_agent_setup["Agent setup<br/>[app.py]"]
  node_dataframe_agent["DataFrame agent<br/>[app.py]"]
  node_python_tool["Python analysis tool<br/>[app.py]"]
end

subgraph group_inference["Local inference"]
  node_ollama_client["ChatOllama client<br/>[app.py]"]
  node_ollama{{"Ollama / Llama 3"}}
end

node_user(("User"))

node_user -->|"uploads file"| node_file_upload
node_file_upload -->|"provides file"| node_data_loader
node_data_loader -->|"loads data"| node_pandas
node_pandas -->|"previews rows"| node_data_preview
node_pandas -->|"provides DataFrame"| node_agent_setup
node_agent_setup -->|"configures model"| node_ollama_client
node_agent_setup -->|"creates agent"| node_dataframe_agent
node_user -->|"asks question"| node_question_input
node_question_input -->|"invokes agent"| node_dataframe_agent
node_dataframe_agent -->|"requests reasoning"| node_ollama_client
node_ollama_client -->|"sends prompts"| node_ollama
node_dataframe_agent -->|"dispatches analysis"| node_python_tool
node_python_tool -->|"analyzes data"| node_pandas
node_dataframe_agent -->|"returns output"| node_result_display
node_result_display -->|"displays result"| node_user

click node_streamlit_app "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_file_upload "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_data_loader "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_pandas "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_data_preview "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_agent_setup "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_question_input "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_dataframe_agent "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_python_tool "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_ollama_client "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py"
click node_result_display "https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.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_app,node_file_upload,node_data_preview,node_question_input,node_result_display,node_user toneBlue
class node_data_loader,node_pandas,node_agent_setup,node_dataframe_agent,node_python_tool toneAmber
class node_ollama_client,node_ollama toneMint
```

## Components

### User interface

- [Streamlit app](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [File upload](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Data preview](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Question input](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Analysis result](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`

### Data analysis

- [CSV / Excel loader](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Pandas DataFrame](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Agent setup](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [DataFrame agent](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- [Python analysis tool](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`

### Local inference

- [ChatOllama client](https://github.com/sbalakumar98/ai-expense-analyzer/blob/main/app.py): `app.py`
- **Ollama / Llama 3**

### Other components

- **User**

## Connections

- User → File upload: uploads file
- File upload → CSV / Excel loader: provides file
- CSV / Excel loader → Pandas DataFrame: loads data
- Pandas DataFrame → Data preview: previews rows
- Pandas DataFrame → Agent setup: provides DataFrame
- Agent setup → ChatOllama client: configures model
- Agent setup → DataFrame agent: creates agent
- User → Question input: asks question
- Question input → DataFrame agent: invokes agent
- DataFrame agent → ChatOllama client: requests reasoning
- ChatOllama client → Ollama / Llama 3: sends prompts
- DataFrame agent → Python analysis tool: dispatches analysis
- Python analysis tool → Pandas DataFrame: analyzes data
- DataFrame agent → Analysis result: returns output
- Analysis result → User: displays result
