# tomiponceasd/reserva-app architecture

> Architecture diagram of the GitHub repository tomiponceasd/reserva-app, 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/tomiponceasd/reserva-app
- Repository: https://github.com/tomiponceasd/reserva-app

## Overview

##### Main Components

- Backend Components:
- Domain Layer: Contains the core business entities (Reserva, Servicio) that represent the data and business rules.
- Application Layer: Provides interfaces (IReservaRepository, IReservaService) and service implementations (ReservaService) that encapsulate business logic.
- Infrastructure Layer: Manages data persistence with the ReservaDbContext, database migrations, and repository implementations (ReservaRepository).
- API Layer: Exposed via the ReservasApi project. It includes controllers (ReservaController, ServicioController) and is responsible for handling HTTP requests, applying business rules from the application layer, and providing a Swagger endpoint for API documentation.

- Frontend Components:
- React Application: The frontend directory contains a React application responsible for interacting with the backend API. It includes components (ListaReservas, ReservaForm) for displaying and capturing data, service files (api.ts) for making HTTP calls, and typical React setup files.

##### Relationships and Interactions

- The Frontend communicates with the Backend API using HTTP calls.
- The API (in ReservasApi) receives client requests, then delegates the business logic request to the Application services.
- The Application services interact with the Domain entities for business rules and use the Infrastructure layer to perform data operations.
- The Infrastructure layer uses a data context (ReservaDbContext) to manage the persistence and evolution (migrations) of the database.
- Clear abstractions separate concerns: the Domain layer contains pure business rules, while the infrastructure deals with persistence, enabling the application to follow the principles of Clean Architecture.

##### Architectural Patterns and Design Principles

- Layered Architecture: The project is structured into distinct layers (Domain, Application, Infrastructure, API, and Frontend), improving modularity and testability.
- Separation of Concerns: The project clearly separates business logic (Application/Domain) from data access (Infrastructure) and user interface (Frontend).
- Dependency Inversion: Through interfaces in the Application layer, concrete implementations (in Infrastructure) are injected into services, easing testing and maintainability.
- RESTful API Design: The ReservasApi project adheres to REST principles with controllers and swagger documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        FEReactApp["React App"]:::frontend
        FELista["ListaReservas Component"]:::frontend
        FEReservaForm["ReservaForm Component"]:::frontend
        FEAPIServ["API Service (api.ts)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        ApiConfig["API Configuration"]:::api
        ReservaController["ReservaController – Handles HTTP requests"]:::api
        ServicioController["ServicioController – Handles HTTP requests"]:::api
        Swagger["Swagger Documentation"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        AppInterfaces["Application Interfaces (IReservaRepository, IReservaService)"]:::app
        ReservaService["ReservaService Implementation"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        ReservaEntity["Reserva Entity"]:::domain
        ServicioEntity["Servicio Entity"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DbContext["ReservaDbContext"]:::infra
        Repository["ReservaRepository"]:::infra
        Migrations["Database Migrations"]:::infra
    end

    %% Database
    Database["Database"]:::database

    %% Connections between layers
    FEReactApp -->|"HTTP_Calls"| ReservaController
    FEReactApp -->|"HTTP_Calls"| ServicioController
    FEAPIServ -->|"Interacts_with"| ApiConfig

    ReservaController -->|"Delegates_to"| ReservaService
    ServicioController -->|"Delegates_to"| ReservaService

    AppInterfaces -->|"Defines_contracts_for"| ReservaService

    ReservaService -->|"Executes_on"| ReservaEntity
    ReservaService -->|"Executes_on"| ServicioEntity
    ReservaService -->|"Calls"| Repository

    Repository -->|"Uses"| DbContext
    DbContext -->|"Persists_to"| Database
    Migrations -->|"Updates_schema_for"| Database

    %% Styles
    classDef frontend fill:#B3CDE0,stroke:#333,stroke-width:2px;
    classDef api fill:#E0BBE4,stroke:#333,stroke-width:2px;
    classDef app fill:#FFDFBA,stroke:#333,stroke-width:2px;
    classDef domain fill:#CDEAC0,stroke:#333,stroke-width:2px;
    classDef infra fill:#FDCEDF,stroke:#333,stroke-width:2px;
    classDef database fill:#F0E68C,stroke:#333,stroke-width:2px;

    %% Click Events - Frontend
    click FEReactApp "https://github.com/tomiponceasd/reserva-app/tree/main/frontend/"
    click FELista "https://github.com/tomiponceasd/reserva-app/blob/main/frontend/src/components/ListaReservas.tsx"
    click FEReservaForm "https://github.com/tomiponceasd/reserva-app/blob/main/frontend/src/components/ReservaForm.tsx"
    click FEAPIServ "https://github.com/tomiponceasd/reserva-app/blob/main/frontend/src/services/api.ts"

    %% Click Events - API Layer
    click ApiConfig "https://github.com/tomiponceasd/reserva-app/blob/main/ReservasApi/Program.cs"
    click ReservaController "https://github.com/tomiponceasd/reserva-app/blob/main/ReservasApi/Controllers/ReservaController.cs"
    click ServicioController "https://github.com/tomiponceasd/reserva-app/blob/main/ReservasApi/Controllers/ServicioController.cs"

    %% Click Events - Application Layer
    click AppInterfaces "https://github.com/tomiponceasd/reserva-app/tree/main/Application/Interfaces"
    click ReservaService "https://github.com/tomiponceasd/reserva-app/blob/main/Application/Services/ReservaService.cs"

    %% Click Events - Domain Layer
    click ReservaEntity "https://github.com/tomiponceasd/reserva-app/blob/main/Domain/Entities/Reserva.cs"
    click ServicioEntity "https://github.com/tomiponceasd/reserva-app/blob/main/Domain/Entities/Servicio.cs"

    %% Click Events - Infrastructure Layer
    click DbContext "https://github.com/tomiponceasd/reserva-app/blob/main/Infrastructure/Data/ReservaDbContext.cs"
    click Repository "https://github.com/tomiponceasd/reserva-app/blob/main/Infrastructure/Repositories/ReservaRepository.cs"
    click Migrations "https://github.com/tomiponceasd/reserva-app/tree/main/Infrastructure/Migrations"
```
