# jbwittner/bankwiz_server architecture

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

- Interactive diagram: https://gitdiagram.com/jbwittner/bankwiz_server
- Repository: https://github.com/jbwittner/bankwiz_server

## Overview

##### Main Components
- Clients/External Consumers: Although not explicitly shown in the tree, consider your API consumers (mobile apps, web clients, or external systems) that make REST calls.
- API REST Layer (Infrastructure – API REST): This module handles HTTP request processing. It contains controllers (for bank accounts, currencies, users, etc.), DTOs, exception handling, and configuration (e.g., security and OpenAPI).
- Application Layer (Application Module): Contains the entry point (Application.java), configuration, and cross-cutting concerns like AOP (logging and transaction management). This layer orchestrates business operations.
- Domain Layer (Domain Module): Implements business logic. It holds core domain models, domain APIs, exceptions, and service definitions (interfaces, services) that enforce business rules.
- Persistence/Database Layer (Infrastructure – SPI JPA): Implements SPI interfaces using JPA to interact with the database. It houses entity mappings, repositories, and is responsible for persistence.

##### Interactions and Flows
- Requests start from external clients hitting the REST endpoints provided by the API REST module.
- Controllers receive the requests, perform necessary validations/conversions (using DTOs), and pass them to the Application Layer.
- The Application Layer then orchestrates the use case and delegates business logic to the Domain Layer.
- The Domain Layer, in turn, invokes SPI interfaces for persistence or external service calls. The SPI implementations are provided in the SPI JPA module, which communicates with the database.
- Responses flow back through the layers completing the cycle.

##### Architectural Patterns and Principles
- The project clearly follows a layered architecture (also apparent via the multi-module structure).
- Domain-Driven Design is evident, as the Domain module encapsulates the core business rules and models.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    subgraph "External Systems"
        Clients["Clients/External Systems"]:::client
    end

    %% API REST Layer
    subgraph "API REST Layer"
        RestControllers["REST Controllers (e.g., BankAccountController, CurrencyController)"]:::controller
    end

    %% Application Layer
    subgraph "Application Layer"
        AppLayer["Application Layer\n(Application.java, AOP & configuration)"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DomainLayer["Domain Layer\n(Business models, services, exceptions)"]:::domain
    end

    %% Persistence/Database Layer
    subgraph "Persistence Layer"
        Persistence["Persistence/Database (SPI JPA)"]:::persistence
    end

    %% Flow of Requests
    Clients -->|"HTTPRequest"| RestControllers
    RestControllers -->|"Validates/ConvertsDTO"| AppLayer
    AppLayer -->|"OrchestratesLogic"| DomainLayer
    DomainLayer -->|"PersistsData"| Persistence
    Persistence -->|"ReturnsData"| DomainLayer
    DomainLayer -->|"ResponseData"| AppLayer
    AppLayer -->|"ResponseData"| RestControllers
    RestControllers -->|"HTTPResponse"| Clients

    %% Click Events
    click RestControllers "https://github.com/jbwittner/bankwiz_server/tree/develop/infrastructure/api-rest"
    click AppLayer "https://github.com/jbwittner/bankwiz_server/tree/develop/application/src/main/java/fr/bankwiz/server/application"
    click DomainLayer "https://github.com/jbwittner/bankwiz_server/tree/develop/domain/src/main/java/fr/bankwiz/server/domain"
    click Persistence "https://github.com/jbwittner/bankwiz_server/tree/develop/infrastructure/spi-jpa"

    %% Styles
    classDef client fill:#fef2cc,stroke:#d6a500,stroke-width:2px;
    classDef controller fill:#d1e8ff,stroke:#0066cc,stroke-width:2px;
    classDef application fill:#d6e9c6,stroke:#5cb85c,stroke-width:2px;
    classDef domain fill:#fde2e4,stroke:#d63384,stroke-width:2px;
    classDef persistence fill:#cce5ff,stroke:#007bff,stroke-width:2px;
```
