# nicolasberti/movie-reservation-system architecture

> Architecture diagram of the GitHub repository nicolasberti/movie-reservation-system, 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/nicolasberti/movie-reservation-system
- Repository: https://github.com/nicolasberti/movie-reservation-system

## Overview

##### Main Components
- API Layer (Controllers): In the “controllers” package, you have separate controllers for authentication, movie handling, showing (movie screenings), and user management.
- Service Layer: This includes the various services such as MovieService, ShowingService (with sub-services for retrieval, reservation, seats, and stats), UserService, and the JWT-specific services. Different service implementation classes (e.g., JWT/AuthenticationService, JwtService, and others) should be represented.
- Data Access Layer (Repositories): These consist of the interfaces for accessing Movie, Showing, User, and UserShowing data.
- Domain Models: The domain entities such as Movie, User, Showing, Role, and others which manage application state.
- Security & Configurations: Configuration components like SecurityConfiguration, ApplicationConfiguration, and JWT filters that manage authentication and security aspects.
- External/Infrastructure Components:
- Database: Although not explicitly mentioned in the file tree, the use of JPA/Hibernate implies a connection to a relational database.
- Containerization: Docker files (Dockerfile and docker-compose.yml) indicate that this back-end service is designed to run in Docker containers.
- Front-end integration: Mentioned in the README as Angular-based but not fully implemented yet; it should be noted as an external client interfacing with the API.

##### Relationships and Interactions
- Client to API: Show the Angular front-end (client) making HTTP requests to the back-end controllers.
- API to Services: Controllers delegate business logic and processing to their respective service classes.
- Services to Repositories: Service implementations handle CRUD operations via repository interfaces which interact with the database.
- Security Flow: Clients first authenticate via the AuthenticationController and JWT-based services. The JwtAuthenticationFilter intercepts requests to secure endpoints.
- Exception Handling: Although not a separate “layer,” the GlobalExceptionHandler in the exceptions package governs error and exception responses across layers.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly separate the Controller, Service, and Data Access layers.
- Clean Code & SOLID: The project packages indicate adherence to these principles by using clearly named interfaces and corresponding implementations.
- Security Filtering: Emphasize the centralized JWT filtering and security configuration.
- Containerization: Include a note on how Docker is set up for deployment which encapsulates the entire back-end environment.

##### Relevant Technologies, Frameworks, and Libraries
- Spring Boot: Central framework powering the application.
- Spring Security & JWT: For handling authentication and authorization.
- Hibernate & JPA: For ORM and database interactions.
- Docker: For containerizing the application, with Docker Compose to potentially setup the complete environment (e.g., linking the application to a database container).
- Maven: Indicated by pom.xml and Maven Wrapper scripts for building the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Components
    Angular("Angular Front-end"):::external
    Docker("Docker Containerization"):::external
    DB("Relational Database"):::external

    %% API Layer
    subgraph "API Layer"
        AC("AuthenticationController"):::controller
        MC("MovieController"):::controller
        SC("ShowingController"):::controller
        UC("UserController"):::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        MS("MovieService"):::service
        SS("ShowingService"):::service
        SGet("ShowingGetterService"):::service
        SRes("ShowingReservationService"):::service
        SSeats("ShowingSeatsService"):::service
        SStats("ShowingStatsService"):::service
        StatsUtil("DefaultStatsCalculator"):::service
        US("UserService"):::service
        AuthS("AuthenticationService"):::service
        JwtS("JwtService"):::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        MR("MovieRepository"):::repository
        SR("ShowingRepository"):::repository
        UR("UserRepository"):::repository
        USR("UserShowingRepository"):::repository
    end

    %% Domain Models
    subgraph "Domain Models"
        DMovie("Movie"):::domain
        DRole("Role"):::domain
        DShowing("Showing"):::domain
        DUser("User"):::domain
        DUserShowing("UserShowing"):::domain
        GEH("GlobalExceptionHandler"):::domain
        IRE("InvalidRequestException"):::domain
    end

    %% Security & Configurations
    subgraph "Security & Configurations"
        AppConfig("ApplicationConfiguration"):::security
        SecConfig("SecurityConfiguration"):::security
        JwtFilter("JwtAuthenticationFilter"):::security
    end

    %% Interactions - External to API
    Angular -->|"HTTP_Request"| AC
    Angular -->|"HTTP_Request"| MC
    Angular -->|"HTTP_Request"| SC
    Angular -->|"HTTP_Request"| UC

    %% API to Service
    AC -->|"uses"| AuthS
    AC -->|"uses"| JwtS
    MC -->|"calls"| MS
    SC -->|"calls"| SS
    UC -->|"calls"| US

    %% Service Layer Internal Delegation
    SS -->|"delegates"| SGet
    SS -->|"delegates"| SRes
    SS -->|"delegates"| SSeats
    SS -->|"delegates"| SStats
    SStats -->|"utilizes"| StatsUtil

    %% Service to Repositories
    MS -->|"CRUD"| MR
    SS -->|"CRUD"| SR
    US -->|"CRUD"| UR
    US -->|"CRUD"| USR

    %% Repositories interact with Database
    MR --> DB
    SR --> DB
    UR --> DB
    USR --> DB

    %% Exception Handling from API Controllers to Domain Exception Handler
    AC -->|"exception"| GEH
    MC -->|"exception"| GEH
    SC -->|"exception"| GEH
    UC -->|"exception"| GEH

    %% Security Integration: JWT Filter secures API Endpoints
    JwtFilter -->|"secures"| AC
    JwtFilter -->|"secures"| MC
    JwtFilter -->|"secures"| SC
    JwtFilter -->|"secures"| UC
    SecConfig -->|"configures"| JwtFilter
    AppConfig -->|"loads"| SecConfig

    %% Docker containerization groups Angular and Database
    Docker -->|"contains"| Angular
    Docker -->|"contains"| DB

    %% Style Classes
    classDef controller fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef service fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef repository fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef domain fill:#D8BFD8,stroke:#000,stroke-width:1px;
    classDef security fill:#F08080,stroke:#000,stroke-width:1px;
    classDef external fill:#EEE8AA,stroke:#000,stroke-width:1px;

    %% Click Events for API Layer
    click AC "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/controllers/AuthenticationController.java"
    click MC "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/controllers/MovieController.java"
    click SC "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/controllers/ShowingController.java"
    click UC "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/controllers/UserController.java"

    %% Click Events for Service Layer
    click MS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/MovieService.java"
    click MS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/MovieServiceImpl.java"
    click SS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/ShowingService.java"
    click SS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/ShowingServiceImpl.java"
    click SGet "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/GetterService.java"
    click SGet "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/GetterServiceImpl.java"
    click SRes "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/ReservationService.java"
    click SRes "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/ReservationServiceImpl.java"
    click SSeats "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/SeatsService.java"
    click SSeats "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/SeatsServiceImpl.java"
    click SStats "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/StatsService.java"
    click SStats "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/StatsServiceImpl.java"
    click StatsUtil "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/utils/DefaultStatsCalculator.java"
    click StatsUtil "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/Showing/utils/StatsCalculator.java"
    click US "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/UserService.java"
    click US "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/UserServiceImpl.java"
    click AuthS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/JWT/AuthenticationService.java"
    click JwtS "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/services/JWT/JwtService.java"

    %% Click Events for Data Access Layer
    click MR "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/repository/MovieRepository.java"
    click SR "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/repository/ShowingRepository.java"
    click UR "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/repository/UserRepository.java"
    click USR "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/repository/UserShowingRepository.java"

    %% Click Events for Domain Models
    click DMovie "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/Movie.java"
    click DRole "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/Role.java"
    click DShowing "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/Showing.java"
    click DUser "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/User.java"
    click DUserShowing "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/UserShowing.java"
    click GEH "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/exceptions/GlobalExceptionHandler.java"
    click IRE "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/models/exceptions/InvalidRequestException.java"

    %% Click Events for Security & Configurations
    click AppConfig "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/configs/ApplicationConfiguration.java"
    click SecConfig "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/configs/SecurityConfiguration.java"
    click JwtFilter "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/src/main/java/com/movies/demo/configs/JwtAuthenticationFilter.java"

    %% Click Events for External/Infrastructure
    click Docker "https://github.com/nicolasberti/movie-reservation-system/tree/main/demo/Dockerfile"
    click Docker "https://github.com/nicolasberti/movie-reservation-system/blob/main/demo/docker-compose.yml"
```
