# puncho-dev/ahp_ludoteca architecture

> Architecture diagram of the GitHub repository puncho-dev/ahp_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/puncho-dev/ahp_ludoteca
- Repository: https://github.com/puncho-dev/ahp_ludoteca

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Proyecto-Tutorial de Ludoteca”) for managing video-game lending: clients, authors, games, and loans.
- The frontend is an Angular 17+ SPA (TypeScript, Angular Material, Bootstrap, RxJS). The backend is a Spring Boot monolith (Java 21, Spring Web, Spring Data JPA, H2 DB, Maven).

##### File Structure Highlights
- Top-level directories:
- cliente/ludoteca-test → Angular client
- servidor/tutorial → Spring Boot server
- Frontend: organized by feature modules (author, category, client, game, loan) under src/app.
- Backend: organized by package per feature (author, category, client, game, loan) plus common (pagination, search criteria), config, and resources.

##### Key Architecture Components
a. Frontend SPA
- Components (author-list, author-edit, client-list, loan-list, etc.)
- Services using HttpClient → REST API calls
- Angular router for navigation
b. REST API Layer (Spring Controllers)
- AuthorController, ClientController, GameController, LoanController, CategoryController
c. Business Logic (Spring Services)
- Service interfaces + implementations (AuthorServiceImpl, etc.)
- Validation annotations (Spring Validation)
d. Data Access (Spring Data JPA Repositories)
- AuthorRepository, ClientRepository, etc.
e. Persistence
- H2 in-memory DB for dev/tests
- Entities, DTOs, search/pagination criteria
f. Build & Dev Tools
- Frontend: Vite dev server, Angular CLI
- Backend: Maven, JUnit 5 tests

##### Relationships & Data Flows
- Browser → (1) Angular Router/Components → (2) HttpClient GET/POST/PUT/DELETE → (3) Spring Controllers → (4) Service Layer → (5) Repository → (6) H2 DB
- The server returns DTOs back up the chain, HttpClient Observables feed Component views.

##### Architectural Patterns & Principles
- Layered architecture (Presentation → API → Service → Repository → Data)
- Feature-based modularization in frontend
- DTO pattern + ModelMapper (ModelMapperConfig)
- Pagination & filtering via common SearchCriteria and PageableRequest

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend SPA
    subgraph "Frontend SPA"
        subgraph "Feature Modules"
            AuthorComp["AuthorComponent"]:::frontend
            CategoryComp["CategoryComponent"]:::frontend
            ClientComp["ClientComponent"]:::frontend
            GameComp["GameComponent"]:::frontend
            LoanComp["LoanComponent"]:::frontend
        end
        subgraph "Services (HTTP Clients)"
            AuthorSvc["AuthorService"]:::frontend
            CategorySvc["CategoryService"]:::frontend
            ClientSvc["ClientService"]:::frontend
            GameSvc["GameService"]:::frontend
            LoanSvc["LoanService"]:::frontend
        end
        subgraph "Core / Shared"
            Header["HeaderComponent"]:::frontend
            Dialog["DialogConfirmationComponent"]:::frontend
            PaginationModel["Pageable / SortPage"]:::frontend
            Paginator["CustomMatPaginatorIntl"]:::frontend
            Routing["AppRoutes"]:::frontend
            AppConfig["AppConfig"]:::frontend
        end
    end

    %% Backend Spring Boot
    subgraph "Backend (Spring Boot)"
        subgraph "Controllers"
            AuthorCtrl["AuthorController"]:::api
            CatCtrl["CategoryController"]:::api
            ClientCtrl["ClientController"]:::api
            GameCtrl["GameController"]:::api
            LoanCtrl["LoanController"]:::api
        end
        subgraph "Service Layer"
            AuthorSvcB["AuthorServiceImpl"]:::service
            CategorySvcB["CategoryServiceImpl"]:::service
            ClientSvcB["ClientServiceImpl"]:::service
            GameSvcB["GameServiceImpl"]:::service
            LoanSvcB["LoanServiceImpl"]:::service
            ModelMapper["ModelMapperConfig"]:::service
        end
        subgraph "Repositories"
            AuthorRepo["AuthorRepository"]:::repo
            CategoryRepo["CategoryRepository"]:::repo
            ClientRepo["ClientRepository"]:::repo
            GameRepo["GameRepository"]:::repo
            LoanRepo["LoanRepository"]:::repo
        end
        subgraph "Common Utils"
            SearchCrit["SearchCriteria"]:::service
            PageableReq["PageableRequest"]:::service
            GameSpec["GameSpecification"]:::service
            LoanSpec["LoanSpecification"]:::service
        end
        H2[("H2 Database")]:::db
    end

    %% Data Flows
    AuthorComp -->|"HttpClient.get('/api/authors')"| AuthorSvc
    CategoryComp -->|"HttpClient.get('/api/categories')"| CategorySvc
    ClientComp -->|"HttpClient.get('/api/clients')"| ClientSvc
    GameComp -->|"HttpClient.get('/api/games')"| GameSvc
    LoanComp -->|"HttpClient.get('/api/loans')"| LoanSvc

    AuthorSvc -->|"GET /api/authors"| AuthorCtrl
    CategorySvc -->|"GET /api/categories"| CatCtrl
    ClientSvc -->|"GET /api/clients"| ClientCtrl
    GameSvc -->|"GET /api/games"| GameCtrl
    LoanSvc -->|"GET /api/loans"| LoanCtrl

    AuthorCtrl -->|"create/update/delete/findAll()"| AuthorSvcB
    CatCtrl -->|"create/update/delete/findAll()"| CategorySvcB
    ClientCtrl -->|"create/update/delete/findAll()"| ClientSvcB
    GameCtrl -->|"create/update/delete/findAll()"| GameSvcB
    LoanCtrl -->|"create/update/delete/findAll()"| LoanSvcB

    AuthorSvcB -->|"save()/findAll()"| AuthorRepo
    CategorySvcB -->|"save()/findAll()"| CategoryRepo
    ClientSvcB -->|"save()/findAll()"| ClientRepo
    GameSvcB -->|"save()/findAll()"| GameRepo
    LoanSvcB -->|"save()/findAll()"| LoanRepo

    AuthorRepo -->|"JPA queries"| H2
    CategoryRepo -->|"JPA queries"| H2
    ClientRepo -->|"JPA queries"| H2
    GameRepo -->|"JPA queries"| H2
    LoanRepo -->|"JPA queries"| H2

    %% Shared and cross-cutting flows
    ModelMapper --> AuthorSvcB
    ModelMapper --> CategorySvcB
    ModelMapper --> ClientSvcB
    ModelMapper --> GameSvcB
    ModelMapper --> LoanSvcB

    SearchCrit --> GameSpec
    SearchCrit --> LoanSpec
    PageableReq --> AuthorRepo
    PageableReq --> CategoryRepo
    PageableReq --> ClientRepo
    PageableReq --> GameRepo
    PageableReq --> LoanRepo

    Header --> AuthorComp
    Dialog --> AuthorComp
    Routing --> AuthorComp
    Routing --> CategoryComp
    Routing --> ClientComp
    Routing --> GameComp
    Routing --> LoanComp
    AppConfig --> AuthorSvc

    %% Click Events
    click AuthorComp "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/author"
    click CategoryComp "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/category"
    click ClientComp "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/client"
    click GameComp "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/game"
    click LoanComp "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/loan"
    click Routing "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/app.routes.ts"
    click AppConfig "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/app.config.ts"
    click Dialog "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/core/dialog-confirmation/dialog-confirmation.component.ts"
    click Header "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/core/header/header.component.ts"
    click PaginationModel "https://github.com/puncho-dev/ahp_ludoteca/tree/main/cliente/ludoteca-test/src/app/core/model/page"
    click Paginator "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/core/model/page/CustomMatPaginatorIntl.ts"
    click AuthorSvc "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/author/author.service.ts"
    click CategorySvc "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/category/category.service.ts"
    click ClientSvc "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/client/client.service.ts"
    click GameSvc "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/game/game.service.ts"
    click LoanSvc "https://github.com/puncho-dev/ahp_ludoteca/blob/main/cliente/ludoteca-test/src/app/loan/loan.service.ts"
    click AuthorCtrl "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/author/AuthorController.java"
    click CatCtrl "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/category/CategoryController.java"
    click ClientCtrl "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/client/ClientController.java"
    click GameCtrl "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/game/GameController.java"
    click LoanCtrl "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/loan/LoanController.java"
    click AuthorSvcB "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/author/AuthorServiceImpl.java"
    click CategorySvcB "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/category/CategoryServiceImpl.java"
    click ClientSvcB "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/client/ClientServiceImpl.java"
    click GameSvcB "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/game/GameServiceImpl.java"
    click LoanSvcB "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/loan/LoanServiceImpl.java"
    click AuthorRepo "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/author/AuthorRepository.java"
    click CategoryRepo "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/category/CategoryRepository.java"
    click ClientRepo "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/client/ClientRepository.java"
    click GameRepo "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/game/GameRepository.java"
    click LoanRepo "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/loan/LoanRepository.java"
    click ModelMapper "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/config/ModelMapperConfig.java"
    click SearchCrit "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/common/criteria/SearchCriteria.java"
    click PageableReq "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/common/pagination/PageableRequest.java"
    click GameSpec "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/game/GameSpecification.java"
    click LoanSpec "https://github.com/puncho-dev/ahp_ludoteca/blob/main/servidor/tutorial/src/main/java/com/ccsw/tutorial/loan/LoanSpecification.java"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3,stroke-width:2px
    classDef api fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px
    classDef service fill:#FFFDE7,stroke:#FBC02D,stroke-width:2px
    classDef repo fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
    classDef db fill:#ECEFF1,stroke:#90A4AE,stroke-width:2px,stroke-dasharray: 5 5
```
