# ilyako/pet-holidays architecture

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

- Interactive diagram: https://gitdiagram.com/ilyako/pet-holidays
- Repository: https://github.com/ilyako/pet-holidays

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Frontend Layer (React.js Application)
- Components structure
- Pages (Hotels, Login, Register, About)
- Shared components
- Configuration

b) Backend Layer (ASP.NET Core)
- Web API (endpoints)
- Application Services
- Core Domain
- Data Access Layer

c) Database Layer
- SQL Database (evident from migrations)

##### Architectural Patterns to Highlight

The project follows several important patterns that should be represented:

a) Clean Architecture
- Core (Domain entities)
- Application (Services, DTOs)
- Infrastructure (Data Access)
- Web API (Presentation)

b) Domain-Driven Design elements
- Clear domain models (Hotels, Pets, Rooms, Users)
- Value objects and entities
- Service abstractions

**[Frontend Layer]**

- React Components
- Pages
- Shared Components
- Layout

- ▼
**[API Gateway / Middleware]**

- Exception Handlers
- User Handler
- Validation Handler

- ▼
**[Application Services]**

- Hotel Service
- Pet Service
- Room Service
- User Service

- ▼
**[Domain Layer]**

- Entities
- Hotel
- Pet
- Room
- User

- ▼
**[Data Access Layer]**

- Database

##### Key Relationships

- Frontend to Backend communication via REST APIs
- Service layer interactions with domain entities
- Data flow between services and database
- Authentication/Authorization flow
- CRUD operations flow

##### Additional Elements

Supporting components:
- Docker containers (shown by the Dockerfile presence)
- Configuration management
- Testing infrastructure
- External service integrations (if any)

##### Specific Implementation Details

- The modular structure of the application services
- Clear separation between domain logic and data access
- The relationship between different entity types (Hotels, Rooms, Pets)
- User authentication and authorization flow
- API endpoint organization

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#27ae60,stroke:#219a52,color:white
    classDef domain fill:#f1c40f,stroke:#f39c12,color:black
    classDef data fill:#e67e22,stroke:#d35400,color:white
    classDef middleware fill:#9b59b6,stroke:#8e44ad,color:white
    classDef handler fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Pages["Pages"]:::frontend
        Layout["Layout"]:::frontend
        SharedComp["Shared Components"]:::frontend
    end

    %% API & Middleware Layer
    subgraph APILayer
        APIEndpoints["API Endpoints"]:::api
        
        subgraph Middleware
            ExceptionHandlers["Exception Handlers"]:::middleware
            ValidationHandler["Validation Handler"]:::middleware
            UserHandler["User Handler"]:::middleware
        end
    end

    %% Application Services Layer
    subgraph Services
        HotelService["Hotel Service"]:::service
        PetService["Pet Service"]:::service
        RoomService["Room Service"]:::service
        UserService["User Service"]:::service
        CurrentUserProvider["Current User Provider"]:::service
    end

    %% Domain Layer
    subgraph Domain
        CoreEntities["Core Entities"]:::domain
        HotelEntity["Hotel Entity"]:::domain
        PetEntity["Pet Entity"]:::domain
        RoomEntity["Room Entity"]:::domain
        UserEntity["User Entity"]:::domain
    end

    %% Data Access Layer
    subgraph DataAccess
        DbContext["Database Context"]:::data
        Migrations["Migrations"]:::data
    end

    %% Relationships
    Frontend --> APIEndpoints
    APIEndpoints --> Middleware
    Middleware --> Services
    Services --> Domain
    Domain --> DataAccess

    %% Click Events
    click Pages "https://github.com/IlyaKo/pet-holidays/tree/develop/src/frontend/src/components/pages"
    click Layout "https://github.com/IlyaKo/pet-holidays/blob/develop/src/frontend/src/components/layout/Layout.js"
    click SharedComp "https://github.com/IlyaKo/pet-holidays/tree/develop/src/frontend/src/components/shared"
    click APIEndpoints "https://github.com/IlyaKo/pet-holidays/tree/develop/src/backend/LosTomates.PetHolidays.WebApi/Endpoints"
    click ExceptionHandlers "https://github.com/IlyaKo/pet-holidays/tree/develop/src/backend/LosTomates.PetHolidays.WebApi/Middleware"
    click ValidationHandler "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.WebApi/Middleware/ValidationEceptionHandler.cs"
    click UserHandler "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.WebApi/Middleware/UserHandlerMiddleware.cs"
    click HotelService "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Application/Hotels/HotelService.cs"
    click PetService "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Application/Pets/PetService.cs"
    click RoomService "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Application/Rooms/RoomService.cs"
    click UserService "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Application/Users/UserService.cs"
    click CurrentUserProvider "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Application/Users/CurrentUserProvider.cs"
    click CoreEntities "https://github.com/IlyaKo/pet-holidays/tree/develop/src/backend/LosTomates.PetHolidays.Core/Domain"
    click HotelEntity "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Core/Domain/Hotels/Hotel.cs"
    click PetEntity "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Core/Domain/Pets/Pet.cs"
    click RoomEntity "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Core/Domain/Rooms/Room.cs"
    click UserEntity "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.Core/Domain/Users/User.cs"
    click DbContext "https://github.com/IlyaKo/pet-holidays/blob/develop/src/backend/LosTomates.PetHolidays.DataAccess/ApplicationDbContext.cs"
    click Migrations "https://github.com/IlyaKo/pet-holidays/tree/develop/src/backend/LosTomates.PetHolidays.DataAccess/Migrations"
```
