# abhishek-tm-123/smart-exp-v2-backend architecture

> Architecture diagram of the GitHub repository abhishek-tm-123/smart-exp-v2-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhishek-tm-123/smart-exp-v2-backend
- Repository: https://github.com/abhishek-tm-123/smart-exp-v2-backend

## Overview

This is a personal-finance application exposing authentication, transaction tracking, spending summaries, budgets, and AI chat through a FastAPI service, with a CLI also present. The main user workflow is to authenticate, manage transactions, and request summaries or budget status; chat is a separate capability. The source index supports the route, service, model, and configuration relationships shown. The README is empty, and the CLI’s connections are unclear from the indexed references, so it is included without inferred links.

Main entry points: [`app/services/finance.py`](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/finance.py) (Finance service), [`app/main.py`](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/main.py) (FastAPI app), [`app/api/routes/auth.py`](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/auth.py) (Auth routes), [`app/api/routes/expenses.py`](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/expenses.py) (Expense routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Interfaces"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_expense_routes["Expense routes<br/>[expenses.py]"]
  node_budget_routes["Budget routes<br/>[budgets.py]"]
  node_chat_routes["Chat route<br/>[chat.py]"]
  node_cli["CLI interface<br/>[cli.py]"]
  node_auth_schema["Auth schemas<br/>[auth.py]"]
  node_transaction_schema["Transaction schemas<br/>[transactions.py]"]
  node_budget_schema["Budget schemas<br/>[budgets.py]"]
  node_summary_schema["Summary schemas<br/>[summary.py]"]
end

subgraph group_domain["Finance Services"]
  node_transaction_service["Transaction service<br/>[transactions.py]"]
  node_finance_service["Finance service<br/>[finance.py]"]
  node_ai_service["AI service<br/>[ai.py]"]
end

subgraph group_identity["Identity and Configuration"]
  node_auth_service["Auth service<br/>[auth.py]"]
  node_auth_security["Token security<br/>[security.py]"]
  node_auth_deps["Auth dependencies<br/>[deps.py]"]
  node_config["App settings<br/>[config.py]"]
end

subgraph group_persistence["Data Model"]
  node_session["DB sessions<br/>[session.py]"]
  node_user_model[("User records<br/>[user.py]")]
  node_transaction_model[("Transactions<br/>[transaction.py]")]
  node_budget_model[("Budgets<br/>[budget.py]")]
end

node_user(("Finance user"))
node_database[("SQL database")]

node_user -->|"uses"| node_fastapi
node_fastapi -->|"registers"| node_auth_routes
node_fastapi -->|"registers"| node_expense_routes
node_fastapi -->|"registers"| node_budget_routes
node_fastapi -->|"registers"| node_chat_routes
node_auth_routes -->|"validates and returns"| node_auth_schema
node_auth_routes -->|"authenticates"| node_auth_service
node_auth_routes -->|"issues token"| node_auth_security
node_auth_routes -->|"requires user"| node_auth_deps
node_auth_service -->|"hashes and verifies"| node_auth_security
node_auth_service -->|"queries and creates"| node_user_model
node_auth_deps -->|"decodes token"| node_auth_security
node_auth_deps -->|"loads user"| node_user_model
node_auth_security -->|"reads settings"| node_config
node_expense_routes -->|"accepts and returns"| node_transaction_schema
node_expense_routes -->|"manages transactions"| node_transaction_service
node_expense_routes -->|"requests summaries"| node_finance_service
node_expense_routes -->|"returns summary"| node_summary_schema
node_transaction_service -->|"queries and updates"| node_transaction_model
node_budget_routes -->|"accepts and returns"| node_budget_schema
node_budget_routes -->|"manages budget status"| node_finance_service
node_finance_service -->|"creates and evaluates"| node_budget_model
node_finance_service -->|"aggregates spending"| node_transaction_model
node_finance_service -->|"uses budget input"| node_budget_schema
node_finance_service -->|"builds summaries"| node_summary_schema
node_chat_routes -->|"handles chat"| node_ai_service
node_session -->|"reads database URL"| node_config
node_session -->|"opens sessions"| node_database

click node_fastapi "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/main.py"
click node_auth_routes "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/auth.py"
click node_expense_routes "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/expenses.py"
click node_budget_routes "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/budgets.py"
click node_chat_routes "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/chat.py"
click node_cli "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/cli.py"
click node_transaction_service "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/transactions.py"
click node_finance_service "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/finance.py"
click node_ai_service "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/ai.py"
click node_auth_service "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/auth.py"
click node_auth_security "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/core/security.py"
click node_auth_deps "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/deps.py"
click node_config "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/core/config.py"
click node_session "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/db/session.py"
click node_user_model "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/user.py"
click node_transaction_model "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/transaction.py"
click node_budget_model "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/budget.py"
click node_auth_schema "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/auth.py"
click node_transaction_schema "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/transactions.py"
click node_budget_schema "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/budgets.py"
click node_summary_schema "https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/summary.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_fastapi,node_auth_routes,node_expense_routes,node_budget_routes,node_chat_routes,node_cli,node_auth_schema,node_transaction_schema,node_budget_schema,node_summary_schema,node_user toneBlue
class node_transaction_service,node_finance_service,node_ai_service,node_database toneAmber
class node_auth_service,node_auth_security,node_auth_deps,node_config toneMint
class node_session,node_user_model,node_transaction_model,node_budget_model toneRose
```

## Components

### API and Interfaces

- [FastAPI app](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/main.py): `app/main.py`
- [Auth routes](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/auth.py): `app/api/routes/auth.py`
- [Expense routes](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/expenses.py): `app/api/routes/expenses.py`
- [Budget routes](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/budgets.py): `app/api/routes/budgets.py`
- [Chat route](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/routes/chat.py): `app/api/routes/chat.py`
- [CLI interface](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/cli.py): `app/cli.py`
- [Auth schemas](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/auth.py): `app/schemas/auth.py`
- [Transaction schemas](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/transactions.py): `app/schemas/transactions.py`
- [Budget schemas](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/budgets.py): `app/schemas/budgets.py`
- [Summary schemas](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/schemas/summary.py): `app/schemas/summary.py`

### Finance Services

- [Transaction service](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/transactions.py): `app/services/transactions.py`
- [Finance service](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/finance.py): `app/services/finance.py`
- [AI service](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/ai.py): `app/services/ai.py`

### Identity and Configuration

- [Auth service](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/services/auth.py): `app/services/auth.py`
- [Token security](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/core/security.py): `app/core/security.py`
- [Auth dependencies](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/api/deps.py): `app/api/deps.py`
- [App settings](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/core/config.py): `app/core/config.py`

### Data Model

- [DB sessions](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/db/session.py): `app/db/session.py`
- [User records](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/user.py): `app/models/user.py`
- [Transactions](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/transaction.py): `app/models/transaction.py`
- [Budgets](https://github.com/abhishek-tm-123/smart-exp-v2-backend/blob/main/app/models/budget.py): `app/models/budget.py`

### Other components

- **Finance user**
- **SQL database**

## Connections

- Finance user → FastAPI app: uses
- FastAPI app → Auth routes: registers (evidence: `app/main.py`)
- FastAPI app → Expense routes: registers (evidence: `app/main.py`)
- FastAPI app → Budget routes: registers (evidence: `app/main.py`)
- FastAPI app → Chat route: registers (evidence: `app/main.py`)
- Auth routes → Auth schemas: validates and returns (evidence: `app/api/routes/auth.py`)
- Auth routes → Auth service: authenticates (evidence: `app/api/routes/auth.py`)
- Auth routes → Token security: issues token (evidence: `app/api/routes/auth.py`)
- Auth routes → Auth dependencies: requires user (evidence: `app/api/routes/auth.py`)
- Auth service → Token security: hashes and verifies (evidence: `app/services/auth.py`)
- Auth service → User records: queries and creates (evidence: `app/services/auth.py`)
- Auth dependencies → Token security: decodes token (evidence: `app/api/deps.py`)
- Auth dependencies → User records: loads user (evidence: `app/api/deps.py`)
- Token security → App settings: reads settings (evidence: `app/core/security.py`)
- Expense routes → Transaction schemas: accepts and returns (evidence: `app/api/routes/expenses.py`)
- Expense routes → Transaction service: manages transactions (evidence: `app/api/routes/expenses.py`)
- Expense routes → Finance service: requests summaries (evidence: `app/api/routes/expenses.py`)
- Expense routes → Summary schemas: returns summary (evidence: `app/api/routes/expenses.py`)
- Transaction service → Transactions: queries and updates (evidence: `app/services/transactions.py`)
- Budget routes → Budget schemas: accepts and returns (evidence: `app/api/routes/budgets.py`)
- Budget routes → Finance service: manages budget status (evidence: `app/api/routes/budgets.py`)
- Finance service → Budgets: creates and evaluates (evidence: `app/services/finance.py`)
- Finance service → Transactions: aggregates spending (evidence: `app/services/finance.py`)
- Finance service → Budget schemas: uses budget input (evidence: `app/services/finance.py`)
- Finance service → Summary schemas: builds summaries (evidence: `app/services/finance.py`)
- Chat route → AI service: handles chat (evidence: `app/api/routes/chat.py`)
- DB sessions → App settings: reads database URL (evidence: `app/db/session.py`)
- DB sessions → SQL database: opens sessions (evidence: `app/db/session.py`)
