# spring-boot-framework/financial-java-api architecture

> Architecture diagram of the GitHub repository spring-boot-framework/financial-java-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spring-boot-framework/financial-java-api
- Repository: https://github.com/spring-boot-framework/financial-java-api

## Overview

##### Project Type and Purpose
- This is a RESTful API built with Java and Spring Boot meant for managing financial transactions. It exposes endpoints to create, update, delete, and query transactions and generate statistics.
- The API is structured to support HTTP endpoints, integrate with a PostgreSQL database (and H2 for testing), and features capabilities like rate limiting, caching, and automatic database migration with Flyway.

##### File Structure to Identify Main Components
- Source Code Separation: The project follows a standard layered architecture with clear packages:
- Controllers (located under controller/v1) for handling HTTP requests.
- DTOs and Response objects for data exchange.
- Exception handling in its own package.
- Domain Models and Enumerations (model and model/enumeration) representing business entities.
- Repositories (repository package) for database access.
- Services implementing business logic (service packages, with implementations in their respective “impl” subdirectories). Notice there are specialized services such as rate-limiting, statistic, and transaction services.
- Utilities and Configuration classes that set up EhCache, Swagger, RateLimiting, and more.
- Testing: There are distinct directories for unit tests (src/test) and integration tests (src/it) that validate the API functionality.
- Infrastructure/Deployment: Files like pom.xml, Procfile, and system.properties indicate Maven usage, Heroku deployment support, and continuous integration (via Travis CI).

##### Final Recommendations
- Make the labels as clear as possible – for instance, “TransactionController (handles POST, PUT, DELETE & GET endpoints for transactions)”, “TransactionService (business logic)”, etc.
- That you include both the normal operational flow and integration test boundaries where applicable.
- Notes or legends for abbreviations (like “DTO”, “API”, etc.) and specify which environment settings (dev with PostgreSQL vs. test using H2) where relevant.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client"
        Client("Client"):::external
    end

    %% API Gateway / Controller Layer
    subgraph "API Gateway / Controller Layer"
        TransactionCtrl("TransactionController (handles transactions)"):::controller
        StatisticCtrl("StatisticController (handles statistics)"):::controller
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        RateLimitInter("RateLimitInterceptor"):::config
        SwaggerConfig("SwaggerConfiguration"):::config
        CacheConfig("CacheConfiguration"):::config
        OtherConfigs("FinancialApiConfiguration, PageableConfiguration, RateLimitingConfiguration"):::config
        Utilities("Utilities (BigDecimalConverter, CacheEventLogger, FinancialApiUtil, LocalDateTimeConverter)"):::config
    end

    %% Service Layer
    subgraph "Service Layer"
        TransactionSvc("TransactionService"):::service
        TransactionSvcImpl("TransactionServiceImpl"):::service
        StatisticSvc("StatisticService"):::service
        StatisticSvcImpl("StatisticServiceImpl"):::service
        RateLimitingSvc("APIUsagePlansService"):::service
        RateLimitingSvcImpl("APIUsagePlansServiceImpl"):::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        TransactionRepo("TransactionRepository"):::repository
        StatisticRepo("StatisticRepository"):::repository
    end

    %% Domain Model & DTO Layer
    subgraph "Domain Model & DTO"
        TransactionModel("Transaction (Domain Model)"):::domain
        StatisticModel("Statistic (Domain Model)"):::domain
        TransactionDTO("TransactionDTO"):::domain
        StatisticDTO("StatisticDTO"):::domain
        Response("Response Object"):::domain
        ResponseError("ResponseError Object"):::domain
    end

    %% Exception Handling
    subgraph "Exception Handling"
        ExceptionHandler("FinancialJavaAPIExceptionHandler"):::exception
    end

    %% External Dependencies & Infrastructure
    subgraph "External Dependencies & Infrastructure"
        Flyway("Flyway Migration"):::external
        EhCache("EhCache Configuration"):::external
        AppProps("Application Properties (dev, prod, test)"):::external
        BuildFiles("Build & Deployment Files (pom.xml, Procfile, system.properties)"):::external
        DB("PostgreSQL Database"):::external
    end

    %% Testing
    subgraph "Testing"
        IntegrationTests("Integration Tests"):::testing
        UnitTests("Unit Tests"):::testing
    end

    %% Relationships
    Client -->|"sends request"| TransactionCtrl
    Client -->|"sends request"| StatisticCtrl

    TransactionCtrl -->|"request"| RateLimitInter
    StatisticCtrl -->|"request"| RateLimitInter

    RateLimitInter -->|"allows"| TransactionSvc
    RateLimitInter -->|"allows"| StatisticSvc
    RateLimitInter -->|"leverages"| RateLimitingSvc

    TransactionSvc -->|"delegates"| TransactionSvcImpl
    StatisticSvc -->|"delegates"| StatisticSvcImpl
    RateLimitingSvc -->|"delegates"| RateLimitingSvcImpl

    TransactionSvcImpl -->|"calls"| TransactionRepo
    StatisticSvcImpl -->|"calls"| StatisticRepo

    TransactionRepo -->|"queries"| DB
    StatisticRepo -->|"queries"| DB

    %% Integration of Domain Models & DTOs with Services
    TransactionSvcImpl -->|"maps to"| TransactionModel
    StatisticSvcImpl -->|"maps to"| StatisticModel
    TransactionCtrl -->|"converts with"| TransactionDTO
    StatisticCtrl -->|"converts with"| StatisticDTO
    TransactionCtrl -->|"wraps in"| Response
    StatisticCtrl -->|"wraps in"| Response

    %% Exception Handling
    TransactionSvcImpl -.->|"triggers"| ExceptionHandler
    StatisticSvcImpl -.->|"triggers"| ExceptionHandler

    %% Configurations supporting Controllers and Services
    SwaggerConfig ---|"providesDocs"| TransactionCtrl
    SwaggerConfig ---|"providesDocs"| StatisticCtrl
    CacheConfig ---|"appliesCaching"| TransactionSvcImpl
    CacheConfig ---|"appliesCaching"| StatisticSvcImpl
    OtherConfigs ---|"configures"| TransactionSvcImpl
    OtherConfigs ---|"configures"| StatisticSvcImpl

    AppProps ---|"configures"| TransactionSvcImpl
    AppProps ---|"configures"| StatisticSvcImpl

    %% Testing connections
    IntegrationTests ---|"validates"| TransactionCtrl
    IntegrationTests ---|"validates"| StatisticCtrl
    UnitTests ---|"tests"| TransactionSvcImpl
    UnitTests ---|"tests"| StatisticSvcImpl

    %% Click Events
    click TransactionCtrl "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/transaction/TransactionController.java"
    click StatisticCtrl "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/controller/v1/statistic/StatisticController.java"
    
    click TransactionSvc "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/TransactionService.java"
    click TransactionSvcImpl "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/transaction/impl/TransactionServiceImpl.java"
    click StatisticSvc "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/StatisticService.java"
    click StatisticSvcImpl "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/statistic/impl/StatisticServiceImpl.java"
    click RateLimitingSvc "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/APIUsagePlansService.java"
    click RateLimitingSvcImpl "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/service/ratelimiting/impl/APIUsagePlansServiceImpl.java"

    click TransactionRepo "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/transaction/TransactionRepository.java"
    click StatisticRepo "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/repository/statistic/StatisticRepository.java"

    click TransactionModel "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/model/transaction/Transaction.java"
    click StatisticModel "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/model/statistic/Statistic.java"
    click TransactionDTO "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/dto/model/transaction/TransactionDTO.java"
    click StatisticDTO "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/dto/model/statistic/StatisticDTO.java"
    click Response "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/dto/response/Response.java"
    click ResponseError "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/dto/response/ResponseError.java"

    click ExceptionHandler "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/exception/FinancialJavaAPIExceptionHandler.java"

    click SwaggerConfig "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/util/config/SwaggerConfiguration.java"
    click CacheConfig "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/util/config/CacheConfiguration.java"
    click OtherConfigs "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/util/config/FinancialApiConfiguration.java"
    click RateLimitInter "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/java/io/github/mariazevedo88/financialjavaapi/util/interceptor/RateLimitInterceptor.java"

    click Flyway "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/resources/db/migration/V1__init.sql"
    click EhCache "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/resources/cache/ehcache.xml"
    click AppProps "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/main/resources/application.properties"
    click BuildFiles "https://github.com/spring-boot-framework/financial-java-api/blob/master/pom.xml"
    
    click IntegrationTests "https://github.com/spring-boot-framework/financial-java-api/blob/master/src/it/java/io/github/mariazevedo88/financialjavaapi/it/FinancialJavaApiIntegrationTest.java"
    click UnitTests "https://github.com/spring-boot-framework/financial-java-api/tree/master/src/test/java/io/github/mariazevedo88/financialjavaapi/test/"

    %% Styles
    classDef controller fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef service fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef repository fill:#ffc0cb,stroke:#333,stroke-width:2px;
    classDef domain fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef config fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef testing fill:#f5deb3,stroke:#333,stroke-width:2px;
    classDef exception fill:#ffb6c1,stroke:#333,stroke-width:2px;
```
