# caa900nbb-projectx/loginservice_found_it_backend architecture

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

- Interactive diagram: https://gitdiagram.com/caa900nbb-projectx/loginservice_found_it_backend
- Repository: https://github.com/caa900nbb-projectx/loginservice_found_it_backend

## Overview

##### Main Components
- Frontend/API Exposure: Although there isn’t a dedicated frontend, external clients (e.g., Postman, other UI apps) interact with the service via exposed REST endpoints.
- Web Layer: Represent the two controllers – the AuthenticationController and UserController – which handle login, registration, and user queries.
- Service Layer: Include AuthenticationService, UserService, EmailService, JwtService, and LogoutService. These provide business logic, email verification tasks, token generation, and security handling.
- Data Access Layer: Indicate the repository interfaces ITokenRepository and IUserRepository that interact with the data model.
- Domain/Model Layer: Illustrate the User and Token models, as well as DTO classes (LoginUserDto, RegisterUserDto, etc.) that are used for data exchange.
- Core Configuration & Security: Detail classes such as ApplicationConfiguration, EmailConfiguration, SecurityConfiguration, and JwtAuthenticationFilter – these handle the security setup, JWT filtering, and application environment settings.
- External Components:
- Database – PostgreSQL, as set up per the README.
- External Email Service – Configured via the provided EmailConfiguration with support for Gmail app passwords.

- That controllers delegate tasks to the Service Layer.
- Service Layer interacting with repositories to perform CRUD operations on the database.

##### Architectural Patterns
- Layered Architecture: Clearly separate controllers (presentation), services (business logic), and repositories (data access).
- Security and JWT: Emphasize the integration of a JwtAuthenticationFilter along with SecurityConfiguration, showing use of JWT for stateless authentication.
- Dependency Injection: Reflect how Spring Boot’s configuration classes (ApplicationConfiguration, EmailConfiguration) provide centralized management of dependencies.

##### Relevant Technologies
- Java (via Oracle Java SDK 23)
- Spring Boot (including Security and Web libraries)
- Gradle Build System (building and dependency management)
- Docker (Dockerfile and docker-compose for containerization, even if containerization is to be developed further)
- PostgreSQL (for persistence)
- SMTP Email Services (for sending verification emails)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Client["Client (Postman)"]:::client
    end

    %% Web Layer (Controllers)
    subgraph "Web Layer (Controllers)"
        AC["AuthenticationController"]:::controller
        UC["UserController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        AS["AuthenticationService"]:::service
        US["UserService"]:::service
        ES["EmailService"]:::service
        JS["JwtService"]:::service
        LS["LogoutService"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        IUR["IUserRepository"]:::repository
        ITR["ITokenRepository"]:::repository
    end

    %% Domain/Model Layer
    subgraph "Domain/Model Layer"
        UM["User Model"]:::model
        TM["Token Model"]:::model
        DTO["DTO Classes"]:::model
    end

    %% Core Configuration & Security
    subgraph "Core Configuration & Security"
        ACfg["ApplicationConfiguration"]:::config
        ECfg["EmailConfiguration"]:::config
        SCfg["SecurityConfiguration"]:::config
        JAF["JwtAuthenticationFilter"]:::config
    end

    %% External Components
    subgraph "External Components"
        DB["PostgreSQL Database"]:::external
        SMTP["SMTP Email Service"]:::external
        DS["Docker Setup"]:::external
        AP["Application Properties"]:::external
    end

    %% Relationships
    Client -->|"HTTP_Request"| AC
    Client -->|"HTTP_Request"| UC

    AC -->|"delegates"| AS
    UC -->|"delegates"| US
    AC -->|"delegates"| LS

    AS -->|"calls"| IUR
    AS -->|"calls"| ITR
    US -->|"calls"| IUR
    AS -->|"uses"| JS
    ES -->|"sends"| SMTP

    IUR -->|"CRUD"| DB
    ITR -->|"CRUD"| DB

    %% Configuration Influence
    SCfg -->|"configures"| JAF
    AC ---|"secured_by"| JAF
    UC ---|"secured_by"| JAF
    AS ---|"configured_by"| ACfg
    US ---|"configured_by"| ACfg
    ES ---|"configured_by"| ECfg

    %% External Setup
    AP ---|"provides"| DS

    %% Click Events
    click AC "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/controllers/AthenticationController.java"
    click UC "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/controllers/UserController.java"
    click AS "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/service/AuthenticationService.java"
    click US "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/service/UserService.java"
    click ES "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/service/EmailService.java"
    click JS "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/service/JwtService.java"
    click LS "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/service/LogoutService.java"
    click IUR "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/repository/IUserRepository.java"
    click ITR "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/repository/ITokenRepository.java"
    click UM "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/model/User.java"
    click TM "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/model/Token.java"
    click DTO "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/tree/main/src/main/java/com/projectx/foundit/dto"
    click ACfg "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/core/ApplicationConfiguration.java"
    click ECfg "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/core/EmailConfiguration.java"
    click SCfg "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/core/SecurityConfiguration.java"
    click JAF "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/java/com/projectx/foundit/core/JwtAuthenticationFilter.java"
    click DS "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/tree/main/docker-service"
    click AP "https://github.com/caa900nbb-projectx/loginservice_found_it_backend/blob/main/src/main/resources/application.properties"

    %% Styles
    classDef client fill:#E74C3C,stroke:#000,stroke-width:1px;
    classDef controller fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef service fill:#A9DFBF,stroke:#000,stroke-width:1px;
    classDef repository fill:#F9E79F,stroke:#000,stroke-width:1px;
    classDef model fill:#F5CBA7,stroke:#000,stroke-width:1px;
    classDef config fill:#D7BDE2,stroke:#000,stroke-width:1px;
    classDef external fill:#FAD7A0,stroke:#000,stroke-width:1px;
```
