# joselinares17/repositorio-tpi architecture

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

- Interactive diagram: https://gitdiagram.com/joselinares17/repositorio-tpi
- Repository: https://github.com/joselinares17/repositorio-tpi

## Overview

##### Main Architectural Layers and Components
- Front Controller/API Layer: Represented by the various controllers (ArticleController, AuthController, ReviewController, and UserController) – these handle incoming HTTP requests and delegate to service layers.
- Service/Business Logic Layer: Classes such as ArticleService, AuthService, ReviewService, and UserService (with their corresponding implementations) encapsulate the business logic.
- Data Access Layer: The repositories (ArticleRepository, ReviewRepository, UserRepository) which interface with the database (MySQL).
- Domain/Data Model Layer: Entities (classes in the “entities” package, e.g., Article, ArticleDetail, Course, Review, User, etc.) that model the persistent data.
- Security and Authentication: Modules in the “security” and “security/jwt” packages that configure and implement JWT-based authentication (using JwtAuthenticationFilter, JwtService, and a SecurityConfig class).
- DTOs and Mappers: The dto, mapper, and request/response directories which manage object conversion between the API’s external representation and internal domain models.
- Exception Handling: Global exception management (e.g., GlobalExceptionHandler) and custom exception classes that ensure robust error handling.
- Utility Functions: Utilities like PDFAcademicExtractor (utilizing Apache PDFBox) to handle PDF extraction related to academic documents.
- Validations: Custom validations (e.g., ValidUsernameValidator) to ensure request data meets business constraints.

##### Mapping Relationships and Interactions
– The controllers then invoke the service layer where the core business logic executes.
– The utility components and custom validations are used within services and controllers to process and validate data.
– Errors propagate up and are managed by the global exception handler.

##### Essential Design Patterns and Principles
– Layered Architecture: Clearly delineate the presentation, business, data access, and security concerns.
– Repository Pattern: Abstracts data persistence with repository interfaces.
– Model-View-Controller (MVC) – at least in the sense of organizing controllers separate from business logic.
– Dependency Injection: Spring Boot automatically manages component injections (evident in the service and repository classes).
– Exception Handling and Cross-Cutting Concerns: GlobalExceptionHandler illustrates centralized control of application errors.

##### Relevant Technologies and Frameworks
– Java and Spring Boot for the backend framework.
– MySQL for database operations.
– Apache PDFBox for PDF extraction processes.
– Maven for project management and build automation.
– JWT for securing authentication and maintaining session state on stateless protocols.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client (Browser/API)"]:::external

    %% Security Layer
    subgraph "Security Layer"
        secConfig["Security Config"]:::security
        jwtComp["JWT Components"]:::security
    end

    %% Presentation Layer (API Controllers)
    subgraph "Front Controller/API Layer"
        controllers["Controllers (Article, Auth, Review, User)"]:::controllers
    end

    %% Business Logic Layer (Services)
    subgraph "Service/Business Logic Layer"
        services["Services (Business Logic)"]:::services
    end

    %% Data Access Layer (Repositories)
    subgraph "Data Access Layer"
        repositories["Repositories (Data Access)"]:::repositories
    end

    %% Database
    database["MySQL Database"]:::database

    %% Domain/Data Model Layer
    subgraph "Domain/Data Model Layer"
        dataEntities["Data Entities (Article, ArticleDetail, ODS_GOALS)"]:::entities
        userEntities["User Entities (Course, Review, Role, User, UserDetail)"]:::entities
    end

    %% DTOs and Mappers
    subgraph "DTOs and Mappers"
        dtos["DTOs"]:::dto
        mappers["Mappers"]:::dto
    end

    %% Exception Handling
    subgraph "Exception Handling"
        exceptions["Exceptions"]:::exceptions
        globalException["GlobalExceptionHandler"]:::exceptions
    end

    %% Utility Functions and Validations (Cross Cutting Concerns)
    utilities["Utilities (PDF Extractor)"]:::utilities
    validations["Validations"]:::validations

    %% Data Flow
    Client -->|"HTTP Request"| secConfig
    secConfig -->|"Filters Request"| jwtComp
    jwtComp -->|"Forwards Request"| controllers
    controllers -->|"Delegates to"| services
    services -->|"Calls"| repositories
    repositories -->|"Queries/Persists"| database

    %% Supporting Interactions
    controllers -.->|"Data Conversion"| dtos
    controllers -.-> mappers
    controllers -.->|"Error Handling"| globalException
    services -.->|"Validates Data"| validations
    controllers -.->|"Utilizes"| utilities
    services -.-> utilities
    repositories -->|"Maps Domain"| dataEntities
    repositories --> dataEntities
    repositories -->|"Maps Domain"| userEntities
    repositories --> userEntities

    %% Click Events
    click controllers "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/controllers"
    click services "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/services"
    click repositories "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/repositories"
    click dataEntities "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/entities/data"
    click userEntities "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/entities/user"
    click secConfig "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/security"
    click jwtComp "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/security/jwt"
    click dtos "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/dto"
    click mappers "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/dto/mapper"
    click exceptions "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/exceptions"
    click globalException "https://github.com/joselinares17/repositorio-tpi/blob/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/exceptions/management/GlobalExceptionHandler.java"
    click utilities "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/utils"
    click validations "https://github.com/joselinares17/repositorio-tpi/tree/master/src/main/java/org/lumeninvestiga/backend/repositorio/tpi/validations"

    %% Styles
    classDef external fill:#EFEFEF,stroke:#333,stroke-width:2px
    classDef controllers fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef services fill:#90EE90,stroke:#333,stroke-width:2px
    classDef repositories fill:#FFD700,stroke:#333,stroke-width:2px
    classDef security fill:#FF7F7F,stroke:#333,stroke-width:2px
    classDef entities fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef dto fill:#FFFF99,stroke:#333,stroke-width:2px
    classDef exceptions fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef utilities fill:#D2B48C,stroke:#333,stroke-width:2px
    classDef validations fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef database fill:#FFA500,stroke:#333,stroke-width:2px
```
