# z33xd/finance-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/z33xd/finance-tracker
- Repository: https://github.com/z33xd/finance-tracker

## Overview

#### Purpose and Entry Points
Finance Tracker is a personal-finance system with a Spring Boot REST API and React/Vite client. The backend starts at `src/main/java/com/fintrack/finance_tracker/FinanceTrackerApplication.java`; the browser client starts at `frontend/src/main.jsx` and routes from `frontend/src/App.jsx`. The API manages authenticated users’ accounts, ledger transactions, categories, budgets, CSV imports, and currency reporting.

#### Client Application
The React SPA presents dashboard, account, transaction, budget, category, profile, and authentication views. `frontend/src/context/AuthContext.jsx` owns client authentication state; `frontend/src/components/ProtectedRoute.jsx` gates secured views. `frontend/src/services/api.js` is the HTTP boundary to the backend, while `frontend/src/components/Navbar.jsx` provides authenticated navigation. The production frontend is containerized and served through Nginx (`frontend/Dockerfile`, `frontend/nginx.conf`).

#### API and Domain Boundary
Backend domains follow a controller → service → Spring Data JPA repository/entity structure. Controllers expose REST endpoints, services implement user-scoped business rules and ledger effects, and repositories persist relational records to PostgreSQL. Core financial resources are:
- Accounts and dashboard summaries: `accounts/AccountController.java`, `accounts/AccountService.java`, `accounts/AccountSummary.java`
- Transactions, the primary ledger: `transactions/TransactionController.java`, `transactions/TransactionService.java`, `transactions/Transaction.java`
- Category-based spending caps: `budgets/BudgetService.java`, `budgets/BudgetSummary.java`, `categories/Category.java`

#### Authentication and Data Isolation
Public registration, login, and verification flow through `authentication/AuthenticationController.java` and `authentication/AuthenticationService.java`. JWT issuance and validation are separated into `jwt/JwtService.java` and `config/JwtAuthenticationFilter.java`; `config/SecurityConfiguration.java` applies stateless Spring Security. The authenticated principal is the isolation boundary: financial controllers/services scope operations to the current user rather than accepting an unrestricted tenant context. Signup verification uses `email/EmailService.java` with mail configuration in `config/EmailConfiguration.java`.

#### Financial Reporting and Exchange Rates
Amounts remain native to account/budget currencies. Read-time summaries convert balances or spending using persisted date-specific exchange-rate pairs. `exchange_rates/ExchangeRateService.java` manages retrieval/cache behavior, `exchange_rates/CurrencyConversionService.java` performs conversions, and `exchange_rates/BaseCurrencyResolver.java` determines the reporting anchor from the user’s first account. The external ExchangeRate-API is accessed through Spring’s configured web client (`config/WebClientConfig.java`) and requires an API key.

#### CSV Import Pipeline
Bulk uploads enter at `import_batches/ImportBatchController.java` and are staged/audited as `ImportBatch` records. `import_batches/ImportBatchService.java` parses and validates rows, detects duplicates, records job totals/status, and creates accepted ledger entries through the transaction path. This boundary protects account balance consistency while preserving batch-level processing telemetry; `transactions/TransactionRepository.java` and `import_batches/ImportBatchRepository.java` support the persistence side.

#### Runtime and Infrastructure
The backend is Java 21, Spring Boot 3, Maven, Spring Security, JPA/Hibernate, and PostgreSQL (`pom.xml`, `src/main/resources/application.properties`). Docker packaging exists for both application tiers (`Dockerfile`, `frontend/Dockerfile`) and orchestration is defined in `docker-compose.yml`. Required external dependencies are PostgreSQL, an SMTP/mail provider for verification, and ExchangeRate-API.

Main entry points: [`src/main/resources/application.properties`](https://github.com/z33xd/finance-tracker/blob/main/src/main/resources/application.properties) (PostgreSQL), [`frontend/src/main.jsx`](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/main.jsx) (React SPA), [`docker-compose.yml`](https://github.com/z33xd/finance-tracker/blob/main/docker-compose.yml) (Docker Compose), [`frontend/src/components/ProtectedRoute.jsx`](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/components/ProtectedRoute.jsx) (Protected Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_spa["React SPA<br/>Vite entry<br/>[main.jsx]"]
  node_auth_context["Auth Context<br/>client auth state<br/>[AuthContext.jsx]"]
  node_protected_routes["Protected Routes<br/>route guard<br/>[ProtectedRoute.jsx]"]
  node_api_client["API Client<br/>HTTP boundary<br/>[api.js]"]
end

subgraph group_api["Spring Boot API"]
  node_security["Security Filter Chain<br/>stateless security"]
  node_jwt_filter["JWT Filter<br/>authentication filter"]
  node_auth_api["Authentication API<br/>REST controller/service"]
  node_jwt_service["JWT Service<br/>token service"]
  node_email_service["Email Service<br/>verification mail"]
end

subgraph group_finance["Financial Domain"]
  node_accounts["Accounts &amp; Dashboard<br/>controller/service"]
  node_ledger["Transaction Ledger<br/>controller/service/entity"]
  node_budgets["Budgets &amp; Categories<br/>budget service"]
  node_import_api["CSV Import API<br/>batch controller"]
  node_import_pipeline["Import Batch Pipeline<br/>batch service"]
  node_reporting["Currency Reporting<br/>conversion services"]
  node_rates["Exchange Rate Service<br/>rate retrieval/cache"]
end

subgraph group_integrations["Infrastructure &amp; Integrations"]
  node_nginx["Nginx Frontend<br/>production server<br/>[nginx.conf]"]
  node_postgres[("PostgreSQL<br/>relational database")]
  node_exchange_api{{"ExchangeRate-API<br/>external API"}}
  node_smtp{{"SMTP Provider<br/>external mail"}}
  node_compose["Docker Compose<br/>runtime orchestration<br/>[docker-compose.yml]"]
end

node_spa -->|"owns session"| node_auth_context
node_spa -->|"routes secured views"| node_protected_routes
node_protected_routes -->|"checks auth"| node_auth_context
node_spa -->|"calls API"| node_api_client
node_nginx -->|"serves build"| node_spa
node_api_client -->|"REST requests"| node_security
node_security -->|"authenticates"| node_jwt_filter
node_jwt_filter -->|"validates token"| node_jwt_service
node_security -.->|"permits public flow"| node_auth_api
node_auth_api -->|"issues JWT"| node_jwt_service
node_auth_api -->|"sends verification"| node_email_service
node_email_service -->|"delivers mail"| node_smtp
node_security -->|"authenticated principal"| node_accounts
node_security -->|"authenticated principal"| node_ledger
node_security -->|"authenticated principal"| node_budgets
node_security -->|"authenticated principal"| node_import_api
node_import_api -->|"uploads CSV"| node_import_pipeline
node_import_pipeline -->|"creates accepted entries"| node_ledger
node_accounts -->|"requests summaries"| node_reporting
node_budgets -->|"converts spending"| node_reporting
node_reporting -->|"uses dated rates"| node_rates
node_rates -->|"fetches rates"| node_exchange_api
node_accounts -->|"persists accounts"| node_postgres
node_ledger -->|"persists transactions"| node_postgres
node_budgets -->|"persists budgets/categories"| node_postgres
node_import_pipeline -->|"persists batches"| node_postgres
node_auth_api -->|"persists users"| node_postgres
node_compose -.->|"orchestrates"| node_nginx
node_compose -.->|"orchestrates"| node_postgres

click node_spa "https://github.com/z33xd/finance-tracker/blob/main/frontend/src/main.jsx"
click node_auth_context "https://github.com/z33xd/finance-tracker/blob/main/frontend/src/context/AuthContext.jsx"
click node_protected_routes "https://github.com/z33xd/finance-tracker/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_api_client "https://github.com/z33xd/finance-tracker/blob/main/frontend/src/services/api.js"
click node_nginx "https://github.com/z33xd/finance-tracker/blob/main/frontend/nginx.conf"
click node_postgres "https://github.com/z33xd/finance-tracker/blob/main/src/main/resources/application.properties"
click node_compose "https://github.com/z33xd/finance-tracker/blob/main/docker-compose.yml"

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_spa,node_auth_context,node_protected_routes,node_api_client toneBlue
class node_security,node_jwt_filter,node_auth_api,node_jwt_service,node_email_service toneAmber
class node_accounts,node_ledger,node_budgets,node_import_api,node_import_pipeline,node_reporting,node_rates toneMint
class node_nginx,node_postgres,node_exchange_api,node_smtp,node_compose toneRose
```

## Components

### React Client

- [React SPA](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/main.jsx): Vite entry · Browser application entry and route shell. · `frontend/src/main.jsx`
- [Auth Context](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/context/AuthContext.jsx): client auth state · `frontend/src/context/AuthContext.jsx`
- [Protected Routes](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/components/ProtectedRoute.jsx): route guard · `frontend/src/components/ProtectedRoute.jsx`
- [API Client](https://github.com/z33xd/finance-tracker/blob/main/frontend/src/services/api.js): HTTP boundary · `frontend/src/services/api.js`

### Spring Boot API

- **Security Filter Chain**: stateless security · Applies JWT authentication to secured API routes.
- **JWT Filter**: authentication filter
- **Authentication API**: REST controller/service · Registration, login, and verification endpoints.
- **JWT Service**: token service
- **Email Service**: verification mail

### Financial Domain

- **Accounts & Dashboard**: controller/service · User-scoped account operations and balance summaries.
- **Transaction Ledger**: controller/service/entity · Primary user-scoped ledger and balance-effect path.
- **Budgets & Categories**: budget service · Category-based spending caps and summaries.
- **CSV Import API**: batch controller
- **Import Batch Pipeline**: batch service · Validates rows, detects duplicates, and records batch status.
- **Currency Reporting**: conversion services · Resolves reporting currency and converts read-time summaries.
- **Exchange Rate Service**: rate retrieval/cache

### Infrastructure & Integrations

- [Nginx Frontend](https://github.com/z33xd/finance-tracker/blob/main/frontend/nginx.conf): production server · `frontend/nginx.conf`
- [PostgreSQL](https://github.com/z33xd/finance-tracker/blob/main/src/main/resources/application.properties): relational database · JPA persistence for users, accounts, ledger, budgets, and import batches. · `src/main/resources/application.properties`
- **ExchangeRate-API**: external API
- **SMTP Provider**: external mail
- [Docker Compose](https://github.com/z33xd/finance-tracker/blob/main/docker-compose.yml): runtime orchestration · Runs the packaged application tiers and database. · `docker-compose.yml`

## Connections

- React SPA → Auth Context: owns session
- React SPA → Protected Routes: routes secured views
- Protected Routes → Auth Context: checks auth
- React SPA → API Client: calls API
- Nginx Frontend → React SPA: serves build
- API Client → Security Filter Chain: REST requests
- Security Filter Chain → JWT Filter: authenticates
- JWT Filter → JWT Service: validates token
- Security Filter Chain → Authentication API: permits public flow
- Authentication API → JWT Service: issues JWT
- Authentication API → Email Service: sends verification
- Email Service → SMTP Provider: delivers mail
- Security Filter Chain → Accounts & Dashboard: authenticated principal
- Security Filter Chain → Transaction Ledger: authenticated principal
- Security Filter Chain → Budgets & Categories: authenticated principal
- Security Filter Chain → CSV Import API: authenticated principal
- CSV Import API → Import Batch Pipeline: uploads CSV
- Import Batch Pipeline → Transaction Ledger: creates accepted entries
- Accounts & Dashboard → Currency Reporting: requests summaries
- Budgets & Categories → Currency Reporting: converts spending
- Currency Reporting → Exchange Rate Service: uses dated rates
- Exchange Rate Service → ExchangeRate-API: fetches rates
- Accounts & Dashboard → PostgreSQL: persists accounts
- Transaction Ledger → PostgreSQL: persists transactions
- Budgets & Categories → PostgreSQL: persists budgets/categories
- Import Batch Pipeline → PostgreSQL: persists batches
- Authentication API → PostgreSQL: persists users
- Docker Compose → Nginx Frontend: orchestrates
- Docker Compose → PostgreSQL: orchestrates
