# dtc245200007/expense-management-lite-final architecture

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

- Interactive diagram: https://gitdiagram.com/dtc245200007/expense-management-lite-final
- Repository: https://github.com/dtc245200007/expense-management-lite-final

## Overview

Sổ Chi Tiêu Lite is a personal-expense web app: users register or sign in, manage income/expense categories and transactions, then view a dashboard and monthly reports. React routes requests through its API client to FastAPI; authenticated handlers use the current account and PostgreSQL-backed data. The README also describes deployment and monitoring services, but their implementation files are not in the supplied tree, so they are not mapped here. Backend connections beyond the shown excerpts follow the router registration and source-index references; frontend-to-API links are documented only at a high level.

Main entry points: [`app/database.py`](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/database.py) (Database session), [`app/main.py`](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/main.py) (FastAPI app), [`app/routers/auth.py`](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/auth.py) (Authentication), [`app/routers/categories.py`](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/categories.py) (Category management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["React app<br/>[App.tsx]"]
  node_authstate["Session state<br/>[AuthContext.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
end

subgraph group_api["API services"]
  node_api["FastAPI app<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_identity["Current account<br/>[deps.py]"]
  node_categories["Category management<br/>[categories.py]"]
  node_transactions["Transactions<br/>[transactions.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_reports["Monthly reports<br/>[reports.py]"]
end

subgraph group_domain["Expense domain"]
  node_users["User records<br/>[user.py]"]
  node_categorymodel["Category records<br/>[category.py]"]
  node_transactionmodel["Transaction records<br/>[transaction.py]"]
end

subgraph group_storage["Persistence"]
  node_db["Database session<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

node_person(("Account holder"))

node_person -->|"uses"| node_app
node_app -->|"provides session"| node_authstate
node_authstate -->|"requests identity"| node_apiclient
node_app -.->|"routes requests"| node_apiclient
node_apiclient -.->|"calls API"| node_api
node_api -->|"registers routes"| node_auth
node_api -->|"registers routes"| node_categories
node_api -->|"registers routes"| node_transactions
node_api -->|"registers routes"| node_dashboard
node_api -->|"registers routes"| node_reports
node_auth -->|"opens session"| node_db
node_auth -->|"queries and updates"| node_users
node_auth -->|"checks session"| node_identity
node_identity -->|"opens session"| node_db
node_identity -->|"loads account"| node_users
node_categories -->|"reads and writes"| node_categorymodel
node_categories -->|"checks usage"| node_transactionmodel
node_categories -->|"opens session"| node_db
node_transactions -->|"reads and writes"| node_transactionmodel
node_transactions -->|"checks category"| node_categorymodel
node_transactions -->|"opens session"| node_db
node_dashboard -->|"queries data"| node_db
node_reports -->|"queries data"| node_db
node_reports -->|"aggregates categories"| node_categorymodel
node_reports -->|"aggregates transactions"| node_transactionmodel
node_db -.->|"connects"| node_postgres

click node_app "https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/App.tsx"
click node_authstate "https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/auth/AuthContext.tsx"
click node_apiclient "https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/lib/api.ts"
click node_api "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/main.py"
click node_auth "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/auth.py"
click node_identity "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/core/deps.py"
click node_categories "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/categories.py"
click node_transactions "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/transactions.py"
click node_dashboard "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/dashboard.py"
click node_reports "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/reports.py"
click node_users "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/user.py"
click node_categorymodel "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/category.py"
click node_transactionmodel "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/transaction.py"
click node_db "https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/database.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_app,node_authstate,node_apiclient toneBlue
class node_api,node_auth,node_identity,node_categories,node_transactions,node_dashboard,node_reports toneAmber
class node_users,node_categorymodel,node_transactionmodel toneMint
class node_db,node_postgres toneRose
class node_person toneIndigo
```

## Components

### Web interface

- [React app](https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session state](https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/auth/AuthContext.tsx): `frontend/src/auth/AuthContext.tsx`
- [API client](https://github.com/dtc245200007/expense-management-lite-final/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API services

- [FastAPI app](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/main.py): `app/main.py`
- [Authentication](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Current account](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/core/deps.py): `app/core/deps.py`
- [Category management](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/categories.py): `app/routers/categories.py`
- [Transactions](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/transactions.py): `app/routers/transactions.py`
- [Dashboard](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/dashboard.py): `app/routers/dashboard.py`
- [Monthly reports](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/routers/reports.py): `app/routers/reports.py`

### Expense domain

- [User records](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/user.py): `app/models/user.py`
- [Category records](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/category.py): `app/models/category.py`
- [Transaction records](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/models/transaction.py): `app/models/transaction.py`

### Persistence

- [Database session](https://github.com/dtc245200007/expense-management-lite-final/blob/main/app/database.py): `app/database.py`
- **PostgreSQL**

### Other components

- **Account holder**

## Connections

- Account holder → React app: uses (evidence: `frontend/src/App.tsx`)
- React app → Session state: provides session (evidence: `frontend/src/App.tsx`)
- Session state → API client: requests identity (evidence: `frontend/src/auth/AuthContext.tsx`)
- React app → API client: routes requests
- API client → FastAPI app: calls API
- FastAPI app → Authentication: registers routes (evidence: `app/main.py`)
- FastAPI app → Category management: registers routes (evidence: `app/main.py`)
- FastAPI app → Transactions: registers routes (evidence: `app/main.py`)
- FastAPI app → Dashboard: registers routes (evidence: `app/main.py`)
- FastAPI app → Monthly reports: registers routes (evidence: `app/main.py`)
- Authentication → Database session: opens session (evidence: `app/routers/auth.py`)
- Authentication → User records: queries and updates (evidence: `app/routers/auth.py`)
- Authentication → Current account: checks session (evidence: `app/routers/auth.py`)
- Current account → Database session: opens session (evidence: `app/core/deps.py`)
- Current account → User records: loads account (evidence: `app/core/deps.py`)
- Category management → Category records: reads and writes (evidence: `app/routers/categories.py`)
- Category management → Transaction records: checks usage (evidence: `app/routers/categories.py`)
- Category management → Database session: opens session (evidence: `app/routers/categories.py`)
- Transactions → Transaction records: reads and writes (evidence: `app/routers/transactions.py`)
- Transactions → Category records: checks category (evidence: `app/routers/transactions.py`)
- Transactions → Database session: opens session (evidence: `app/routers/transactions.py`)
- Dashboard → Database session: queries data (evidence: `app/routers/dashboard.py`)
- Monthly reports → Database session: queries data (evidence: `app/routers/reports.py`)
- Monthly reports → Category records: aggregates categories (evidence: `app/routers/reports.py`)
- Monthly reports → Transaction records: aggregates transactions (evidence: `app/routers/reports.py`)
- Database session → PostgreSQL: connects
