# charantej06/expense_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/charantej06/expense_tracker
- Repository: https://github.com/charantej06/expense_tracker

## Overview

This is a FastAPI expense-tracking API. Users sign up and verify by email OTP, authenticate with access or refresh tokens, and use authenticated endpoints to create, list, update, and delete their expenses. Account and expense operations use SQLAlchemy sessions; Redis supports OTP, pending signup data, and token revocation. The README contains only the product name, so capabilities and links here are based on the sampled route and service code; the email sender’s external delivery mechanism was not shown.

Main entry points: [`src/auth/routes.py`](https://github.com/charantej06/expense_tracker/blob/main/src/auth/routes.py) (Account endpoints), [`src/expenses/routes.py`](https://github.com/charantej06/expense_tracker/blob/main/src/expenses/routes.py) (Expense endpoints), [`src/auth/dependencies.py`](https://github.com/charantej06/expense_tracker/blob/main/src/auth/dependencies.py) (Token guards), [`src/db/redis.py`](https://github.com/charantej06/expense_tracker/blob/main/src/db/redis.py) (Redis operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Identity and access"]
  node_auth_routes["Account endpoints<br/>[routes.py]"]
  node_auth_schemas["Account schemas<br/>[schemas.py]"]
  node_auth_services["Account services<br/>[services.py]"]
  node_user_model["User model<br/>[models.py]"]
  node_token_utils["Password and tokens<br/>[utils.py]"]
  node_token_guard["Token guards<br/>[dependencies.py]"]
  node_email_sender["Verification email<br/>[send_mails.py]"]
end

subgraph group_expenses["Expense management"]
  node_expense_routes["Expense endpoints<br/>[routes.py]"]
  node_expense_schemas["Expense schemas<br/>[schemas.py]"]
  node_expense_services["Expense services<br/>[services.py]"]
  node_expense_model["Expense model<br/>[models.py]"]
end

subgraph group_infra["Persistence and runtime"]
  node_redis_helpers["Redis operations<br/>[redis.py]"]
  node_session_provider["Database sessions<br/>[main.py]"]
  node_database[("SQL database")]
  node_redis_store[("Redis store")]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("API user"))

node_user -->|"calls account API"| node_auth_routes
node_user -->|"calls expense API"| node_expense_routes
node_auth_routes -->|"validates input"| node_auth_schemas
node_auth_routes -->|"calls"| node_auth_services
node_auth_services -->|"queries and writes"| node_user_model
node_auth_routes -->|"checks and issues tokens"| node_token_utils
node_token_guard -->|"decodes tokens"| node_token_utils
node_auth_routes -->|"requires token checks"| node_token_guard
node_auth_routes -->|"stores and checks OTP data"| node_redis_helpers
node_token_guard -->|"checks revocation"| node_redis_helpers
node_auth_routes -->|"sends verification mail"| node_email_sender
node_expense_routes -->|"validates input"| node_expense_schemas
node_expense_routes -->|"requires access token"| node_token_guard
node_expense_routes -->|"calls"| node_expense_services
node_expense_services -->|"queries and writes"| node_expense_model
node_auth_routes -->|"gets database session"| node_session_provider
node_expense_routes -->|"gets database session"| node_session_provider
node_session_provider -->|"opens sessions"| node_database
node_auth_services -->|"executes queries and commits"| node_database
node_expense_services -->|"executes queries and commits"| node_database
node_redis_helpers -->|"reads and writes"| node_redis_store
node_session_provider -->|"reads database settings"| node_config
node_redis_helpers -->|"reads Redis settings"| node_config
node_token_utils -->|"reads JWT settings"| node_config
node_email_sender -->|"reads mail settings"| node_config

click node_auth_routes "https://github.com/charantej06/expense_tracker/blob/main/src/auth/routes.py"
click node_auth_schemas "https://github.com/charantej06/expense_tracker/blob/main/src/auth/schemas.py"
click node_auth_services "https://github.com/charantej06/expense_tracker/blob/main/src/auth/services.py"
click node_user_model "https://github.com/charantej06/expense_tracker/blob/main/src/auth/models.py"
click node_token_utils "https://github.com/charantej06/expense_tracker/blob/main/src/auth/utils.py"
click node_token_guard "https://github.com/charantej06/expense_tracker/blob/main/src/auth/dependencies.py"
click node_redis_helpers "https://github.com/charantej06/expense_tracker/blob/main/src/db/redis.py"
click node_email_sender "https://github.com/charantej06/expense_tracker/blob/main/src/emails/send_mails.py"
click node_expense_routes "https://github.com/charantej06/expense_tracker/blob/main/src/expenses/routes.py"
click node_expense_schemas "https://github.com/charantej06/expense_tracker/blob/main/src/expenses/schemas.py"
click node_expense_services "https://github.com/charantej06/expense_tracker/blob/main/src/expenses/services.py"
click node_expense_model "https://github.com/charantej06/expense_tracker/blob/main/src/expenses/models.py"
click node_session_provider "https://github.com/charantej06/expense_tracker/blob/main/src/db/main.py"
click node_config "https://github.com/charantej06/expense_tracker/blob/main/src/config.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_auth_routes,node_auth_schemas,node_auth_services,node_user_model,node_token_utils,node_token_guard,node_email_sender,node_user toneBlue
class node_expense_routes,node_expense_schemas,node_expense_services,node_expense_model toneAmber
class node_redis_helpers,node_session_provider,node_database,node_redis_store,node_config toneMint
```

## Components

### Identity and access

- [Account endpoints](https://github.com/charantej06/expense_tracker/blob/main/src/auth/routes.py): `src/auth/routes.py`
- [Account schemas](https://github.com/charantej06/expense_tracker/blob/main/src/auth/schemas.py): `src/auth/schemas.py`
- [Account services](https://github.com/charantej06/expense_tracker/blob/main/src/auth/services.py): `src/auth/services.py`
- [User model](https://github.com/charantej06/expense_tracker/blob/main/src/auth/models.py): `src/auth/models.py`
- [Password and tokens](https://github.com/charantej06/expense_tracker/blob/main/src/auth/utils.py): `src/auth/utils.py`
- [Token guards](https://github.com/charantej06/expense_tracker/blob/main/src/auth/dependencies.py): `src/auth/dependencies.py`
- [Verification email](https://github.com/charantej06/expense_tracker/blob/main/src/emails/send_mails.py): `src/emails/send_mails.py`

### Expense management

- [Expense endpoints](https://github.com/charantej06/expense_tracker/blob/main/src/expenses/routes.py): `src/expenses/routes.py`
- [Expense schemas](https://github.com/charantej06/expense_tracker/blob/main/src/expenses/schemas.py): `src/expenses/schemas.py`
- [Expense services](https://github.com/charantej06/expense_tracker/blob/main/src/expenses/services.py): `src/expenses/services.py`
- [Expense model](https://github.com/charantej06/expense_tracker/blob/main/src/expenses/models.py): `src/expenses/models.py`

### Persistence and runtime

- [Redis operations](https://github.com/charantej06/expense_tracker/blob/main/src/db/redis.py): `src/db/redis.py`
- [Database sessions](https://github.com/charantej06/expense_tracker/blob/main/src/db/main.py): `src/db/main.py`
- **SQL database**
- **Redis store**
- [Runtime settings](https://github.com/charantej06/expense_tracker/blob/main/src/config.py): `src/config.py`

### Other components

- **API user**

## Connections

- API user → Account endpoints: calls account API (evidence: `src/auth/routes.py`)
- API user → Expense endpoints: calls expense API (evidence: `src/expenses/routes.py`)
- Account endpoints → Account schemas: validates input (evidence: `src/auth/routes.py`)
- Account endpoints → Account services: calls (evidence: `src/auth/routes.py`)
- Account services → User model: queries and writes (evidence: `src/auth/services.py`)
- Account endpoints → Password and tokens: checks and issues tokens (evidence: `src/auth/routes.py`)
- Token guards → Password and tokens: decodes tokens (evidence: `src/auth/dependencies.py`)
- Account endpoints → Token guards: requires token checks (evidence: `src/auth/routes.py`)
- Account endpoints → Redis operations: stores and checks OTP data (evidence: `src/auth/routes.py`)
- Token guards → Redis operations: checks revocation (evidence: `src/auth/dependencies.py`)
- Account endpoints → Verification email: sends verification mail (evidence: `src/auth/routes.py`)
- Expense endpoints → Expense schemas: validates input (evidence: `src/expenses/routes.py`)
- Expense endpoints → Token guards: requires access token (evidence: `src/expenses/routes.py`)
- Expense endpoints → Expense services: calls (evidence: `src/expenses/routes.py`)
- Expense services → Expense model: queries and writes (evidence: `src/expenses/services.py`)
- Account endpoints → Database sessions: gets database session (evidence: `src/auth/routes.py`)
- Expense endpoints → Database sessions: gets database session (evidence: `src/expenses/routes.py`)
- Database sessions → SQL database: opens sessions (evidence: `src/db/main.py`)
- Account services → SQL database: executes queries and commits (evidence: `src/auth/services.py`)
- Expense services → SQL database: executes queries and commits (evidence: `src/expenses/services.py`)
- Redis operations → Redis store: reads and writes (evidence: `src/db/redis.py`)
- Database sessions → Runtime settings: reads database settings (evidence: `src/db/main.py`)
- Redis operations → Runtime settings: reads Redis settings (evidence: `src/db/redis.py`)
- Password and tokens → Runtime settings: reads JWT settings (evidence: `src/auth/utils.py`)
- Verification email → Runtime settings: reads mail settings (evidence: `src/emails/send_mails.py`)
