# jumpering/fanaticupsback architecture

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

- Interactive diagram: https://gitdiagram.com/jumpering/fanaticupsback
- Repository: https://github.com/jumpering/fanaticupsback

## Overview

##### Project Type and Purpose
- This is a backend service engineered with Java. It’s built with Maven (as indicated by the pom.xml, mvnw files, and the .mvn folder) and appears to be using Spring Boot.
- The project is structured as a REST API back end, evident from multiple controllers (AuthController, CategoryController, ChatController, CupController, UserController) that expose endpoints for operations likely related to user management, chatting, category handling, and cup management.
- It also includes a dedicated security package (with configuration, filters, models, and services for JWT authentication), indicating a focus on securing API endpoints.
- There’s a MinioService present, which suggests integration with an external object storage service.

##### Analyzing the File Structure
- Top-level directories like src/main/java indicate all Java source files. Under org.fanaticups.fanaticupsBack, several sub-packages denote classic layers:
- controllers: for handling incoming HTTP requests.
- services: for implementing business logic.
- dao (and further entities and repositories): for data persistence, likely interfacing with a relational database.
- security: containing configurations, filters, and JWT handling.
- models: for data transfer objects (DTOs) that represent the request/response payloads.
- utils: for utility classes (e.g., FileComparator).
- The src/main/resources directory contains configuration properties for different environments (development, production), suggesting environment-specific configurations.
- The presence of Dockerfile hints at containerization support for deployment.

a. Main Components:
- Entry Point: The application is bootstrapped by FanaticupsBackEndApplication.java.
- API Controllers: Represented by various controllers (e.g., AuthController, ChatController). They handle HTTP requests and route them to appropriate services.
- Business Logic Layer: The services (CategoryService, ChatService, CupService, MessageService, MinioService, UserService) encapsulate business logic.
- Data Access Layer: The DAO components with entities (e.g., CategoryEntity, ChatEntity) and repositories (CategoryRepository, ChatRepository, etc.) handle interaction with the database.
- Security Module: Includes configuration (WebSecurityConfig, CorsConfig), filters (JWTAuthenticationFilter), and supporting models/services for authentication and authorization.
- External Services: Integration points like Minio for object storage and presumably a database (implied by the use of JPA repositories).
- Configuration & Environment Properties: Manage different runtime configurations (application-development.properties, application-production.properties).

b. Relationships and Interactions:
- HTTP Request Flow: Clients initiate HTTP requests that are routed to the corresponding Controller.
- Each Controller interacts with one or more Services to perform business operations.
- Services then communicate with DAO/Repository layers to persist or retrieve data.
- Security components intercept and validate requests, ensuring secure access before the controllers are reached.

c. Architectural Patterns and Design Principles:
- Layered architecture: Presentation (Controller), Business (Service), and Data (Repository/DAO).
- Separation of concerns with modular packages.
- Security is integrated as a cross-cutting concern via filters and configuration.
- Use of DTOs (Data Transfer Objects) to decouple external representations from internal entities.
- Containerization hint via the Dockerfile suggests that deployment is container-based.

d. Relevant Technologies, Frameworks, and Libraries:
- Java & Maven as the primary technology stack.
- Spring Boot framework (implied by the folder and package structure).
- Spring Security for authentication/authorization.
- JPA/Hibernate for ORM (implied by repositories and entity classes).
- JWT for token-based authentication (JWTAuthenticationFilter, TokenInfo, etc.).
- Minio for managing external object storage.

##### Specific Elements
- Clear Labels: Name each component clearly (e.g., "AuthController", "ChatService", "UserRepository", "JWTAuthenticationFilter", etc.).

##### Final Assembly
– Branch out to show several controllers, each linked to their corresponding services.
– Show the flow from the Service layer into the Data Access layer where repositories interact with the database.
– Parallelly, illustrate the Security components (filters, configuration) that intercept incoming requests prior to the controllers.
– Include a separate block for the external Minio object storage and show its direct connection to the MinioService.
– Also, indicate the configuration management (properties files) as a separate block, which influences the behavior of the application based upon the environment.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Node
    Client("Client"):::external

    %% Application Core
    subgraph "Application Core"
        Entry("FanaticupsBackEndApplication"):::entry
        Client -->|"HTTP_Request"| Entry
    end

    %% Security Layer
    subgraph "Security Layer"
        JWT("JWTAuthenticationFilter"):::security
        Cors("CorsConfig"):::security
        WebSec("WebSecurityConfig"):::security
        SecServ("Security_Services"):::security
        Entry -->|"Initializes_Security"| JWT
        JWT ---|"Configured_by"| Cors
        JWT ---|"Configured_by"| WebSec
        JWT ---|"Uses"| SecServ
    end

    %% API Controllers
    subgraph "API Controllers"
        AuthCtrl("AuthController"):::controllers
        CatCtrl("CategoryController"):::controllers
        ChatCtrl("ChatController"):::controllers
        CupCtrl("CupController"):::controllers
        UserCtrl("UserController"):::controllers
        JWT -->|"Validates_Request"| AuthCtrl
        JWT -->|"Validates_Request"| CatCtrl
        JWT -->|"Validates_Request"| ChatCtrl
        JWT -->|"Validates_Request"| CupCtrl
        JWT -->|"Validates_Request"| UserCtrl
    end

    %% Business Services
    subgraph "Business Services"
        CatServ("CategoryService"):::services
        ChatServ("ChatService"):::services
        CupServ("CupService"):::services
        MsgServ("MessageService"):::services
        MinioServ("MinioService"):::services
        UserServ("UserService"):::services
        AuthCtrl -->|"Process"| CatServ
        CatCtrl -->|"Process"| CatServ
        ChatCtrl -->|"Process"| ChatServ
        CupCtrl -->|"Process"| CupServ
        UserCtrl -->|"Process"| UserServ
        AuthCtrl -->|"Process"| MsgServ
        MinioServ ---|"Integrates"| MinioExt[("Minio Server")]
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        Entities("Entities_(Category,Chat,Cup,Message)"):::dao
        Repos("Repositories_(Category,Chat,Cup,Message)"):::dao
        SecEntity("UserEntity"):::dao
        SecRepo("UserRepository"):::dao
        CatServ -->|"Data_Access"| Entities
        ChatServ -->|"Data_Access"| Entities
        CupServ -->|"Data_Access"| Entities
        MsgServ -->|"Data_Access"| Entities
        CatServ -->|"Data_Access"| Repos
        ChatServ -->|"Data_Access"| Repos
        CupServ -->|"Data_Access"| Repos
        MsgServ -->|"Data_Access"| Repos
        UserServ -->|"Data_Access"| SecEntity
        UserServ -->|"Data_Access"| SecRepo
        Entities ---|"Queries"| DB[("Database")]
        Repos ---|"Queries"| DB
        SecEntity ---|"Queries"| DB
        SecRepo ---|"Queries"| DB
    end

    %% DTO & Models
    subgraph "DTO & Models"
        DTO("DTOs_&_Models"):::dto
        AuthCtrl -->|"Uses_DTOs"| DTO
        CatCtrl -->|"Uses_DTOs"| DTO
        ChatCtrl -->|"Uses_DTOs"| DTO
        CupCtrl -->|"Uses_DTOs"| DTO
        UserCtrl -->|"Uses_DTOs"| DTO
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        Config("Environment_Properties"):::config
        Utility("FileComparator"):::utility
        Entry -->|"Loads_Config"| Config
    end

    %% Click Events
    click Entry "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/FanaticupsBackEndApplication.java"
    click AuthCtrl "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/controllers/AuthController.java"
    click CatCtrl "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/controllers/CategoryController.java"
    click ChatCtrl "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/controllers/ChatController.java"
    click CupCtrl "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/controllers/CupController.java"
    click UserCtrl "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/controllers/UserController.java"
    click CatServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/CategoryService.java"
    click ChatServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/ChatService.java"
    click CupServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/CupService.java"
    click MsgServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/MessageService.java"
    click MinioServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/MinioService.java"
    click UserServ "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/services/UserService.java"
    click Entities "https://github.com/jumpering/fanaticupsback/tree/main/src/main/java/org/fanaticups/fanaticupsBack/dao/entities"
    click Repos "https://github.com/jumpering/fanaticupsback/tree/main/src/main/java/org/fanaticups/fanaticupsBack/dao/repositories"
    click SecEntity "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/security/dao/UserEntity.java"
    click SecRepo "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/security/dao/UserRepository.java"
    click JWT "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/security/filters/JWTAuthenticationFilter.java"
    click Cors "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/security/config/CorsConfig.java"
    click WebSec "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/security/config/WebSecurityConfig.java"
    click DTO "https://github.com/jumpering/fanaticupsback/tree/main/src/main/java/org/fanaticups/fanaticupsBack/models"
    click Config "https://github.com/jumpering/fanaticupsback/tree/main/src/main/resources"
    click Utility "https://github.com/jumpering/fanaticupsback/blob/main/src/main/java/org/fanaticups/fanaticupsBack/utils/FileComparator.java"

    %% Styles
    classDef entry fill:#cfc,stroke:#333,stroke-width:2px;
    classDef controllers fill:#f9c,stroke:#333,stroke-width:2px;
    classDef services fill:#ff9,stroke:#333,stroke-width:2px;
    classDef dao fill:#9f9,stroke:#333,stroke-width:2px;
    classDef security fill:#9ff,stroke:#333,stroke-width:2px;
    classDef dto fill:#fc9,stroke:#333,stroke-width:2px;
    classDef config fill:#cff,stroke:#333,stroke-width:2px;
    classDef utility fill:#ecc,stroke:#333,stroke-width:2px;
    classDef external fill:#fdd,stroke:#333,stroke-width:2px;
```
