# oguzhantomak/hotelguide architecture

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

## Overview

##### Main Components
- HotelManagementService:
- API Layer: Represents the HTTP endpoints (see the API project under HotelManagementService.API).
- Business/Application Layer: Contains the use-case logic, DTOs, services, validators, and exceptions.
- Domain Layer: Houses core business entities like Hotel, ContactInformation, and domain events (e.g., HotelCreatedEvent).
- Infrastructure Layer: Deals with data access via Entity Framework Core and repositories.

- ReportService:
- API Layer: Exposes endpoints (e.g., ReportController, WeatherForecastController).
- Business/Application Layer: Contains DTOs for reports, service classes, domain events (e.g., ReportCreatedEvent), and messaging interfaces.
- Domain Layer: Contains key report entities, value objects, and related domain logic.
- Infrastructure Layer: Integrates with external dependencies like MongoDB for report storage, HTTP clients (for hotel management data), and RabbitMQ for messaging.

- Cross-Service/Additional Components:
- RabbitMQ: Used for event-driven communication. HotelManagementService emits events (such as when a hotel is created) that ReportService subscribes to.
- Databases:
- SQL (or equivalent through Entity Framework Core) for HotelManagementService.
- MongoDB for ReportService storage.
- Docker & Docker Compose: Indicates containerization and orchestration for both services, supporting deployment isolation.

##### And Reflect the Layered Architecture
- Microservice with its four distinct layers:
- Domain, Application, Infrastructure, and API.
- That within each microservice, the relationships between these layers are clearly expressed. For example, the API layer delegates requests to the Application layer, which in turn utilizes the Domain and Infrastructure layers.

- From HotelManagementService API to its Domain (e.g., creating a Hotel entity).
- From the Application/Domain layers of HotelManagementService to the Infrastructure layer (repository accessing the database).
- Outbound event emission from HotelManagementService to RabbitMQ.
- Flow from ReportService to MongoDB for persisting reports.

##### Architectural Patterns
- Domain-Driven Design:
- How Aggregate Roots (Hotel, Report) reside in the Domain layer.
- Value Objects (e.g., Address or ContactType) as part of the Domain.
- Domain Events (HotelCreatedEvent, ReportCreatedEvent) and the decoupling they bring.
- Clean Architecture:
- Separation of concerns by illustrating the four layers.
- Dependency inversion where the higher-level layers depend on abstractions defined in the Domain and Application layers.
- Event-Driven:
- RabbitMQ component and its role in decoupling reporting updates.

##### Final Touches
- Verify that every component from the file tree that plays a role in the architecture is represented (even if not every file needs to be drawn: focus on conceptual components like Controllers, Services, Repositories, Domain Entities).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "HotelManagementService"
        H_API["HotelManagementService.API"]:::api
        H_App["HotelManagementService.Application"]:::application
        H_Domain["HotelManagementService.Domain"]:::domain
        H_Infra["HotelManagementService.Infrastructure"]:::infra
        H_DB["SQL Database"]:::database
    end

    subgraph "ReportService"
        R_API["ReportService.API"]:::api
        R_App["ReportService.Application"]:::application
        R_Domain["ReportService.Domain"]:::domain
        R_Infra["ReportService.Infrastructure"]:::infra
        R_DB["MongoDB"]:::database
    end

    RabbitMQ["RabbitMQ"]:::messaging

    %% HotelManagementService Layer Interactions
    H_API -->|"delegates"| H_App
    H_App -->|"uses"| H_Domain
    H_Domain -->|"accesses"| H_Infra
    H_Infra -->|"writes to"| H_DB
    H_Infra -->|"publishesEvent"| RabbitMQ

    %% ReportService Layer Interactions
    RabbitMQ -->|"subscribesEvent"| R_API
    R_API -->|"delegates"| R_App
    R_App -->|"uses"| R_Domain
    R_Domain -->|"accesses"| R_Infra
    R_Infra -->|"storesReport"| R_DB

    %% Cross-Service HTTP Call
    R_App -->|"HTTPCall"| H_API

    %% Click Events
    click H_API "https://github.com/oguzhantomak/hotelguide/blob/master/src/HotelManagementService/HotelManagementService.API"
    click H_App "https://github.com/oguzhantomak/hotelguide/blob/master/src/HotelManagementService/HotelManagementService.Application"
    click H_Domain "https://github.com/oguzhantomak/hotelguide/blob/master/src/HotelManagementService/HotelManagementService.Domain"
    click H_Infra "https://github.com/oguzhantomak/hotelguide/blob/master/src/HotelManagementService/HotelManagementService.Infrastructure"
    click H_DB "https://github.com/oguzhantomak/hotelguide/blob/master/src/HotelManagementService/HotelManagementService.Infrastructure/Data/AppDbContext.cs"
    click R_API "https://github.com/oguzhantomak/hotelguide/blob/master/src/ReportService/ReportService.API"
    click R_App "https://github.com/oguzhantomak/hotelguide/blob/master/src/ReportService/ReportService.Application"
    click R_Domain "https://github.com/oguzhantomak/hotelguide/blob/master/src/ReportService/ReportService.Domain"
    click R_Infra "https://github.com/oguzhantomak/hotelguide/blob/master/src/ReportService/ReportService.Infrastructure"
    click RabbitMQ "https://github.com/oguzhantomak/hotelguide/blob/master/src/ReportService/ReportService.Infrastructure/Messaging/RabbitMqPublisher.cs"

    %% Styles
    classDef api fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef application fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef domain fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef infra fill:#F5CBA7,stroke:#873600,stroke-width:2px;
    classDef messaging fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef database fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
```
