# ppsegur/proyectopepeseguraacademia architecture

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

- Interactive diagram: https://gitdiagram.com/ppsegur/proyectopepeseguraacademia
- Repository: https://github.com/ppsegur/proyectopepeseguraacademia

## Overview

##### Main Components
- Frontend/User Interface: Represented by the static resources (CSS, JavaScript, images) and the Thymeleaf (or similar) HTML templates in the resources/templates folder. This layer handles the frontend presentation and user interactions.
- Web/Controller Layer: All controllers (located in the “controller” package) such as AdminControlador, CarritoControlador, CursoController, and others form the web layer that processes requests and returns responses.
- Service Layer: Business logic is encapsulated in service classes (e.g., CarritoServicio, CursoServicio, EstudianteServicio, etc.). They orchestrate operations between incoming client requests and database operations.
- Data Access Layer: The repository interfaces (located in the “repositorio” package) manage CRUD operations on the domain models.
- Domain/Model Layer: Entity classes (like Curso, Certificado, Estudiante, Venta, etc.) represent the data and business objects.
- Security Layer: Security configuration is provided under the “security” package (SecurityConfig, PasswordEncoderConfig) to manage authentication and authorization.
- Database: Not directly visible in the file tree but implied via the “import.sql” (which likely seeds data) and configuration properties from application.properties.
- Additional Utilities: Components such as mail service (MailService) and PDF export utility (UserPdfExporter) add supporting functionality.

##### Relationships and Interactions
- How the frontend (HTML templates, static resources) sends requests (via forms or Ajax) to the controller layer.
- That controllers process requests, delegate business logic to the service layer, and then use repositories for accessing or modifying data.
- Data flow in the reverse direction (responses and views) to the client.
- Exception handling and security filters that are applied to incoming requests (e.g., using Spring Security).

##### Architectural Patterns and Design Principles
- Follow the MVC (Model-View-Controller) pattern: clearly separate responsibilities among Controllers (handling HTTP requests), Services (business logic), and Repositories/Models (persistence and domain data).
- Dependency Injection and Inversion of Control, inherent in Spring Boot, which decouples component dependencies.
- Layered Architecture: Distinct separation between presentation, business, and data layers.
- Use of modular components enhances maintainability and extensibility (e.g., dedicated packages for security, exceptions, and utilities).

## Diagram (Mermaid)

```mermaid
graph TD

  %% Presentation Layer
  subgraph "Presentation Layer"
    A["Templates (HTML)"] 
    B["Static Resources"]
  end

  %% Security Layer
  subgraph "Security Layer"
    AE["SecurityConfig"]
    AF["PasswordEncoderConfig"]
  end

  %% Controller Layer
  subgraph "Controller Layer"
    C["AdminControlador"]
    D["CarritoControlador"]
    E["CertificadoController"]
    F["CursoController"]
    G["EstudianteController"]
    H["RoleBasedSuccessHandler"]
  end

  %% Service Layer
  subgraph "Service Layer"
    I["CarritoServicio"]
    J["CertificadoServicio"]
    K["CursoServicio"]
    L["EstudianteServicio"]
    M["MailService"]
    N["MaterialServicio"]
    O["UserDetailsServiceImpl"]
    P["VentaServicio"]
  end

  %% Repository Layer
  subgraph "Repository Layer"
    Q["CarritoRepositorio"]
    R["CertificadoRepositorio"]
    S["CursoRepositorio"]
    T["EstudianteRepositorio"]
    U["LineaVentaRepositorio"]
    V["MaterialRepositorio"]
    W["VentaRepositorio"]
  end

  %% Domain/Model Layer
  subgraph "Domain/Model Layer"
    X["Certificado"]
    Y["Curso"]
    Z["Estudiante"]
    AA["LineaVenta"]
    AB["LineaVentaPk"]
    AC["Material"]
    AD["Venta"]
  end

  %% Database
  AG["Database"]

  %% Additional Utilities
  subgraph "Additional Utilities"
    AH["UserPdfExporter"]
  end

  %% Flow connections
  %% Frontend to Security
  A -->|"sendsRequest"| AE
  B -->|"sendsRequest"| AE
  
  %% Security to Controllers
  AE -->|"permits"| C

  %% Controllers delegate to Services
  C -->|"calls"| I
  D -->|"calls"| I
  E -->|"calls"| J
  F -->|"calls"| K
  G -->|"calls"| L
  H -->|"calls"| I

  %% Services call Repositories
  I -->|"read/write"| Q
  J -->|"read/write"| R
  K -->|"read/write"| S
  L -->|"read/write"| T
  M -->|"triggers"| Q
  P -->|"read/write"| W

  %% Repositories interact with Database
  Q -->|"CRUD"| AG
  R -->|"CRUD"| AG
  S -->|"CRUD"| AG
  T -->|"CRUD"| AG
  U -->|"CRUD"| AG
  V -->|"CRUD"| AG
  W -->|"CRUD"| AG

  %% Repository maps Domain Models (generic association)
  Q ---|"maps"| X

  %% Service Layer triggering utilities
  P -->|"exportsPDF"| AH

  %% Styling Classes
  class A,B frontend
  class C,D,E,F,G,H controller
  class I,J,K,L,M,N,O,P service
  class Q,R,S,T,U,V,W repository
  class X,Y,Z,AA,AB,AC,AD domain
  class AE,AF security
  class AG database
  class AH utilities

  %% Click Events
  click A "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/resources/templates"
  click B "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/resources/static"
  click C "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/controller"
  click H "https://github.com/ppsegur/proyectopepeseguraacademia/blob/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/controller/RoleBasedSuccessHandler.java"
  click I "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/servicio"
  click M "https://github.com/ppsegur/proyectopepeseguraacademia/blob/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/servicio/MailService.java"
  click Q "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/repositorio"
  click X "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/modelo"
  click AE "https://github.com/ppsegur/proyectopepeseguraacademia/tree/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/security"
  click AG "https://github.com/ppsegur/proyectopepeseguraacademia/blob/main/ProyectoPepeSeguraAcademia/src/main/resources/import.sql"
  click AH "https://github.com/ppsegur/proyectopepeseguraacademia/blob/main/ProyectoPepeSeguraAcademia/src/main/java/com/salesianostriana/dam/proyectopepesegura/util/UserPdfExporter.java"

%% Class Definitions for Colors
classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
classDef controller fill:#FFECB3,stroke:#F9A825,stroke-width:2px;
classDef service fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
classDef repository fill:#D1C4E9,stroke:#5E35B1,stroke-width:2px;
classDef domain fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
classDef security fill:#FFE0B2,stroke:#F57C00,stroke-width:2px;
classDef database fill:#B2EBF2,stroke:#0097A7,stroke-width:2px;
classDef utilities fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
```
