# matiasmazparrotefeliu/expense_management_application architecture

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

- Interactive diagram: https://gitdiagram.com/matiasmazparrotefeliu/expense_management_application
- Repository: https://github.com/matiasmazparrotefeliu/expense_management_application

## Overview

This is a personal expense-management application: users authenticate, manage multi-currency accounts, record income and expenses, and review budgets and monthly reports. The main workflow runs from the protected frontend through its API client to authenticated backend routes and domain services, which validate and persist changes. Text-based AI extraction returns an editable preview; the user confirms it through the normal operation-creation flow. The graph includes documented capabilities whose implementation was not sampled; edges are limited to relationships supported by excerpts, source-index references, or the README.

Main entry points: [`backend/main.py`](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/main.py) (FastAPI application), [`backend/src/models`](https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/backend/src/models) (Domain records), [`backend/src/services/operation_service.py`](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/operation_service.py) (Operation service), [`backend/src/api/operation_routes.py`](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/operation_routes.py) (Operation routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_auth_ui["Login and registration"]
  node_auth_provider["Auth provider<br/>[AuthProvider.tsx]"]
  node_dashboard["Accounts and operations UI"]
  node_ai_form["AI extraction preview"]
  node_reports_ui["Monthly reports UI"]
  node_data_provider["Data provider<br/>[DataProvider.tsx]"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_auth_api["Auth API adapter<br/>[authApi.ts]"]
  node_operations_api["Operations API adapter<br/>[operationsApi.ts]"]
  node_budget_api["Budget API adapter<br/>[budgetApi.ts]"]
end

subgraph group_api["Backend API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_user_routes["User routes<br/>[user_routes.py]"]
  node_account_routes["Account routes<br/>[account_routes.py]"]
  node_category_routes["Category routes<br/>[category_routes.py]"]
  node_operation_routes["Operation routes"]
  node_budget_routes["Budget routes<br/>[budget_routes.py]"]
end

subgraph group_domain["Domain services"]
  node_user_service["User service<br/>[user_service.py]"]
  node_account_service["Account service<br/>[account_service.py]"]
  node_category_service["Category service"]
  node_operation_service["Operation service"]
  node_text_service["Narration extraction"]
  node_budget_service["Budget analytics<br/>[budget_service.py]"]
end

subgraph group_auth["Authentication"]
  node_auth_middleware["Request authentication<br/>[middleware.py]"]
  node_auth_security["JWT and password security<br/>[security.py]"]
  node_auth_dependencies["Current-user dependency<br/>[dependencies.py]"]
end

subgraph group_persistence["Persistence and models"]
  node_db_config["Database sessions<br/>[config.py]"]
  node_models[("Domain records")]
  node_budget_model[("Budget limits<br/>[budget_limit.py]")]
end

node_person(("User"))
node_llm{{"LLM provider"}}

node_person -->|"signs in"| node_auth_ui
node_person -->|"manages finances"| node_dashboard
node_auth_ui -->|"submits credentials"| node_auth_provider
node_auth_provider -->|"calls"| node_auth_api
node_auth_api -->|"sends requests"| node_api_client
node_dashboard -.->|"uses data"| node_data_provider
node_data_provider -.->|"requests operations"| node_operations_api
node_data_provider -.->|"requests budgets"| node_budget_api
node_ai_form -->|"requests extraction"| node_operations_api
node_operations_api -.->|"sends requests"| node_api_client
node_budget_api -.->|"sends requests"| node_api_client
node_reports_ui -.->|"loads summaries"| node_budget_api
node_api_client -->|"calls REST API"| node_app
node_app -->|"installs middleware"| node_auth_middleware
node_app -->|"registers router"| node_user_routes
node_app -->|"registers router"| node_account_routes
node_app -->|"registers router"| node_category_routes
node_app -->|"registers router"| node_operation_routes
node_app -->|"registers router"| node_budget_routes
node_auth_middleware -->|"validates tokens"| node_auth_security
node_auth_middleware -->|"loads user data"| node_db_config
node_account_routes -->|"requires user"| node_auth_dependencies
node_operation_routes -->|"requires user"| node_auth_dependencies
node_budget_routes -->|"requires user"| node_auth_dependencies
node_user_routes -->|"calls"| node_user_service
node_account_routes -->|"calls"| node_account_service
node_category_routes -->|"calls"| node_category_service
node_operation_routes -->|"calls"| node_operation_service
node_operation_routes -->|"calls extraction"| node_text_service
node_budget_routes -->|"calls"| node_budget_service
node_text_service -->|"checks account"| node_operation_service
node_text_service -->|"requests extraction"| node_llm
node_person -->|"confirms preview"| node_operation_service
node_operation_service -->|"reads and writes"| node_models
node_account_service -.->|"reads and writes"| node_models
node_category_service -.->|"reads catalog"| node_models
node_user_service -->|"reads and writes"| node_models
node_budget_service -->|"reads and writes"| node_models
node_budget_service -->|"uses operation data"| node_operation_service
node_budget_service -->|"manages limits"| node_budget_model
node_app -->|"creates schema"| node_db_config
node_db_config -.->|"provides sessions"| node_models

click node_auth_ui "https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/frontend-next/src/features/auth"
click node_auth_provider "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/auth/AuthProvider.tsx"
click node_dashboard "https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/frontend-next/src/components/dashboard"
click node_ai_form "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/components/dashboard/AIExtractionForm.tsx"
click node_reports_ui "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/reports/MonthlyReportView.tsx"
click node_data_provider "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/data/DataProvider.tsx"
click node_api_client "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/client.ts"
click node_auth_api "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/authApi.ts"
click node_operations_api "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/operationsApi.ts"
click node_budget_api "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/budgetApi.ts"
click node_app "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/main.py"
click node_user_routes "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/user_routes.py"
click node_account_routes "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/account_routes.py"
click node_category_routes "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/category_routes.py"
click node_operation_routes "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/operation_routes.py"
click node_budget_routes "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/budget_routes.py"
click node_user_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/user_service.py"
click node_account_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/account_service.py"
click node_category_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/category_service.py"
click node_operation_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/operation_service.py"
click node_text_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/operation_text_service.py"
click node_budget_service "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/budget_service.py"
click node_auth_middleware "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/middleware.py"
click node_auth_security "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/security.py"
click node_auth_dependencies "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/dependencies.py"
click node_db_config "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/db/config.py"
click node_models "https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/backend/src/models"
click node_budget_model "https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/models/budget_limit.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_ui,node_auth_provider,node_dashboard,node_ai_form,node_reports_ui,node_data_provider,node_api_client,node_auth_api,node_operations_api,node_budget_api,node_person toneBlue
class node_app,node_user_routes,node_account_routes,node_category_routes,node_operation_routes,node_budget_routes toneAmber
class node_user_service,node_account_service,node_category_service,node_operation_service,node_text_service,node_budget_service toneMint
class node_auth_middleware,node_auth_security,node_auth_dependencies toneRose
class node_db_config,node_models,node_budget_model,node_llm toneIndigo
```

## Components

### Frontend experience

- [Login and registration](https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/frontend-next/src/features/auth): `frontend-next/src/features/auth`
- [Auth provider](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/auth/AuthProvider.tsx): `frontend-next/src/features/auth/AuthProvider.tsx`
- [Accounts and operations UI](https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/frontend-next/src/components/dashboard): `frontend-next/src/components/dashboard`
- [AI extraction preview](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/components/dashboard/AIExtractionForm.tsx): `frontend-next/src/components/dashboard/AIExtractionForm.tsx`
- [Monthly reports UI](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/reports/MonthlyReportView.tsx): `frontend-next/src/features/reports/MonthlyReportView.tsx`
- [Data provider](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/features/data/DataProvider.tsx): `frontend-next/src/features/data/DataProvider.tsx`
- [HTTP client](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/client.ts): `frontend-next/src/api/client.ts`
- [Auth API adapter](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/authApi.ts): `frontend-next/src/api/authApi.ts`
- [Operations API adapter](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/operationsApi.ts): `frontend-next/src/api/operationsApi.ts`
- [Budget API adapter](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/frontend-next/src/api/budgetApi.ts): `frontend-next/src/api/budgetApi.ts`

### Backend API

- [FastAPI application](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/main.py): `backend/main.py`
- [User routes](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/user_routes.py): `backend/src/api/user_routes.py`
- [Account routes](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/account_routes.py): `backend/src/api/account_routes.py`
- [Category routes](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/category_routes.py): `backend/src/api/category_routes.py`
- [Operation routes](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/operation_routes.py): `backend/src/api/operation_routes.py`
- [Budget routes](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/api/budget_routes.py): `backend/src/api/budget_routes.py`

### Domain services

- [User service](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/user_service.py): `backend/src/services/user_service.py`
- [Account service](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/account_service.py): `backend/src/services/account_service.py`
- [Category service](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/category_service.py): `backend/src/services/category_service.py`
- [Operation service](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/operation_service.py): `backend/src/services/operation_service.py`
- [Narration extraction](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/operation_text_service.py): `backend/src/services/operation_text_service.py`
- [Budget analytics](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/services/budget_service.py): `backend/src/services/budget_service.py`

### Authentication

- [Request authentication](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/middleware.py): `backend/src/auth/middleware.py`
- [JWT and password security](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/security.py): `backend/src/auth/security.py`
- [Current-user dependency](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/auth/dependencies.py): `backend/src/auth/dependencies.py`

### Persistence and models

- [Database sessions](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/db/config.py): `backend/src/db/config.py`
- [Domain records](https://github.com/matiasmazparrotefeliu/expense_management_application/tree/master/backend/src/models): `backend/src/models`
- [Budget limits](https://github.com/matiasmazparrotefeliu/expense_management_application/blob/master/backend/src/models/budget_limit.py): `backend/src/models/budget_limit.py`

### Other components

- **User**
- **LLM provider**

## Connections

- User → Login and registration: signs in (evidence: `README.md`)
- User → Accounts and operations UI: manages finances (evidence: `README.md`)
- Login and registration → Auth provider: submits credentials (evidence: `frontend-next/src/features/auth/AuthProvider.tsx`)
- Auth provider → Auth API adapter: calls (evidence: `frontend-next/src/features/auth/AuthProvider.tsx`)
- Auth API adapter → HTTP client: sends requests (evidence: `frontend-next/src/api/authApi.ts`)
- Accounts and operations UI → Data provider: uses data
- Data provider → Operations API adapter: requests operations
- Data provider → Budget API adapter: requests budgets
- AI extraction preview → Operations API adapter: requests extraction (evidence: `README.md`)
- Operations API adapter → HTTP client: sends requests
- Budget API adapter → HTTP client: sends requests
- Monthly reports UI → Budget API adapter: loads summaries
- HTTP client → FastAPI application: calls REST API (evidence: `README.md`)
- FastAPI application → Request authentication: installs middleware (evidence: `backend/main.py`)
- FastAPI application → User routes: registers router (evidence: `backend/main.py`)
- FastAPI application → Account routes: registers router (evidence: `backend/main.py`)
- FastAPI application → Category routes: registers router (evidence: `backend/main.py`)
- FastAPI application → Operation routes: registers router (evidence: `backend/main.py`)
- FastAPI application → Budget routes: registers router (evidence: `backend/main.py`)
- Request authentication → JWT and password security: validates tokens (evidence: `backend/src/auth/middleware.py`)
- Request authentication → Database sessions: loads user data (evidence: `backend/src/auth/middleware.py`)
- Account routes → Current-user dependency: requires user (evidence: `backend/src/api/account_routes.py`)
- Operation routes → Current-user dependency: requires user (evidence: `backend/src/api/operation_routes.py`)
- Budget routes → Current-user dependency: requires user (evidence: `backend/src/api/budget_routes.py`)
- User routes → User service: calls (evidence: `backend/src/api/user_routes.py`)
- Account routes → Account service: calls (evidence: `backend/src/api/account_routes.py`)
- Category routes → Category service: calls (evidence: `backend/src/api/category_routes.py`)
- Operation routes → Operation service: calls (evidence: `backend/src/api/operation_routes.py`)
- Operation routes → Narration extraction: calls extraction (evidence: `backend/src/api/operation_routes.py`)
- Budget routes → Budget analytics: calls (evidence: `backend/src/api/budget_routes.py`)
- Narration extraction → Operation service: checks account (evidence: `backend/src/services/operation_text_service.py`)
- Narration extraction → LLM provider: requests extraction (evidence: `backend/src/services/operation_text_service.py`)
- User → Operation service: confirms preview (evidence: `README.md`)
- Operation service → Domain records: reads and writes (evidence: `backend/src/services/operation_service.py`)
- Account service → Domain records: reads and writes
- Category service → Domain records: reads catalog
- User service → Domain records: reads and writes (evidence: `backend/src/services/user_service.py`)
- Budget analytics → Domain records: reads and writes (evidence: `backend/src/services/budget_service.py`)
- Budget analytics → Operation service: uses operation data (evidence: `backend/src/services/budget_service.py`)
- Budget analytics → Budget limits: manages limits (evidence: `backend/src/services/budget_service.py`)
- FastAPI application → Database sessions: creates schema (evidence: `backend/main.py`)
- Database sessions → Domain records: provides sessions
