# ulasahin/hotelmanagementwebsite architecture

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

- Interactive diagram: https://gitdiagram.com/ulasahin/hotelmanagementwebsite
- Repository: https://github.com/ulasahin/hotelmanagementwebsite

## Overview

##### Project Type & Purpose
- This is clearly a full-stack web application for hotel management. Its purpose is to handle user registrations, reservations, automated emails, payment processing via Stripe, and room management.
- The front end is built with Angular (using Angular CLI), while the backend is developed in Java with Spring Boot and communicates with a PostgreSQL database.
- Key features include authentication, room reservations, email notifications, and payment processing.

##### Analyzing the File Structure
- The backend (EasyStay-core) is organized with a clear layered architecture:
- “controller” package: Contains REST controllers like AppController, AuthController, RoomController, etc.
- “service” packages (both abstracts and concretes): Contains business logic for authentication, reservations, room management, etc.
- “repository” package: Implements data persistence and interacts with the PostgreSQL database.
- “model”, “mapper”, and “dtos”: Define domain entities, data transfer objects, and Mapstruct-based mappers.
- “core/config” and “core/security”: Handle configurations, security (JWT), CORS, and email integrations.
- “tasks” and “exceptionhandling”: Manage scheduled tasks and global error handling.
- The frontend (easystay-ui) follows Angular conventions with distinct components, pages, services (for handling HTTP requests), interceptors (for JWT auth), and models.
- There is also configuration for Maven (pom.xml, mvnw) and for Angular (angular.json, package.json).

##### Identifying Main Components
a. Backend Components:
- API Layer: REST controllers (e.g., AuthController, RoomController, ReservationController, etc.) which provide endpoints.
- Business Logic Layer: Service interfaces and implementations (AuthServiceImpl, ReservationServiceImpl, etc.) encapsulating the core operations and handling business rules (e.g., ReservationBusinessRule, RoomBusinessRule).
- Data Access Layer: Repositories for data persistence connected to PostgreSQL.
- Domain Model & Mapping: Entities, DTOs, and mappers for converting between layers.
- Infrastructure: Security configurations (JWTFilter, SecurityConfiguration, CorsConfig), Email Service, Stripe configuration, scheduling tasks, and exception handling.

b. Frontend Components:
- UI Layer: Angular components divided among pages (home, login, profile, room, etc.) and shared modules.
- Service Layer: Angular services (AuthService, RoomService, NavbarService) that connect to API endpoints, possibly using Interceptors for authorization (JWT interceptor).
- Routing & State Management: Defined routes (app.routes.ts) and guards (auth.guard.ts) to manage view access.

c. Database:
- PostgreSQL as the persistence layer storing hotel reservations, user records, room details, reviews, and payment records.

d. External Services:
- Email Service for notifications.
- Payment Processing (Stripe) as configured in StripeConfig.
- Possibly third-party logging and monitoring tools (based on logback-spring.xml).

##### Defining Relationships and Interactions
- On the backend, map the flow: Controller ⇨ Service ⇨ Repository (with bidirectional interaction for error handling via GlobalExceptionHandler).
- That the Security Layer (JWTFilter, SecurityConfiguration) sits in front of the controller endpoints.
- Scheduled tasks and asynchronous operations such as email notifications as background processes.
- External integrations such as Stripe (for payment) and the email server.

##### Architectural Patterns and Technologies
- The backend follows a layered/MVC pattern: Controllers (presentation), Services (business logic), and Repositories (data).
- JWT-based security is implemented for authentication and authorization.
- The application uses dependency injection (Spring Boot) and leverages Mapstruct for mapping DTOs to entities.
- The frontend follows Angular’s component-based architecture with routing and service layers for API interaction.
- Maven and Node.js manage the build and dependency resolution for their respective layers.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Frontend Subgraph
  subgraph "Angular Frontend"
    A1("UI Pages"):::frontend
    A2("Hotel Info"):::frontend
    A3("Navbar"):::frontend
    A4("Angular Services"):::frontend
    A5("HTTP Interceptors (JWT)"):::frontend
  end

  %% Backend Subgraph
  subgraph "Spring Boot Backend"
    B0("Security Layer (JWT, CORS)"):::security
    C("REST Controllers"):::controller
    S_abs("Service Abstracts"):::service
    S_impl("Service Implementations"):::service
    R("Data Repositories"):::repository
    %% Domain Models & Mapping Subgraph
    subgraph "Domain Models & Mapping"
      DM1("Entities"):::domain
      DM2("Mappers"):::domain
      DM3("DTOs"):::domain
    end
    %% Infrastructure Subgraph
    subgraph "Infrastructure"
      I1("Security Configurations"):::security
      I2("Email Service"):::email
      I3("Stripe Config"):::payment
      I4("Global Exception Handler"):::exception
      I5("Scheduled Tasks"):::tasks
    end
  end

  %% External & Database Subgraph
  subgraph "External & Database"
    DB["PostgreSQL Database"]:::database
  end

  %% Frontend Connections
  A1 -->|"calls"| A4
  A2 -->|"calls"| A4
  A3 -->|"calls"| A4
  A4 -->|"uses"| A5
  A4 -->|"RESTAPICall"| C

  %% Backend Connections
  B0 --> C
  C -->|"calls"| S_impl
  S_impl -->|"uses"| R
  R -->|"persists to"| DB
  S_impl -->|"mapswith"| DM1
  S_impl -->|"mapswith"| DM2
  S_impl -->|"mapswith"| DM3
  I5 -->|"triggers"| I2

  %% Click Events
  click C "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/controller"
  click S_abs "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/service/abstracts"
  click S_impl "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/service/concretes"
  click R "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/repository"
  click DM1 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/model/entity"
  click DM2 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/mapper"
  click DM3 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/service/dtos"
  click I1 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/EasyStay-core/src/main/java/com/example/easystay/core/security/configurations"
  click I2 "https://github.com/ulasahin/hotelmanagementwebsite/blob/master/EasyStay-core/src/main/java/com/example/easystay/core/mail/EmailService.java"
  click I3 "https://github.com/ulasahin/hotelmanagementwebsite/blob/master/EasyStay-core/src/main/java/com/example/easystay/core/config/StripeConfig.java"
  click I4 "https://github.com/ulasahin/hotelmanagementwebsite/blob/master/EasyStay-core/src/main/java/com/example/easystay/core/exceptionhandling/configurations/GlobalExceptionHandler.java"
  click I5 "https://github.com/ulasahin/hotelmanagementwebsite/blob/master/EasyStay-core/src/main/java/com/example/easystay/core/tasks/ScheduledTasks.java"
  click A1 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/easystay-ui/src/app/pages"
  click A2 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/easystay-ui/src/app/hotel-info"
  click A3 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/easystay-ui/src/app/navbar"
  click A4 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/easystay-ui/src/app/services"
  click A5 "https://github.com/ulasahin/hotelmanagementwebsite/tree/master/easystay-ui/src/app/interceptors"

  %% Styles
  classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
  classDef controller fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
  classDef service fill:#F5CBA7,stroke:#A04000,stroke-width:2px;
  classDef repository fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
  classDef domain fill:#FADBD8,stroke:#922B21,stroke-width:2px;
  classDef security fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
  classDef email fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
  classDef payment fill:#EBDEF0,stroke:#6C3483,stroke-width:2px;
  classDef exception fill:#F9EBEA,stroke:#C0392B,stroke-width:2px;
  classDef tasks fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
  classDef database fill:#D6DBDF,stroke:#566573,stroke-width:2px;
```
