# valarchie/agileboot-back-end architecture

> Architecture diagram of the GitHub repository valarchie/agileboot-back-end, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valarchie/agileboot-back-end
- Repository: https://github.com/valarchie/agileboot-back-end

## Overview

##### Main Components
- AgileBoot-Admin – This module provides the backend management interface (admin API) for system operations such as user, department, and role management.
- AgileBoot-API – This module exposes public APIs (open interfaces) to clients (e.g., mobile or external services).
- AgileBoot-Domain – The heart of the business logic. It is organized using CQRS and DDD concepts, separating command (update operations) and query (read operations) flows. It encapsulates the core domain models, factories, commands, queries, and application services.
- AgileBoot-Common – Contains common utilities, core base classes, exception handling, and constants shared across modules.
- AgileBoot-Infrastructure – Focuses on system configuration and integration concerns (security, caching, exception handling, thread management, logging, MyBatis integration, etc.).

##### External Systems and Dependencies
- Database (MySQL) – the primary persistent storage backend.
- Redis – used for caching (with multi-tier caching strategies: Map, Guava, and Redis) and distributed session management via JWT.
- Additional components such as H2 (for testing/embedded mode), external authentication systems, and even containerized deployment (docker references).

##### Out Relationships and Data Flow
- Frontend Client (separate Vue3 project) communicates with the AgileBoot-Admin and AgileBoot-API modules (likely via REST APIs secured with JWT).
- Within the admin module, incoming HTTP requests (from the admin portal) pass through controllers. They then flow into the application service layer (residing mostly in the agileboot-domain module) to separate query and command paths:
– Query flows: Controller → Query DTO/Model → Application Service → Domain Service → Mapper (DB access)
– Command flows: Controller → Command DTO/Model → Application Service → Domain Model (business logic) → Persistence (save/update via MyBatis/JPA)
- AgileBoot-Common provides base classes and shared utilities (error codes, common exceptions, and DTOs) used across the other modules.
- AgileBoot-Infrastructure connects with external dependencies (configurations for Redis, MySQL, security filters such as JwtAuthenticationTokenFilter, rate limiting aspects, caching aspects, etc.) and even supports integration tests and embedded database modes.

##### Architectural Patterns and Design Principles
- CQRS: Clearly distinguish between query and command operations as explained in the README.
- Domain-Driven Design: The Domain layer uses domain models, factories, and application services that encapsulate business logic.
- Layered Architecture: Different modules are organized by concerns – presentation (controllers), application (service layers), domain (business logic), and infrastructure (configuration/integration).
- Separation of Concerns: Each module (admin, API, common, domain, infrastructure) is responsible for a clear-cut part of the business workflow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    FNC("Frontend Client (Vue3)"):::external

    %% Main Module Nodes
    AADMIN("AgileBoot-Admin"):::module
    AAPI("AgileBoot-API"):::module
    ADOMAIN("AgileBoot-Domain"):::module
    ACOMMON("AgileBoot-Common"):::module
    AINFRA("AgileBoot-Infrastructure"):::module

    %% External Databases
    MSQL("MySQL Database"):::database
    REDIS("Redis Cache"):::database

    %% Connect Frontend to Modules
    FNC --> AADMIN
    FNC --> AAPI

    %% AgileBoot-Admin Details
    subgraph "AgileBoot-Admin Details"
        AADMIN1("Admin Controller"):::controller
        AADMIN2("JwtAuthenticationTokenFilter"):::security
        AADMIN3("Admin Application Service"):::service
    end
    AADMIN --> AADMIN1
    AADMIN1 -->|"passesThrough"| AADMIN2
    AADMIN2 -->|"invokes"| AADMIN3

    %% AgileBoot-API Details
    subgraph "AgileBoot-API Details"
        AAPI1("API Controller"):::controller
    end
    AAPI --> AAPI1

    %% AgileBoot-Domain Details
    subgraph "AgileBoot-Domain Details"
        ADomain1("Command Flow Handler"):::domain
        ADomain2("Query Flow Handler"):::domain
        ADomain3("Mapper (DB Access)"):::domain
    end
    %% Flow from Admin and API to Domain Layer (CQRS separation)
    AADMIN3 -->|"handlesCommand"| ADomain1
    AADMIN3 -->|"handlesQuery"| ADomain2
    AAPI1   -->|"invokesQuery"| ADomain2
    ADomain1 --> ADomain3
    ADomain2 --> ADomain3
    ADomain3 -->|"accesses"| MSQL

    %% AgileBoot-Infrastructure Details
    subgraph "AgileBoot-Infrastructure Details"
        AInfra1("Security Configurations"):::infra
        AInfra2("Caching & Logging"):::infra
    end
    %% Link Infrastructure to security component in Admin
    AInfra1 -->|"configures"| AADMIN2
    AInfra2 -->|"supports"| REDIS

    %% Shared Utilities (Common)
    AADMIN3 -.->|"uses"| ACOMMON
    AAPI1   -.->|"uses"| ACOMMON

    %% Module relationships with Domain and Infrastructure
    AADMIN3 -->|"reliesOn"| ADOMAIN
    AAPI1   -->|"reliesOn"| ADOMAIN
    AINFRA -->|"supports"| AADMIN
    AINFRA -->|"supports"| AAPI

    %% Click Events for Component Mapping
    click AADMIN "https://github.com/valarchie/agileboot-back-end/tree/main/agileboot-admin"
    click AAPI "https://github.com/valarchie/agileboot-back-end/tree/main/agileboot-api"
    click ADOMAIN "https://github.com/valarchie/agileboot-back-end/tree/main/agileboot-domain"
    click ACOMMON "https://github.com/valarchie/agileboot-back-end/tree/main/agileboot-common"
    click AINFRA "https://github.com/valarchie/agileboot-back-end/tree/main/agileboot-infrastructure"

    %% Styles
    classDef external fill:#bbf,stroke:#333,stroke-width:2px;
    classDef module fill:#f9e79f,stroke:#e67e22,stroke-width:2px;
    classDef controller fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef security fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef service fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef domain fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef infra fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef database fill:#f7dc6f,stroke:#f1c40f,stroke-width:2px;
```
