# hengthay/expenses-tracker-api architecture

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

## Overview

This is a Spring application for expense tracking, with user registration and JWT authentication, account and category management, and income/expense transactions that adjust account balances. The main flow is an authenticated client request through a controller and service to persistence; transaction operations also resolve the current user, account, and category. The excerpts establish these service-level calls and balance updates. Other listed controller capabilities are included, but relationships for unsampled implementations are omitted where their call paths cannot be verified.

Main entry points: [`src/main/java/com/hengthay/myapp/transaction/TransactionService.java`](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionService.java) (Transaction service), [`src/main/java/com/hengthay/myapp/auth/AuthService.java`](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/AuthService.java) (Authentication), [`src/main/java/com/hengthay/myapp/account/AccountService.java`](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountService.java) (Account service), [`src/main/java/com/hengthay/myapp/user/UserRepository.java`](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserRepository.java) (User repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_auth_controller["Auth API"]
  node_auth_service["Authentication<br/>[AuthService.java]"]
  node_jwt_service["JWT service<br/>[JwtService.java]"]
  node_jwt_filter["JWT filter"]
  node_security["Security config"]
end

subgraph group_users["User management"]
  node_user_api["User API"]
  node_user_service["User service<br/>[UserService.java]"]
  node_user_repo["User repository"]
end

subgraph group_accounts["Accounts"]
  node_account_api["Account API"]
  node_account_service["Account service"]
  node_account_repo["Account repository"]
end

subgraph group_transactions["Transactions"]
  node_transaction_api["Transaction API"]
  node_transaction_service["Transaction service"]
  node_transaction_repo["Transaction repository"]
end

subgraph group_categories["Categories"]
  node_category_api["Category API"]
  node_category_service["Category service"]
  node_category_repo["Category repository"]
end

node_client(("API client"))
node_database[("Relational database")]
node_error_handler["Error mapping"]

node_client -->|"sends login"| node_auth_controller
node_client -->|"manages users"| node_user_api
node_client -->|"manages accounts"| node_account_api
node_client -->|"records transactions"| node_transaction_api
node_client -->|"manages categories"| node_category_api
node_auth_controller -->|"delegates auth"| node_auth_service
node_auth_service -->|"loads users"| node_user_repo
node_auth_service -->|"issues tokens"| node_jwt_service
node_jwt_filter -->|"validates tokens"| node_jwt_service
node_security -->|"registers filter"| node_jwt_filter
node_user_api -->|"delegates users"| node_user_service
node_user_service -->|"persists users"| node_user_repo
node_account_api -->|"delegates accounts"| node_account_service
node_account_service -->|"gets current user"| node_auth_service
node_account_service -->|"persists accounts"| node_account_repo
node_transaction_api -->|"delegates transactions"| node_transaction_service
node_transaction_service -->|"gets current user"| node_auth_service
node_transaction_service -->|"loads and updates account"| node_account_repo
node_transaction_service -->|"loads category"| node_category_repo
node_transaction_service -->|"persists transactions"| node_transaction_repo
node_category_api -->|"delegates categories"| node_category_service
node_category_service -->|"persists categories"| node_category_repo
node_user_repo -.->|"reads and writes"| node_database
node_account_repo -.->|"reads and writes"| node_database
node_transaction_repo -.->|"reads and writes"| node_database
node_category_repo -.->|"reads and writes"| node_database

click node_auth_controller "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/AuthController.java"
click node_auth_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/AuthService.java"
click node_jwt_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/JwtService.java"
click node_jwt_filter "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/JwtAuthenticationFilter.java"
click node_security "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/config/SecurityConfig.java"
click node_user_api "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserController.java"
click node_user_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserService.java"
click node_user_repo "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserRepository.java"
click node_account_api "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountController.java"
click node_account_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountService.java"
click node_account_repo "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountRepository.java"
click node_transaction_api "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionController.java"
click node_transaction_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionService.java"
click node_transaction_repo "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionRepository.java"
click node_category_api "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryController.java"
click node_category_service "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryService.java"
click node_category_repo "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryRepository.java"
click node_error_handler "https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/config/GlobalExceptionHandler.java"

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_controller,node_auth_service,node_jwt_service,node_jwt_filter,node_security,node_client toneBlue
class node_user_api,node_user_service,node_user_repo,node_database toneAmber
class node_account_api,node_account_service,node_account_repo toneMint
class node_transaction_api,node_transaction_service,node_transaction_repo toneRose
class node_category_api,node_category_service,node_category_repo toneIndigo
class node_error_handler toneTeal
```

## Components

### Identity and access

- [Auth API](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/AuthController.java): `src/main/java/com/hengthay/myapp/auth/AuthController.java`
- [Authentication](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/AuthService.java): `src/main/java/com/hengthay/myapp/auth/AuthService.java`
- [JWT service](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/JwtService.java): `src/main/java/com/hengthay/myapp/auth/JwtService.java`
- [JWT filter](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/auth/JwtAuthenticationFilter.java): `src/main/java/com/hengthay/myapp/auth/JwtAuthenticationFilter.java`
- [Security config](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/config/SecurityConfig.java): `src/main/java/com/hengthay/myapp/config/SecurityConfig.java`

### User management

- [User API](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserController.java): `src/main/java/com/hengthay/myapp/user/UserController.java`
- [User service](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserService.java): `src/main/java/com/hengthay/myapp/user/UserService.java`
- [User repository](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/user/UserRepository.java): `src/main/java/com/hengthay/myapp/user/UserRepository.java`

### Accounts

- [Account API](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountController.java): `src/main/java/com/hengthay/myapp/account/AccountController.java`
- [Account service](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountService.java): `src/main/java/com/hengthay/myapp/account/AccountService.java`
- [Account repository](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/account/AccountRepository.java): `src/main/java/com/hengthay/myapp/account/AccountRepository.java`

### Transactions

- [Transaction API](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionController.java): `src/main/java/com/hengthay/myapp/transaction/TransactionController.java`
- [Transaction service](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionService.java): `src/main/java/com/hengthay/myapp/transaction/TransactionService.java`
- [Transaction repository](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/transaction/TransactionRepository.java): `src/main/java/com/hengthay/myapp/transaction/TransactionRepository.java`

### Categories

- [Category API](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryController.java): `src/main/java/com/hengthay/myapp/category/CategoryController.java`
- [Category service](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryService.java): `src/main/java/com/hengthay/myapp/category/CategoryService.java`
- [Category repository](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/category/CategoryRepository.java): `src/main/java/com/hengthay/myapp/category/CategoryRepository.java`

### Other components

- **API client**
- **Relational database**
- [Error mapping](https://github.com/hengthay/expenses-tracker-api/blob/main/src/main/java/com/hengthay/myapp/config/GlobalExceptionHandler.java): `src/main/java/com/hengthay/myapp/config/GlobalExceptionHandler.java`

## Connections

- API client → Auth API: sends login
- API client → User API: manages users
- API client → Account API: manages accounts
- API client → Transaction API: records transactions
- API client → Category API: manages categories
- Auth API → Authentication: delegates auth (evidence: `src/main/java/com/hengthay/myapp/auth/AuthController.java`)
- Authentication → User repository: loads users (evidence: `src/main/java/com/hengthay/myapp/auth/AuthService.java`)
- Authentication → JWT service: issues tokens (evidence: `src/main/java/com/hengthay/myapp/auth/AuthService.java`)
- JWT filter → JWT service: validates tokens (evidence: `src/main/java/com/hengthay/myapp/auth/JwtAuthenticationFilter.java`)
- Security config → JWT filter: registers filter (evidence: `src/main/java/com/hengthay/myapp/config/SecurityConfig.java`)
- User API → User service: delegates users (evidence: `src/main/java/com/hengthay/myapp/user/UserController.java`)
- User service → User repository: persists users (evidence: `src/main/java/com/hengthay/myapp/user/UserService.java`)
- Account API → Account service: delegates accounts (evidence: `src/main/java/com/hengthay/myapp/account/AccountController.java`)
- Account service → Authentication: gets current user (evidence: `src/main/java/com/hengthay/myapp/account/AccountService.java`)
- Account service → Account repository: persists accounts (evidence: `src/main/java/com/hengthay/myapp/account/AccountService.java`)
- Transaction API → Transaction service: delegates transactions (evidence: `src/main/java/com/hengthay/myapp/transaction/TransactionController.java`)
- Transaction service → Authentication: gets current user (evidence: `src/main/java/com/hengthay/myapp/transaction/TransactionService.java`)
- Transaction service → Account repository: loads and updates account (evidence: `src/main/java/com/hengthay/myapp/transaction/TransactionService.java`)
- Transaction service → Category repository: loads category (evidence: `src/main/java/com/hengthay/myapp/transaction/TransactionService.java`)
- Transaction service → Transaction repository: persists transactions (evidence: `src/main/java/com/hengthay/myapp/transaction/TransactionService.java`)
- Category API → Category service: delegates categories (evidence: `src/main/java/com/hengthay/myapp/category/CategoryController.java`)
- Category service → Category repository: persists categories (evidence: `src/main/java/com/hengthay/myapp/category/CategoryService.java`)
- User repository → Relational database: reads and writes
- Account repository → Relational database: reads and writes
- Transaction repository → Relational database: reads and writes
- Category repository → Relational database: reads and writes
