# anagonbu/tutorial_ludoteca architecture

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

- Interactive diagram: https://gitdiagram.com/anagonbu/tutorial_ludoteca
- Repository: https://github.com/anagonbu/tutorial_ludoteca

## Overview

##### Project type and purpose
- This is a full-stack web application (“Tutorial_Ludoteca”) for managing video-game loans in a library.
- Frontend: Angular-based SPA for CRUD operations on clients, authors, games and loans (filtering, pagination, validation).
- Backend: Java Spring Boot REST API exposing endpoints for each domain (client, author, category, game, loan), persisting to an in-memory H2 database.

##### File structure
- Top-level “FrontEnd” folder holds an Angular 17 project (angular.json, package.json, src/app with modules & components).
- Top-level “back” folder holds a Mavenized Spring Boot project (pom.xml, src/main/java/com/ccsw/tutorial with controllers, services, repositories, models; src/main/resources for configuration and data).
- Build scripts: npm (frontend), maven wrapper (back).
- Test suites: Jasmine/Karma for Angular (spec.ts files), JUnit 5 for Java (IT and unit tests).

##### README
- Describes modules: client, author, game, loan, common (pagination & filtering).
- Guides on pending work (error handling).

a. Main components
- UI Layer (Angular SPA)
- HTTP API Layer (Spring Boot Controllers)
- Business Logic Layer (Spring Services & Specifications)
- Data Access Layer (Spring Repositories, JPA)
- Database (H2 in-memory)
- External libraries/frameworks (Angular Material, RxJS, Spring Data JPA, ModelMapper)

b. Relationships & interactions
- UI initiates CRUD and filter requests via HttpClient → REST endpoints.
- Controllers map request DTOs → call corresponding Service.
- Services apply business rules (validation, loan restrictions) and delegate to Repositories.
- Repositories translate to JPA queries (including Specifications for dynamic filtering).
- Database returns persisted entities → mapped back via ModelMapper → returned as DTO → UI updates state (observables).

c. Architectural patterns & design principles
- Frontend: Component-based architecture, routing module, service layer for API abstraction, reactive programming with RxJS.
- Backend: Layered architecture (Controller → Service → Repository), use of DTOs and ModelMapper for mapping, Specification pattern for search criteria, pagination abstraction.
- Separation of concerns, single responsibility per component, RESTful API design.

d. Key technologies/frameworks
- Frontend: Angular 17, TypeScript, Angular Router, Angular Material, Bootstrap, RxJS, HttpClient.
- Backend: Java 21, Spring Boot (Web, Data JPA, Validation), H2, ModelMapper, JUnit 5, Maven.

##### Elements
- Clear labels: “Angular SPA”, “AuthorComponent”, “GameService”, “LoanRepository”, “H2 DB”, etc.
- UI → HttpClient → Controller
- Controller → Service → Repository → DB
- DB → Repository → Service → Controller → UI
- Blue rectangles for frontend components (modules, services).
- Green rectangles for backend layers (controllers, services).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer (Angular SPA)"
        direction TB
        CoreModule["CoreModule"]:::frontend
        AppRoutes["AppRoutes"]:::frontend
        AppConfig["AppConfig"]:::frontend

        subgraph "Author Module"
            direction TB
            AuthorList["AuthorListComponent"]:::frontend
            AuthorEdit["AuthorEditComponent"]:::frontend
            AuthorSvcUI["AuthorService"]:::frontend
        end

        subgraph "Category Module"
            direction TB
            CatList["CategoryListComponent"]:::frontend
            CatEdit["CategoryEditComponent"]:::frontend
            CatSvcUI["CategoryService"]:::frontend
        end

        subgraph "Client Module"
            direction TB
            ClientList["ClientListComponent"]:::frontend
            ClientEdit["ClientEditComponent"]:::frontend
            ClientSvcUI["ClientService"]:::frontend
        end

        subgraph "Game Module"
            direction TB
            GameList["GameListComponent"]:::frontend
            GameEdit["GameEditComponent"]:::frontend
            GameSvcUI["GameService"]:::frontend
        end

        subgraph "Loan Module"
            direction TB
            LoanList["LoanListComponent"]:::frontend
            LoanRegister["LoanRegisterComponent"]:::frontend
            LoanSvcUI["LoanService"]:::frontend
        end
    end

    %% Backend Layers
    subgraph "HTTP API Layer (Controllers)"
        direction TB
        AuthorController["AuthorController"]:::backend
        CategoryController["CategoryController"]:::backend
        ClientController["ClientController"]:::backend
        GameController["GameController"]:::backend
        LoanController["LoanController"]:::backend
    end

    subgraph "Business Logic Layer (Services)"
        direction TB
        AuthorServiceImpl["AuthorServiceImpl"]:::backend
        CategoryServiceImpl["CategoryServiceImpl"]:::backend
        ClientServiceImpl["ClientServiceImpl"]:::backend
        GameServiceImpl["GameServiceImpl"]:::backend
        LoanServiceImpl["LoanServiceImpl"]:::backend
        ModelMapperConfig["ModelMapperConfig"]:::backend
        PageReq["PageableRequest"]:::backend
        SearchCrit["SearchCriteria"]:::backend
    end

    subgraph "Data Access Layer (Repositories & Specs)"
        direction TB
        AuthorRepository["AuthorRepository"]:::backend
        CategoryRepository["CategoryRepository"]:::backend
        ClientRepository["ClientRepository"]:::backend
        GameRepository["GameRepository"]:::backend
        LoanRepository["LoanRepository"]:::backend
        GameSpec["GameSpecification"]:::backend
        LoanSpec["LoanSpecification"]:::backend
    end

    %% Database
    H2DB(("H2 In-Memory DB")):::db

    %% Flows
    CoreModule -->|provides| AuthorList
    CoreModule -->|provides| CatList
    AppConfig -->|configures HTTP| AuthorSvcUI
    AppRoutes -->|routes to| AuthorList

    AuthorList -->|uses| AuthorSvcUI
    AuthorEdit -->|uses| AuthorSvcUI
    CategoryList -->|uses| CatSvcUI
    CategoryEdit -->|uses| CatSvcUI
    ClientList -->|uses| ClientSvcUI
    ClientEdit -->|uses| ClientSvcUI
    GameList -->|uses| GameSvcUI
    GameEdit -->|uses| GameSvcUI
    LoanList -->|uses| LoanSvcUI
    LoanRegister -->|uses| LoanSvcUI

    AuthorSvcUI -->|HTTP/JSON| AuthorController
    CatSvcUI -->|HTTP/JSON| CategoryController
    ClientSvcUI -->|HTTP/JSON| ClientController
    GameSvcUI -->|HTTP/JSON| GameController
    LoanSvcUI -->|HTTP/JSON| LoanController

    AuthorController -->|"calls"| AuthorServiceImpl
    CategoryController -->|"calls"| CategoryServiceImpl
    ClientController -->|"calls"| ClientServiceImpl
    GameController -->|"calls"| GameServiceImpl
    LoanController -->|"calls"| LoanServiceImpl

    AuthorServiceImpl -->|uses| AuthorRepository
    CategoryServiceImpl -->|uses| CategoryRepository
    ClientServiceImpl -->|uses| ClientRepository
    GameServiceImpl -->|uses| GameRepository
    LoanServiceImpl -->|uses| LoanRepository

    GameServiceImpl -->|filters via| GameSpec
    LoanServiceImpl -->|filters via| LoanSpec
    AuthorServiceImpl -->|maps via| ModelMapperConfig

    AuthorRepository -->|JPA| H2DB
    CategoryRepository -->|JPA| H2DB
    ClientRepository -->|JPA| H2DB
    GameRepository -->|JPA| H2DB
    LoanRepository -->|JPA| H2DB

    %% Click Events UI
    click CoreModule "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/core/core.module.ts"
    click AppRoutes "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/app.routes.ts"
    click AppConfig "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/app.config.ts"
    click AuthorList "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/author/author-list"
    click AuthorEdit "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/author/author-edit"
    click AuthorSvcUI "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/author/author.service.ts"
    click CatList "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/category/category-list"
    click CatEdit "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/category/category-edit"
    click CatSvcUI "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/category/category.service.ts"
    click ClientList "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/client/client-list"
    click ClientEdit "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/client/client-edit"
    click ClientSvcUI "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/client/client.service.ts"
    click GameList "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/game/game-list"
    click GameEdit "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/game/game-edit"
    click GameSvcUI "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/game/game.service.ts"
    click LoanList "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/loan/loan-list"
    click LoanRegister "https://github.com/anagonbu/tutorial_ludoteca/tree/main/FrontEnd/src/app/loan/loan-register"
    click LoanSvcUI "https://github.com/anagonbu/tutorial_ludoteca/blob/main/FrontEnd/src/app/loan/loan.service.ts"

    %% Click Events Backend
    click TutorialApp "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/TutorialApplication.java"
    click AuthorController "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/author/AuthorController.java"
    click CategoryController "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/category/CategoryController.java"
    click ClientController "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/client/ClientController.java"
    click GameController "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/game/GameController.java"
    click LoanController "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/loan/LoanController.java"
    click AuthorServiceImpl "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/author/AuthorServiceImpl.java"
    click CategoryServiceImpl "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/category/CategoryServiceImpl.java"
    click ClientServiceImpl "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/client/ClientServiceImpl.java"
    click GameServiceImpl "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/game/GameServiceImpl.java"
    click LoanServiceImpl "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/loan/LoanServiceImpl.java"
    click AuthorRepository "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/author/AuthorRepository.java"
    click CategoryRepository "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/category/CategoryRepository.java"
    click ClientRepository "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/client/ClientRepository.java"
    click GameRepository "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/game/GameRepository.java"
    click LoanRepository "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/loan/LoanRepository.java"
    click GameSpec "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/game/GameSpecification.java"
    click LoanSpec "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/loan/model/LoanSpecification.java"
    click PageReq "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/common/PageableRequest.java"
    click SearchCrit "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/common/criteria/SearchCriteria.java"
    click ModelMapperConfig "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/java/com/ccsw/tutorial/config/ModelMapperConfig.java"
    click H2DB "https://github.com/anagonbu/tutorial_ludoteca/blob/main/back/src/main/resources/application.properties"

    %% Styles
    classDef frontend fill:#D1E8FF,stroke:#0366d6,color:#000;
    classDef backend fill:#E2F0CB,stroke:#228B22,color:#000;
    classDef db fill:#F6E8B1,stroke:#DAA520,color:#000;
```
