# alexandrelefay/arosaje-backend architecture

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

- Interactive diagram: https://gitdiagram.com/alexandrelefay/arosaje-backend
- Repository: https://github.com/alexandrelefay/arosaje-backend

## Overview

##### Project Type and Purpose
- This is a backend application built with Spring Boot. Its purpose is to expose RESTful endpoints to manage various resources (users, tickets, messages, plants, guardianship, etc.) while implementing security (JWT-based) and API documentation (Swagger).
- The README also mentions deployment options (local run, Docker containerization, and Render deployment). Although there is no dedicated frontend folder, the API is designed to support a web client.

##### And Conceptualize the File Structure
- The core logic resides in the src/main/java directory, structured into packages representing configuration, controllers, entities, DTOs, mappers, exceptions, handlers, repositories, security, and service.
- Key layers are:
- Controllers: REST endpoints (e.g., LoginController, MessageController) received by the application.
- Entities & DTOs: Object models and data transfer objects for domain data.
- Mappers: Used for mapping entity objects to/from DTOs.
- Services: Business logic (e.g., UserService, FacultyService for plants, guardianship etc.).
- Repositories: Database access layer.
- Security: Custom configurations for JWT, user details service, and security filters.
- Configurations: Swagger, WebSocket, etc.
- Exception Handlers: Manage business exceptions and error handling.
- Additionally, the project includes Dockerfile, docker-compose.yml, Maven scripts (pom.xml, mvnw), and CI/CD workflows under GitHub actions which hint at both containerized and automated deployment.

a. Main Components:
- Client(s) / API Consumer – external entities (e.g., web client, mobile app) that send HTTP requests.
- API Gateway / Entry Point – the Spring Boot application acting as the main interface.
- REST Controllers – each controller (Login, Message, Photo, etc.) exposing endpoints.
- Service Layer – encapsulated business logic for processing requests.
- Data Access / Repository Layer – interacting with the underlying database (configured via application.properties).
- Security Module – JWT-based login, token management, CustomUserDetails, and SecurityConfig.
- Additional Infrastructure – WebSocket handlers for real-time communication and Swagger configuration for API documentation.
- External Deployments – Docker containers (illustrated with a Docker node and Render environment) and Maven build process.

b. Relationships and Data Flow:
- Interaction between Security components and controllers for authentication and authorization.
- Communication between WebSocket configuration/handlers and the controllers if real-time features are used.

c. Architectural Patterns and Technologies:
- That the project follows a layered (or N-tier) architecture with clear separation for Controllers, Services, and Repositories.
- Use of Spring Boot with its embedded container for rapid development.
- Integration of Swagger (documentation), JWT (security), and WebSocket (real-time communications).
- Also, mention Maven for dependency management and Docker for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["Client / API Consumer"]:::external

    App["API Gateway: Arosaje Application"]:::app
    Client -->|"HTTP_Request"| App
    click App "https://github.com/alexandrelefay/arosaje-backend/blob/master/src/main/java/fr/epsi/mspr/arosaje/ArosajeApplication.java"

    %% REST Controllers Subgraph
    subgraph "REST Controllers"
        Controllers["REST Controllers"]:::controller
        Login["LoginController"]:::controller
        Message["MessageController"]:::controller
        Photo["PhotoController"]:::controller
        Plant["PlantController"]:::controller
        Ticket["TicketController"]:::controller
        TicketComment["TicketCommentController"]:::controller
        User["UserController"]:::controller
        Guardianship["GuardianshipController"]:::controller
        %% Group details (visually connected)
        Login --- Controllers
        Message --- Controllers
        Photo --- Controllers
        Plant --- Controllers
        Ticket --- Controllers
        TicketComment --- Controllers
        User --- Controllers
        Guardianship --- Controllers
    end
    App -->|"routes_API"| Controllers
    click Controllers "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/controller/"

    %% Service Layer Subgraph
    subgraph "Service Layer"
        Services["Service Layer"]:::service
    end
    Controllers -->|"calls_service"| Services
    click Services "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/service/"

    %% Repository Layer Subgraph
    subgraph "Repository Layer"
        Repos["Repository Layer"]:::repository
        DB["Database"]:::database
    end
    Services -->|"performs_C_R_U_D"| Repos
    Repos -->|"DB_interaction"| DB
    click Repos "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/repository/"

    %% Security Module
    subgraph "Security Module"
        Security["Security Module (JWT, Filters)"]:::security
    end
    App -->|"secured_by"| Security
    Controllers -->|"JWT_auth"| Security
    click Security "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/security/"

    %% Data Transformation Subgraph (DTOs and Mappers)
    subgraph "Data Transformation"
        DTOs["DTOs"]:::dto
        Mappers["Mappers"]:::mapper
    end
    Controllers -->|"data_in"| DTOs
    DTOs -->|"maps_to"| Mappers
    Mappers -->|"business_objects_to"| Services
    click DTOs "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/entity/dto/"
    click Mappers "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/entity/mapper/"

    %% Configurations Subgraph
    subgraph "Configurations"
        Configs["Configurations (Swagger, WebSocket)"]:::config
    end
    App -->|"api_docs_WS"| Configs
    click Configs "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/config/"

    %% Exception Handling Subgraph
    subgraph "Exception Handling"
        Exceptions["Exception Definitions"]:::exception
        Handlers["WebSocket Handlers"]:::handler
    end
    Controllers -->|"error_handling"| Exceptions
    Configs -->|"real_time_comm"| Handlers
    click Exceptions "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/exception/"
    click Handlers "https://github.com/alexandrelefay/arosaje-backend/tree/master/src/main/java/fr/epsi/mspr/arosaje/handler/"

    %% Deployment & CI/CD Subgraph
    subgraph "Deployment & CI/CD"
        Build["Build & Dependency Management"]:::deployment
        Container["Containerization & Deployment"]:::deployment
        CICD["CI/CD Workflows"]:::deployment
    end
    Build -->|"builds_app"| App
    Container -->|"containerizes_app"| App
    CICD -->|"deploys_app"| App
    click Build "https://github.com/alexandrelefay/arosaje-backend/blob/master/pom.xml"
    click Container "https://github.com/alexandrelefay/arosaje-backend/tree/master/Dockerfile"
    click CICD "https://github.com/alexandrelefay/arosaje-backend/blob/master/.github/workflows/pipeline.yml"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef app fill:#bbf,stroke:#333,stroke-width:2px;
    classDef controller fill:#cff,stroke:#333,stroke-width:2px;
    classDef service fill:#fcf,stroke:#333,stroke-width:2px;
    classDef repository fill:#cfc,stroke:#333,stroke-width:2px;
    classDef database fill:#ff9,stroke:#333,stroke-width:2px;
    classDef security fill:#faa,stroke:#333,stroke-width:2px;
    classDef dto fill:#afa,stroke:#333,stroke-width:2px;
    classDef mapper fill:#aaf,stroke:#333,stroke-width:2px;
    classDef config fill:#ffd,stroke:#333,stroke-width:2px;
    classDef exception fill:#fdd,stroke:#333,stroke-width:2px;
    classDef handler fill:#dfd,stroke:#333,stroke-width:2px;
    classDef deployment fill:#ddd,stroke:#333,stroke-width:2px;
```
