# himanshubhamaniya/expense-tracker-api architecture

> Architecture diagram of the GitHub repository himanshubhamaniya/expense-tracker-api, 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/himanshubhamaniya/expense-tracker-api
- Repository: https://github.com/himanshubhamaniya/expense-tracker-api

## Overview

This is a FastAPI expense-tracking API. Clients register or log in to receive a JWT, then use bearer-authenticated endpoints to create, list/filter, retrieve, update, and delete expenses scoped to their account. Requests pass through the v1 router to endpoint handlers, which use shared database and authentication dependencies. The README documents these capabilities; the sampled source does not include the individual-expense GET handler, so that documented operation is not wired below.

Main entry points: [`app/api/v1/endpoints/auth.py`](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/auth.py) (Authentication), [`app/core/database.py`](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/database.py) (DB engine), [`app/api/v1/endpoints/expenses.py`](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/expenses.py) (Expense operations), [`app/api/deps.py`](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/deps.py) (Request dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_app["FastAPI app<br/>[main.py]"]
  node_router["V1 router<br/>[router.py]"]
end

subgraph group_flows["Request workflows"]
  node_auth["Authentication<br/>[auth.py]"]
  node_expenses["Expense operations<br/>[expenses.py]"]
end

subgraph group_foundation["Shared foundation"]
  node_deps["Request dependencies<br/>[deps.py]"]
  node_security["JWT and passwords<br/>[security.py]"]
  node_config["Settings<br/>[config.py]"]
  node_database["DB engine<br/>[database.py]"]
  node_user_model["User model<br/>[user.py]"]
  node_expense_model["Expense model<br/>[expense.py]"]
  node_auth_schemas["Auth schemas<br/>[user.py]"]
  node_token_schema["Token schema<br/>[token.py]"]
  node_expense_schema["Expense schemas<br/>[expense.py]"]
end

node_client(("API client"))
node_store[("SQL database")]

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_router
node_app -->|"creates tables"| node_database
node_router -->|"dispatches auth"| node_auth
node_router -->|"dispatches expenses"| node_expenses
node_auth -->|"uses session"| node_deps
node_expenses -->|"uses session and user"| node_deps
node_auth -->|"hashes and signs"| node_security
node_deps -->|"verifies JWT"| node_security
node_deps -->|"opens session"| node_database
node_database -->|"reads URL"| node_config
node_database -->|"connects"| node_store
node_auth -->|"queries and writes"| node_user_model
node_deps -->|"loads user"| node_user_model
node_expenses -->|"uses owner"| node_user_model
node_expenses -->|"queries and mutates"| node_expense_model
node_user_model -->|"uses ORM base"| node_database
node_expense_model -->|"uses ORM base"| node_database
node_auth -->|"validates and responds"| node_auth_schemas
node_auth -->|"returns token"| node_token_schema
node_expenses -->|"validates and responds"| node_expense_schema
node_expense_schema -->|"uses category enum"| node_expense_model

click node_app "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/main.py"
click node_router "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/router.py"
click node_auth "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/auth.py"
click node_expenses "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/expenses.py"
click node_deps "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/deps.py"
click node_security "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/security.py"
click node_config "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/config.py"
click node_database "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/database.py"
click node_user_model "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/models/user.py"
click node_expense_model "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/models/expense.py"
click node_auth_schemas "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/user.py"
click node_token_schema "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/token.py"
click node_expense_schema "https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/expense.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_router,node_client toneBlue
class node_auth,node_expenses,node_store toneAmber
class node_deps,node_security,node_config,node_database,node_user_model,node_expense_model,node_auth_schemas,node_token_schema,node_expense_schema toneMint
```

## Components

### API entry

- [FastAPI app](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/main.py): `app/main.py`
- [V1 router](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/router.py): `app/api/v1/router.py`

### Request workflows

- [Authentication](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/auth.py): `app/api/v1/endpoints/auth.py`
- [Expense operations](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/v1/endpoints/expenses.py): `app/api/v1/endpoints/expenses.py`

### Shared foundation

- [Request dependencies](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/api/deps.py): `app/api/deps.py`
- [JWT and passwords](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/security.py): `app/core/security.py`
- [Settings](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/config.py): `app/core/config.py`
- [DB engine](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/core/database.py): `app/core/database.py`
- [User model](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/models/user.py): `app/models/user.py`
- [Expense model](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/models/expense.py): `app/models/expense.py`
- [Auth schemas](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/user.py): `app/schemas/user.py`
- [Token schema](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/token.py): `app/schemas/token.py`
- [Expense schemas](https://github.com/himanshubhamaniya/expense-tracker-api/blob/main/app/schemas/expense.py): `app/schemas/expense.py`

### Other components

- **API client**
- **SQL database**

## Connections

- API client → FastAPI app: sends requests
- FastAPI app → V1 router: mounts routes
- FastAPI app → DB engine: creates tables
- V1 router → Authentication: dispatches auth
- V1 router → Expense operations: dispatches expenses
- Authentication → Request dependencies: uses session
- Expense operations → Request dependencies: uses session and user
- Authentication → JWT and passwords: hashes and signs
- Request dependencies → JWT and passwords: verifies JWT
- Request dependencies → DB engine: opens session
- DB engine → Settings: reads URL
- DB engine → SQL database: connects
- Authentication → User model: queries and writes
- Request dependencies → User model: loads user
- Expense operations → User model: uses owner
- Expense operations → Expense model: queries and mutates
- User model → DB engine: uses ORM base
- Expense model → DB engine: uses ORM base
- Authentication → Auth schemas: validates and responds
- Authentication → Token schema: returns token
- Expense operations → Expense schemas: validates and responds
- Expense schemas → Expense model: uses category enum
