# ssdd-2025/grupo-16 architecture

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

- Interactive diagram: https://gitdiagram.com/ssdd-2025/grupo-16
- Repository: https://github.com/ssdd-2025/grupo-16

## Overview

##### Project Type and Purpose
- This is a full-stack web application for purchasing concert tickets, where users (anonymous, registered, and administrators) can search for artists and concerts, view detailed artist pages, purchase tickets, and administrators can manage (add/modify/delete) concerts and artists.

##### File Structure and Identify Key Layers
- The project is structured as a Maven-based Spring Boot application.
- Top-level directories include:
- “entrega1”: the main project module with Java source code.
- Within “src/main/java”, the packages are divided under “es/ticketmaster/entrega1”, with subpackages for controllers (both REST and web), services, repositories, model, dto, and security.
- Resources include configuration files (application.properties), static assets (CSS, JS, media) and templates (HTML pages).
- Test code is organized under “src/test”.
- This layered partitioning indicates a clean separation into:
- Presentation layer: Web controllers (handling HTML view templates) and REST controllers.
- Business logic layer: Services that hold the main application logic for users, artists, concerts, and tickets.
- Data access layer: Repositories (JPA interfaces plus custom queries) interacting with the underlying database.
- Domain layer: Entities (UserEntity, Artist, Concert, Ticket) and associated DTOs for transferring data.
- Security layer: Components for authentication, JWT, password management, and session management via a SessionScope “ActiveUser” component.

##### Key Components and Their Interactions
- Client/Web Browser: Users interact with the application via a web interface (HTML pages, static resources) served by Spring Boot.
- Controllers:
- Web endpoints (e.g., MainController, UserController, TicketController, ArtistController, ConcertController) route user interactions to services.
- REST endpoints manage API calls.
- Service Layer: Contains business logic for user validation, ticket purchases, artist and concert management, and security checks.
- Data Layer: Repositories for each entity (ArtistRepository, ConcertRepository, TicketRepository, UserRepository) – repositories use JPA and custom queries to interact with the database.
- Security Components: JWT filters, WebSecurityConfig, and CSRF-related configurations secure the application.
- Assets and Views: Static resources (CSS, JS, media) and Mustache/HTML templates are used for the user interface.

##### Architectural Patterns and Design Principles
- Layered (n-tier) architecture: Separate controllers, services, repositories, and domain logic.
- MVC pattern: Controllers route requests to views (HTML templates) in the web layer.
- Hexagonal (Ports & Adapters) Architecture: The services serve as intermediaries between the controllers and repositories.
- Use of DTOs for data transfer between layers and mapping between domain models and client data.
- Security and session management is modularized (using JWT and session-scoped components).

##### Essential Elements
- Clear Labels: Each component (controller, service, repository, entity, security component, client device, database) should be labeled.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        CT["HTML Templates"]:::client
        CS["Static Assets"]:::client
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        WC["Web Controllers"]:::presentation
        RC["REST Controllers"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        S["Service Layer"]:::business
        DTO["DTO & Mappers"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        R["Repositories"]:::data
        D["Entity Models"]:::data
    end

    %% Security & Configuration
    subgraph "Security & Configuration"
        SEC["Security Components"]:::security
        CFG["Configuration Files"]:::config
        KEYS["Keystore"]:::config
    end

    %% Database
    DB[(Database)]:::database

    %% Connections between layers
    CT -->|"ViewRequest"| WC
    CT -->|"APICall"| RC

    WC -->|"Delegate"| S
    RC -->|"Delegate"| S

    S -->|"DataMapping"| DTO
    S -->|"ServiceCall"| R

    DTO -->|"MapsTo"| D

    R -->|"DBAccess"| DB
    D -->|"Stores"| DB

    WC -->|"AuthCheck"| SEC
    RC -->|"AuthCheck"| SEC

    CFG -->|"Configures"| SEC
    CFG -->|"Configures"| S

    %% Class Definitions (with colors)
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef presentation fill:#FFC300,stroke:#FF5733,stroke-width:2px;
    classDef business fill:#C70039,stroke:#900C3F,stroke-width:2px,color:#fff;
    classDef data fill:#28B463,stroke:#196F3D,stroke-width:2px,color:#fff;
    classDef security fill:#AF7AC5,stroke:#6C3483,stroke-width:2px,color:#fff;
    classDef config fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#E59866,stroke:#BA4A00,stroke-width:2px;

    %% Click Events for component mapping
    click CT "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/resources/templates"
    click CS "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/resources/static"
    click WC "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/controller/web"
    click RC "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/controller/rest"
    click S "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/service"
    click R "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/repository"
    click D "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/model"
    click DTO "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/dto"
    click SEC "https://github.com/ssdd-2025/grupo-16/tree/main/entrega1/src/main/java/es/ticketmaster/entrega1/security"
    click CFG "https://github.com/ssdd-2025/grupo-16/blob/main/entrega1/src/main/resources/application.properties"
    click KEYS "https://github.com/ssdd-2025/grupo-16/blob/main/entrega1/src/main/resources/keystore.jks"
```
