# imtiyaz-dev432/smart-expense-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/imtiyaz-dev432/smart-expense-tracker
- Repository: https://github.com/imtiyaz-dev432/smart-expense-tracker

## Overview

Smart Expense Tracker is a Flask-backed personal-finance app with a browser frontend. Users register and verify their account, then manage income, expenses, categories, loans and repayments, borrow/lend records, and subscriptions; dashboard reports and rule-based suggestions summarize that data. The frontend sends API requests to the Flask app, whose route handlers query or update SQLAlchemy-backed records. The sampled source confirms app registration, authentication, dashboard and AI data access, and Brevo email delivery; other domain links follow the README’s documented API capabilities.

Main entry points: [`app.py`](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/app.py) (Flask API), [`routes/dashboard.py`](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/dashboard.py) (Dashboard reports), [`routes/ai.py`](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/ai.py) (Rule-based suggestions), [`routes/auth.py`](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/auth.py) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_frontend["Finance UI<br/>[script.js]"]
end

subgraph group_identity["Identity and verification"]
  node_auth["Authentication<br/>[auth.py]"]
  node_otp["OTP verification<br/>[otp.py]"]
  node_password["Password recovery<br/>[forgot.py]"]
  node_otp_utils["OTP utilities<br/>[hashed.py]"]
  node_email["OTP email<br/>[otp.py]"]
end

subgraph group_finance["Finance records"]
  node_income["Income management<br/>[income.py]"]
  node_expenses["Expense management<br/>[expense.py]"]
  node_categories["Categories<br/>[category.py]"]
  node_category_defaults["Default categories"]
  node_loans["Loans and repayment<br/>[loan.py]"]
  node_borrow["Borrow and lend<br/>[borrow.py]"]
  node_subscriptions["Subscriptions<br/>[subscription.py]"]
end

subgraph group_insights["Financial insights"]
  node_dashboard["Dashboard reports<br/>[dashboard.py]"]
  node_suggestions["Rule-based suggestions<br/>[ai.py]"]
end

subgraph group_persistence["Persistence"]
  node_db[("SQLAlchemy database<br/>[db.py]")]
  node_user_model[("User records<br/>[user.py]")]
  node_income_model[("Income records<br/>[income.py]")]
  node_expense_model[("Expense records<br/>[expense.py]")]
  node_category_model[("Category records<br/>[category.py]")]
  node_loan_model[("Loan records<br/>[loan.py]")]
  node_borrow_model[("Borrow records<br/>[borrow.py]")]
  node_subscription_model[("Subscription records<br/>[subscribe.py]")]
end

node_user(("User"))
node_app["Flask API<br/>[app.py]"]
node_brevo["Brevo email API"]
node_postgres[("PostgreSQL")]

node_user -->|"uses"| node_frontend
node_frontend -->|"sends API requests"| node_app
node_app -->|"registers routes"| node_auth
node_app -->|"registers routes"| node_otp
node_app -->|"registers routes"| node_password
node_app -->|"registers routes"| node_income
node_app -->|"registers routes"| node_expenses
node_app -->|"registers routes"| node_categories
node_app -->|"registers routes"| node_loans
node_app -->|"registers routes"| node_borrow
node_app -->|"registers routes"| node_subscriptions
node_app -->|"registers routes"| node_dashboard
node_app -->|"registers routes"| node_suggestions
node_app -->|"initializes"| node_db
node_auth -->|"queries and writes"| node_user_model
node_auth -->|"generates and hashes"| node_otp_utils
node_auth -->|"sends verification OTP"| node_email
node_otp -->|"creates defaults"| node_category_defaults
node_otp -->|"verifies account"| node_user_model
node_password -->|"updates credentials"| node_user_model
node_email -.->|"sends email"| node_brevo
node_income -->|"manages records"| node_income_model
node_expenses -->|"manages records"| node_expense_model
node_categories -->|"manages records"| node_category_model
node_category_defaults -->|"creates records"| node_category_model
node_loans -->|"manages repayments"| node_loan_model
node_borrow -->|"manages records"| node_borrow_model
node_subscriptions -->|"manages records"| node_subscription_model
node_dashboard -->|"queries totals"| node_income_model
node_dashboard -->|"queries totals"| node_expense_model
node_dashboard -->|"queries loan status"| node_loan_model
node_dashboard -->|"queries balances"| node_borrow_model
node_dashboard -->|"queries billing"| node_subscription_model
node_suggestions -->|"queries monthly totals"| node_income_model
node_suggestions -->|"queries spending"| node_expense_model
node_suggestions -->|"checks EMI status"| node_loan_model
node_suggestions -->|"checks pending amounts"| node_borrow_model
node_db -->|"persists data"| node_postgres

click node_frontend "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/frontend/js/script.js"
click node_app "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/app.py"
click node_auth "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/auth.py"
click node_otp "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/otp.py"
click node_password "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/forgot.py"
click node_otp_utils "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/hashed.py"
click node_email "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/otp.py"
click node_income "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/income.py"
click node_expenses "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/expense.py"
click node_categories "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/category.py"
click node_category_defaults "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/category_default.py"
click node_loans "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/loan.py"
click node_borrow "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/borrow.py"
click node_subscriptions "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/subscription.py"
click node_dashboard "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/dashboard.py"
click node_suggestions "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/ai.py"
click node_db "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/dbms/db.py"
click node_user_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/user.py"
click node_income_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/income.py"
click node_expense_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/expense.py"
click node_category_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/category.py"
click node_loan_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/loan.py"
click node_borrow_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/borrow.py"
click node_subscription_model "https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/subscribe.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_frontend,node_user toneBlue
class node_auth,node_otp,node_password,node_otp_utils,node_email,node_postgres toneAmber
class node_income,node_expenses,node_categories,node_category_defaults,node_loans,node_borrow,node_subscriptions,node_app,node_brevo toneMint
class node_dashboard,node_suggestions toneRose
class node_db,node_user_model,node_income_model,node_expense_model,node_category_model,node_loan_model,node_borrow_model,node_subscription_model toneIndigo
```

## Components

### Browser client

- [Finance UI](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/frontend/js/script.js): `frontend/js/script.js`

### Identity and verification

- [Authentication](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/auth.py): `routes/auth.py`
- [OTP verification](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/otp.py): `routes/otp.py`
- [Password recovery](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/forgot.py): `routes/forgot.py`
- [OTP utilities](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/hashed.py): `utils/hashed.py`
- [OTP email](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/otp.py): `utils/otp.py`

### Finance records

- [Income management](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/income.py): `routes/income.py`
- [Expense management](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/expense.py): `routes/expense.py`
- [Categories](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/category.py): `routes/category.py`
- [Default categories](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/utils/category_default.py): `utils/category_default.py`
- [Loans and repayment](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/loan.py): `routes/loan.py`
- [Borrow and lend](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/borrow.py): `routes/borrow.py`
- [Subscriptions](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/subscription.py): `routes/subscription.py`

### Financial insights

- [Dashboard reports](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/dashboard.py): `routes/dashboard.py`
- [Rule-based suggestions](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/routes/ai.py): `routes/ai.py`

### Persistence

- [SQLAlchemy database](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/dbms/db.py): `dbms/db.py`
- [User records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/user.py): `models/user.py`
- [Income records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/income.py): `models/income.py`
- [Expense records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/expense.py): `models/expense.py`
- [Category records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/category.py): `models/category.py`
- [Loan records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/loan.py): `models/loan.py`
- [Borrow records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/borrow.py): `models/borrow.py`
- [Subscription records](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/models/subscribe.py): `models/subscribe.py`

### Other components

- **User**
- [Flask API](https://github.com/imtiyaz-dev432/smart-expense-tracker/blob/main/app.py): `app.py`
- **Brevo email API**
- **PostgreSQL**

## Connections

- User → Finance UI: uses
- Finance UI → Flask API: sends API requests
- Flask API → Authentication: registers routes
- Flask API → OTP verification: registers routes
- Flask API → Password recovery: registers routes
- Flask API → Income management: registers routes
- Flask API → Expense management: registers routes
- Flask API → Categories: registers routes
- Flask API → Loans and repayment: registers routes
- Flask API → Borrow and lend: registers routes
- Flask API → Subscriptions: registers routes
- Flask API → Dashboard reports: registers routes
- Flask API → Rule-based suggestions: registers routes
- Flask API → SQLAlchemy database: initializes
- Authentication → User records: queries and writes
- Authentication → OTP utilities: generates and hashes
- Authentication → OTP email: sends verification OTP
- OTP verification → Default categories: creates defaults
- OTP verification → User records: verifies account
- Password recovery → User records: updates credentials
- OTP email → Brevo email API: sends email
- Income management → Income records: manages records
- Expense management → Expense records: manages records
- Categories → Category records: manages records
- Default categories → Category records: creates records
- Loans and repayment → Loan records: manages repayments
- Borrow and lend → Borrow records: manages records
- Subscriptions → Subscription records: manages records
- Dashboard reports → Income records: queries totals
- Dashboard reports → Expense records: queries totals
- Dashboard reports → Loan records: queries loan status
- Dashboard reports → Borrow records: queries balances
- Dashboard reports → Subscription records: queries billing
- Rule-based suggestions → Income records: queries monthly totals
- Rule-based suggestions → Expense records: queries spending
- Rule-based suggestions → Loan records: checks EMI status
- Rule-based suggestions → Borrow records: checks pending amounts
- SQLAlchemy database → PostgreSQL: persists data
