# incognitol07/expense-tracker-api architecture

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

- Interactive diagram: https://gitdiagram.com/incognitol07/expense-tracker-api
- Repository: https://github.com/incognitol07/expense-tracker-api

## Overview

This is a FastAPI expense-tracking and budgeting API. The main workflow is a user authenticating and managing expenses, categories, and budgets through mounted API routes, with analytics and group expense/debt capabilities alongside it. Budget checks and notification cleanup run as scheduled background work; notifications are stored and can also be delivered over WebSockets. Several route implementations are unsampled, so their documented capabilities are represented without guessing their internal call chains.

Main entry points: [`app/main.py`](https://github.com/incognitol07/expense-tracker-api/blob/master/app/main.py) (FastAPI application), [`app/database.py`](https://github.com/incognitol07/expense-tracker-api/blob/master/app/database.py) (Database sessions), [`app/background_tasks/scheduler.py`](https://github.com/incognitol07/expense-tracker-api/blob/master/app/background_tasks/scheduler.py) (Task scheduler), [`app/utils/helpers/notifications.py`](https://github.com/incognitol07/expense-tracker-api/blob/master/app/utils/helpers/notifications.py) (Notification helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_application["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_google["Google sign-in<br/>[google_auth.py]"]
  node_profile["User profile<br/>[profile.py]"]
end

subgraph group_finance["Personal finances"]
  node_expenses["Expense tracking<br/>[expenses.py]"]
  node_categories["Categories<br/>[categories.py]"]
  node_budgets["Budget management<br/>[budget.py]"]
  node_category_budgets["Category budgets"]
  node_analytics["Spending analytics<br/>[analytics.py]"]
end

subgraph group_groups["Shared expenses"]
  node_groups_api["Group management<br/>[groups.py]"]
  node_group_expenses["Shared expenses<br/>[group_expenses.py]"]
  node_group_debts["Group debts<br/>[group_debt.py]"]
end

subgraph group_alerts["Alerts and realtime"]
  node_notifications_api["Notification API<br/>[notifications.py]"]
  node_scheduler["Task scheduler<br/>[scheduler.py]"]
  node_jobs["Scheduled jobs"]
  node_ws_manager["WebSocket manager"]
  node_notification_helper["Notification helper<br/>[notifications.py]"]
end

subgraph group_platform["Persistence and configuration"]
  node_database[("Database sessions<br/>[database.py]")]
  node_user_model["User model<br/>[user.py]"]
  node_settings["Application settings<br/>[config.py]"]
end

node_user(("User"))

node_user -->|"uses API"| node_application
node_application -->|"mounts"| node_auth
node_application -->|"mounts"| node_google
node_application -->|"mounts"| node_expenses
node_application -->|"mounts"| node_categories
node_application -->|"mounts"| node_budgets
node_application -->|"mounts"| node_category_budgets
node_application -->|"mounts"| node_analytics
node_application -->|"mounts"| node_profile
node_application -->|"mounts"| node_groups_api
node_application -->|"mounts"| node_group_expenses
node_application -->|"mounts"| node_group_debts
node_application -->|"mounts"| node_notifications_api
node_auth -->|"queries"| node_database
node_google -->|"queries"| node_database
node_expenses -->|"uses sessions"| node_database
node_categories -->|"uses sessions"| node_database
node_budgets -->|"uses sessions"| node_database
node_category_budgets -->|"uses sessions"| node_database
node_groups_api -->|"uses sessions"| node_database
node_application -->|"creates tables"| node_database
node_application -->|"starts"| node_scheduler
node_scheduler -->|"schedules"| node_jobs
node_scheduler -->|"opens sessions"| node_database
node_jobs -->|"sends alerts"| node_ws_manager
node_application -->|"serves WebSockets"| node_ws_manager
node_group_expenses -.->|"uses notifications"| node_notification_helper
node_group_debts -.->|"uses notifications"| node_notification_helper
node_notification_helper -->|"stores notifications"| node_database
node_application -->|"configures app"| node_settings
node_user_model -->|"maps to base"| node_database

click node_application "https://github.com/incognitol07/expense-tracker-api/blob/master/app/main.py"
click node_auth "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/auth.py"
click node_google "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/google_auth.py"
click node_profile "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/profile.py"
click node_expenses "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/expenses.py"
click node_categories "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/categories.py"
click node_budgets "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/budget.py"
click node_category_budgets "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/category_budgets.py"
click node_analytics "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/analytics.py"
click node_groups_api "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/groups.py"
click node_group_expenses "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/group_expenses.py"
click node_group_debts "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/group_debt.py"
click node_notifications_api "https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/notifications.py"
click node_scheduler "https://github.com/incognitol07/expense-tracker-api/blob/master/app/background_tasks/scheduler.py"
click node_jobs "https://github.com/incognitol07/expense-tracker-api/tree/master/app/background_tasks/jobs"
click node_ws_manager "https://github.com/incognitol07/expense-tracker-api/blob/master/app/websocket_manager.py"
click node_notification_helper "https://github.com/incognitol07/expense-tracker-api/blob/master/app/utils/helpers/notifications.py"
click node_database "https://github.com/incognitol07/expense-tracker-api/blob/master/app/database.py"
click node_user_model "https://github.com/incognitol07/expense-tracker-api/blob/master/app/models/user.py"
click node_settings "https://github.com/incognitol07/expense-tracker-api/blob/master/app/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_application,node_auth,node_google,node_profile,node_user toneBlue
class node_expenses,node_categories,node_budgets,node_category_budgets,node_analytics toneAmber
class node_groups_api,node_group_expenses,node_group_debts toneMint
class node_notifications_api,node_scheduler,node_jobs,node_ws_manager,node_notification_helper toneRose
class node_database,node_user_model,node_settings toneIndigo
```

## Components

### API and identity

- [FastAPI application](https://github.com/incognitol07/expense-tracker-api/blob/master/app/main.py): `app/main.py`
- [Authentication](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/auth.py): `app/routers/auth.py`
- [Google sign-in](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/google_auth.py): `app/routers/google_auth.py`
- [User profile](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/profile.py): `app/routers/profile.py`

### Personal finances

- [Expense tracking](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/expenses.py): `app/routers/expenses.py`
- [Categories](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/categories.py): `app/routers/categories.py`
- [Budget management](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/budget.py): `app/routers/budget.py`
- [Category budgets](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/category_budgets.py): `app/routers/category_budgets.py`
- [Spending analytics](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/analytics.py): `app/routers/analytics.py`

### Shared expenses

- [Group management](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/groups.py): `app/routers/groups.py`
- [Shared expenses](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/group_expenses.py): `app/routers/group_expenses.py`
- [Group debts](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/group_debt.py): `app/routers/group_debt.py`

### Alerts and realtime

- [Notification API](https://github.com/incognitol07/expense-tracker-api/blob/master/app/routers/notifications.py): `app/routers/notifications.py`
- [Task scheduler](https://github.com/incognitol07/expense-tracker-api/blob/master/app/background_tasks/scheduler.py): `app/background_tasks/scheduler.py`
- [Scheduled jobs](https://github.com/incognitol07/expense-tracker-api/tree/master/app/background_tasks/jobs): `app/background_tasks/jobs`
- [WebSocket manager](https://github.com/incognitol07/expense-tracker-api/blob/master/app/websocket_manager.py): `app/websocket_manager.py`
- [Notification helper](https://github.com/incognitol07/expense-tracker-api/blob/master/app/utils/helpers/notifications.py): `app/utils/helpers/notifications.py`

### Persistence and configuration

- [Database sessions](https://github.com/incognitol07/expense-tracker-api/blob/master/app/database.py): `app/database.py`
- [User model](https://github.com/incognitol07/expense-tracker-api/blob/master/app/models/user.py): `app/models/user.py`
- [Application settings](https://github.com/incognitol07/expense-tracker-api/blob/master/app/config.py): `app/config.py`

### Other components

- **User**

## Connections

- User → FastAPI application: uses API (evidence: `README.md`)
- FastAPI application → Authentication: mounts (evidence: `app/main.py`)
- FastAPI application → Google sign-in: mounts (evidence: `app/main.py`)
- FastAPI application → Expense tracking: mounts (evidence: `app/main.py`)
- FastAPI application → Categories: mounts (evidence: `app/main.py`)
- FastAPI application → Budget management: mounts (evidence: `app/main.py`)
- FastAPI application → Category budgets: mounts (evidence: `app/main.py`)
- FastAPI application → Spending analytics: mounts (evidence: `app/main.py`)
- FastAPI application → User profile: mounts (evidence: `app/main.py`)
- FastAPI application → Group management: mounts (evidence: `app/main.py`)
- FastAPI application → Shared expenses: mounts (evidence: `app/main.py`)
- FastAPI application → Group debts: mounts (evidence: `app/main.py`)
- FastAPI application → Notification API: mounts (evidence: `app/main.py`)
- Authentication → Database sessions: queries (evidence: `app/routers/auth.py`)
- Google sign-in → Database sessions: queries (evidence: `app/routers/google_auth.py`)
- Expense tracking → Database sessions: uses sessions (evidence: `app/routers/expenses.py`)
- Categories → Database sessions: uses sessions (evidence: `app/routers/categories.py`)
- Budget management → Database sessions: uses sessions (evidence: `app/routers/budget.py`)
- Category budgets → Database sessions: uses sessions (evidence: `app/routers/category_budgets.py`)
- Group management → Database sessions: uses sessions (evidence: `app/routers/groups.py`)
- FastAPI application → Database sessions: creates tables (evidence: `app/main.py`)
- FastAPI application → Task scheduler: starts (evidence: `app/main.py`)
- Task scheduler → Scheduled jobs: schedules (evidence: `app/background_tasks/scheduler.py`)
- Task scheduler → Database sessions: opens sessions (evidence: `app/background_tasks/scheduler.py`)
- Scheduled jobs → WebSocket manager: sends alerts (evidence: `app/background_tasks/jobs/budget_monitoring.py`)
- FastAPI application → WebSocket manager: serves WebSockets (evidence: `app/main.py`)
- Shared expenses → Notification helper: uses notifications
- Group debts → Notification helper: uses notifications
- Notification helper → Database sessions: stores notifications (evidence: `app/utils/helpers/notifications.py`)
- FastAPI application → Application settings: configures app (evidence: `app/main.py`)
- User model → Database sessions: maps to base (evidence: `app/models/user.py`)
