# moinbasha-shaik/spring-security architecture

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

- Interactive diagram: https://gitdiagram.com/moinbasha-shaik/spring-security
- Repository: https://github.com/moinbasha-shaik/spring-security

## Overview

##### Main Components
- Entry Point & Core Application – Represent the RoleBasedAccessControlSystemApplication as the starting point of the application.
- Security Configuration – Include the SecurityConfig class that sets up Spring Security, and the JwtAuthFilter which handles JWT-based authentication.
- Controllers – Create separate nodes for AuthController, AdminController, ApplicantController, OAuth2Controller, and RecruiterController. These represent the web layer that accepts and responds to HTTP requests.
- Service Layer – Highlight CustomUserDetailsService and JwtService as the components handling business logic (authentication, user details retrieval, and JWT management).
- Data Access Layer – Identify the repositories: RoleRepository and UserRepository, along with entity classes like Role and User, which manage persistence and domain data.
- DTOs – Show the DTOs (AuthRequest, AuthResponse, SignupRequest) that are used for transferring data between the client and server during authentication and registration.

##### Relationships & Interactions
- Link the Service layer to the Data Access Layer (repositories) to indicate data persistence.
- Optionally, indicate how DTOs move between the controller and service layers, representing the data transfer in API calls.

##### Architectural Patterns & Design Principles
- Layered Architecture – Showcase the separation between the presentation layer (Controllers), business logic layer (Services), and persistence layer (Repositories/Entities).
- Security/Authentication Pipeline – Emphasize the role of the JWT filter in the security chain and the integration with Spring Security configurations.

##### Keep It Detailed but Structured
- Don’t be afraid to break down the system into as many components as possible; accuracy is more important.
- That security (Spring Security, JWT) is prominently featured, given the importance in this role-based access control system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["RoleBasedAccessControlSystemApplication"]:::entry

    subgraph "Security Configuration"
        SC["SecurityConfig"]:::configuration
        JAF["JwtAuthFilter"]:::configuration
    end

    subgraph "Controllers"
        AC["AuthController"]:::controller
        ADC["AdminController"]:::controller
        APC["ApplicantController"]:::controller
        OAC["OAuth2Controller"]:::controller
        RC["RecruiterController"]:::controller
    end

    subgraph "Service Layer"
        CUDS["CustomUserDetailsService"]:::service
        JS["JwtService"]:::service
    end

    subgraph "Data Access Layer"
        RR["RoleRepository"]:::repository
        UR["UserRepository"]:::repository
        RE["Role Entity"]:::repository
        UE["User Entity"]:::repository
    end

    subgraph "DTOs"
        AR["AuthRequest"]:::dto
        ARes["AuthResponse"]:::dto
        SR["SignupRequest"]:::dto
    end

    %% Application Entry Point linking to Controllers
    A --> AC
    A --> ADC
    A --> APC
    A --> OAC
    A --> RC

    %% Security layer intercepts controller calls
    AC ---|"intercepts"| JAF
    ADC ---|"intercepts"| JAF
    APC ---|"intercepts"| JAF
    OAC ---|"intercepts"| JAF
    RC ---|"intercepts"| JAF

    %% Controllers call Service Layer components
    AC -->|"calls"| JS
    ADC -->|"calls"| CUDS
    APC -->|"calls"| CUDS
    OAC -->|"calls"| CUDS
    RC -->|"calls"| CUDS

    %% DTO interactions with AuthController and JwtService
    AC -->|"receives"| AR
    AC -->|"receives"| SR
    JS -->|"returns"| ARes

    %% Service Layer interacts with Data Access Layer
    CUDS -->|"queries"| UR
    JS -->|"queries"| UR
    JS -->|"queries"| RR

    %% Repositories manage Entities
    RR -->|"manages"| RE
    UR -->|"manages"| UE

    %% Click Events
    click A "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/RoleBasedAccessControlSystemApplication.java"
    click SC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/config/SecurityConfig.java"
    click JAF "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/config/JwtAuthFilter.java"
    click AC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/controller/AuthController.java"
    click ADC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/controller/AdminController.java"
    click APC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/controller/ApplicantController.java"
    click OAC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/controller/OAuth2Controller.java"
    click RC "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/controller/RecruiterController.java"
    click CUDS "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/service/CustomUserDetailsService.java"
    click JS "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/service/JwtService.java"
    click RR "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/repo/RoleRepository.java"
    click UR "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/repo/UserRepository.java"
    click RE "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/entity/Role.java"
    click UE "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/entity/User.java"
    click AR "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/dto/AuthRequest.java"
    click ARes "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/dto/AuthResponse.java"
    click SR "https://github.com/moinbasha-shaik/spring-security/blob/main/src/main/java/in/basha/dto/SignupRequest.java"

    %% Style Definitions
    classDef entry fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef configuration fill:#ffe6cc,stroke:#333,stroke-width:2px;
    classDef controller fill:#ccf2ff,stroke:#333,stroke-width:2px;
    classDef service fill:#d1ffd1,stroke:#333,stroke-width:2px;
    classDef repository fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef dto fill:#e6e6fa,stroke:#333,stroke-width:2px;
```
