# ravindran-dev/smartspend architecture

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

- Interactive diagram: https://gitdiagram.com/ravindran-dev/smartspend
- Repository: https://github.com/ravindran-dev/smartspend

## Overview

Smart Expense Tracker is a receipt-to-expense application: users upload a bill, review extracted details, and save the expense; dashboards, budgets, and reports use expense and analytics data. The README documents OCR, extraction, categorization, and reporting capabilities; sampled code confirms key frontend fetches, backend model loading, and an in-memory expense list. Several backend stages share app.py, and unsampled components’ API wiring is not inferred.

Main entry points: [`backend/app.py`](https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py) (Flask API), [`frontend/src/components/Dashboard.jsx`](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Dashboard.jsx) (Dashboard layout), [`frontend/src/App.jsx`](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/App.jsx) (Page navigation), [`frontend/src/components/UploadCard.jsx`](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/UploadCard.jsx) (Receipt upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Expense interface"]
  node_app["Page navigation<br/>[App.jsx]"]
  node_dashboard["Dashboard layout<br/>[Dashboard.jsx]"]
  node_upload["Receipt upload<br/>[UploadCard.jsx]"]
  node_expense_table["Expense table<br/>[ExpenseTable.jsx]"]
  node_charts["Spending charts<br/>[PieChartCard.jsx]"]
  node_line_chart["Spending trends<br/>[LineChartCard.jsx]"]
  node_date_utils["Date formatting<br/>[dateUtils.js]"]
end

subgraph group_processing["Receipt processing"]
  node_ocr["Image OCR<br/>[app.py]"]
  node_extraction["Bill data extraction<br/>[app.py]"]
  node_classifier["Expense classifier<br/>[models.py]"]
  node_model_assets["Trained model assets"]
  node_training["Model training"]
end

subgraph group_domain["Expense services"]
  node_api["Flask API<br/>[app.py]"]
  node_expense_store[("Expense records<br/>[app.py]")]
end

subgraph group_insights["Budgets and reports"]
  node_budget["Budget tracking"]
  node_reports["Expense reports<br/>[Reports.jsx]"]
  node_settings["Settings<br/>[Settings.jsx]"]
end

node_user(("User"))
node_tesseract["Tesseract OCR"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_upload
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_settings
node_dashboard -->|"renders"| node_upload
node_dashboard -->|"renders"| node_expense_table
node_dashboard -->|"renders"| node_charts
node_dashboard -->|"renders"| node_line_chart
node_dashboard -->|"renders"| node_budget
node_upload -->|"submits bill"| node_api
node_api -->|"processes image"| node_ocr
node_ocr -->|"extracts text"| node_tesseract
node_ocr -->|"provides text"| node_extraction
node_extraction -->|"categorizes expense"| node_classifier
node_api -->|"loads classifier"| node_classifier
node_classifier -->|"uses model files"| node_model_assets
node_training -.->|"trains model"| node_model_assets
node_api -->|"adds expense"| node_expense_store
node_expense_table -->|"fetches expenses"| node_api
node_charts -->|"fetches analytics"| node_api
node_budget -->|"fetches expenses"| node_api
node_reports -->|"fetches expenses"| node_api
node_expense_table -->|"formats dates"| node_date_utils
node_upload -->|"formats dates"| node_date_utils
node_reports -.->|"exports records"| node_expense_store

click node_app "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Dashboard.jsx"
click node_upload "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/UploadCard.jsx"
click node_expense_table "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/ExpenseTable.jsx"
click node_charts "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/PieChartCard.jsx"
click node_line_chart "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/LineChartCard.jsx"
click node_date_utils "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/utils/dateUtils.js"
click node_ocr "https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py"
click node_extraction "https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py"
click node_classifier "https://github.com/ravindran-dev/smartspend/blob/main/backend/models.py"
click node_model_assets "https://github.com/ravindran-dev/smartspend/tree/main/Expense_model/models"
click node_training "https://github.com/ravindran-dev/smartspend/blob/main/Expense_model/scripts/train_production_model.py"
click node_api "https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py"
click node_expense_store "https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py"
click node_budget "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/BudgetProgressCard.jsx"
click node_reports "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Reports.jsx"
click node_settings "https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Settings.jsx"

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_app,node_dashboard,node_upload,node_expense_table,node_charts,node_line_chart,node_date_utils,node_user toneBlue
class node_ocr,node_extraction,node_classifier,node_model_assets,node_training toneAmber
class node_api,node_expense_store toneMint
class node_budget,node_reports,node_settings toneRose
class node_tesseract toneIndigo
```

## Components

### Expense interface

- [Page navigation](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Dashboard layout](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Dashboard.jsx): `frontend/src/components/Dashboard.jsx`
- [Receipt upload](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/UploadCard.jsx): `frontend/src/components/UploadCard.jsx`
- [Expense table](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/ExpenseTable.jsx): `frontend/src/components/ExpenseTable.jsx`
- [Spending charts](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/PieChartCard.jsx): `frontend/src/components/PieChartCard.jsx`
- [Spending trends](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/LineChartCard.jsx): `frontend/src/components/LineChartCard.jsx`
- [Date formatting](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/utils/dateUtils.js): `frontend/src/utils/dateUtils.js`

### Receipt processing

- [Image OCR](https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py): `backend/app.py`
- [Bill data extraction](https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py): `backend/app.py`
- [Expense classifier](https://github.com/ravindran-dev/smartspend/blob/main/backend/models.py): `backend/models.py`
- [Trained model assets](https://github.com/ravindran-dev/smartspend/tree/main/Expense_model/models): `Expense_model/models`
- [Model training](https://github.com/ravindran-dev/smartspend/blob/main/Expense_model/scripts/train_production_model.py): `Expense_model/scripts/train_production_model.py`

### Expense services

- [Flask API](https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py): `backend/app.py`
- [Expense records](https://github.com/ravindran-dev/smartspend/blob/main/backend/app.py): `backend/app.py`

### Budgets and reports

- [Budget tracking](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/BudgetProgressCard.jsx): `frontend/src/components/BudgetProgressCard.jsx`
- [Expense reports](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Reports.jsx): `frontend/src/components/Reports.jsx`
- [Settings](https://github.com/ravindran-dev/smartspend/blob/main/frontend/src/components/Settings.jsx): `frontend/src/components/Settings.jsx`

### Other components

- **User**
- **Tesseract OCR**

## Connections

- User → Page navigation: uses (evidence: `README.md`)
- Page navigation → Dashboard layout: routes to (evidence: `frontend/src/App.jsx`)
- Page navigation → Receipt upload: routes to (evidence: `frontend/src/App.jsx`)
- Page navigation → Expense reports: routes to (evidence: `frontend/src/App.jsx`)
- Page navigation → Settings: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard layout → Receipt upload: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard layout → Expense table: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard layout → Spending charts: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard layout → Spending trends: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard layout → Budget tracking: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Receipt upload → Flask API: submits bill (evidence: `README.md`)
- Flask API → Image OCR: processes image (evidence: `README.md`)
- Image OCR → Tesseract OCR: extracts text (evidence: `README.md`)
- Image OCR → Bill data extraction: provides text (evidence: `README.md`)
- Bill data extraction → Expense classifier: categorizes expense (evidence: `README.md`)
- Flask API → Expense classifier: loads classifier (evidence: `backend/app.py`)
- Expense classifier → Trained model assets: uses model files
- Model training → Trained model assets: trains model
- Flask API → Expense records: adds expense (evidence: `backend/app.py`)
- Expense table → Flask API: fetches expenses (evidence: `frontend/src/components/ExpenseTable.jsx`)
- Spending charts → Flask API: fetches analytics (evidence: `frontend/src/components/PieChartCard.jsx`)
- Budget tracking → Flask API: fetches expenses (evidence: `frontend/src/components/BudgetProgressCard.jsx`)
- Expense reports → Flask API: fetches expenses (evidence: `frontend/src/components/Reports.jsx`)
- Expense table → Date formatting: formats dates (evidence: `frontend/src/components/ExpenseTable.jsx`)
- Receipt upload → Date formatting: formats dates (evidence: `frontend/src/components/UploadCard.jsx`)
- Expense reports → Expense records: exports records
