# riddhisf/hotelmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/riddhisf/hotelmanagement
- Repository: https://github.com/riddhisf/hotelmanagement

## Overview

1. **Overall shape**
   - This is a **Spring Boot** hotel-management backend built as a thin, data-centric application.
   - The codebase is organized around **JPA entities + Spring Data repositories**, with REST exposure and response shaping handled mostly through Spring Data infrastructure rather than a separate service layer.

2. **Application entrypoint**
   - `HotelApplication.java` is the bootstrap class that starts the Spring context.
   - `pom.xml` and the Maven wrapper indicate a standard Maven-based Java build and test pipeline.

3. **Domain model**
   - The core business objects are in `entities/`: `Hotel`, `Room`, `RoomType`, `Amenity`, `Reservation`, `Review`, and `Payment`.
   - These represent the main persistence boundaries and likely map directly to relational tables.

4. **Relationship modeling**
   - `HotelAmenity` and `RoomAmenity` are association entities that model many-to-many links between hotels/rooms and amenities.
   - `HotelAmenityId` and `RoomAmenityId` in `dtos/` are composite key types used to support those join tables cleanly.

5. **Persistence layer**
   - The `repositories/` package contains the primary data access surface: one repository per aggregate/table.
   - There is no visible service layer; the architecture likely relies on repository methods and query derivation for most data operations.

6. **REST/API exposure**
   - `config/RestConfig.java` suggests repository exposure and REST behavior are customized centrally.
   - The presence of `MockMvc`-based tests for repository APIs strongly suggests the app uses **Spring Data REST** or a similar repository-driven REST exposure model, rather than hand-written controllers.

7. **Response shaping**
   - The `projections/` package defines multiple output views such as `HotelProjections`, `RoomProjections`, `ReservationProjection`, `ReviewProjection`, and amenity-related projections.
   - These are used to control what fields and nested relationships are returned over the API, reducing payload size and avoiding overexposing entities.

8. **Error handling boundary**
   - `exceptions/GlobalExceptionHandler.java` provides centralized exception-to-response mapping.
   - This is the main cross-cutting boundary for translating persistence/API errors into consistent HTTP responses.

9. **Data flow**
   - Typical flow is: HTTP request → repository-backed REST endpoint → JPA entity/repository access → database → projection/JSON serialization back to the client.
   - Because there is no visible service orchestration layer, the repository and projection layers are the main functional center of the system.

10. **Testing strategy**
   - Tests are split between repository/unit-style tests and API-style tests using `MockMvc`.
   - This indicates two important verification boundaries: persistence behavior for entities/queries, and REST contract behavior for exposed repository endpoints.

11. **Environment/configuration**
   - `application.properties` and `application-test.properties` separate runtime and test configuration, likely for database settings and Spring Data REST behavior.
   - `.env` is present, suggesting some runtime values may be injected externally, though the repo itself is still centered on Spring configuration files.

12. **Architecture summary for a diagram**
   - The key boxes to draw are: **REST exposure/config**, **projection layer**, **repository layer**, **JPA entity model**, and **relational database**.
   - Surrounding that are **global exception handling** and **test suites** that validate both repository logic and HTTP-facing behavior.

Main entry points: [`src/main/java/com/capg/hotel/config/RestConfig.java`](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/config/RestConfig.java) (REST config), [`src/main/java/com/capg/hotel/repositories/HotelRepository.java`](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/HotelRepository.java) (Hotel repo), [`src/main/java/com/capg/hotel/entities/Amenity.java`](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Amenity.java) (Amenity), [`src/main/java/com/capg/hotel/HotelApplication.java`](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/HotelApplication.java) (Hotel app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API boundary"]
  node_app(("Hotel app<br/>spring boot entrypoint"))
  node_restconfig["REST config<br/>[RestConfig.java]"]
  node_errors["Errors<br/>exception handler"]
  node_hotelproj["Hotel views<br/>projection"]
  node_roomproj["Room views<br/>projection"]
  node_reservationproj["Reservation view<br/>projection"]
  node_reviewproj["Review view<br/>projection"]
  node_amenityproj["Amenity views<br/>projection"]
  node_roomtypeproj["Room type view<br/>projection"]
end

subgraph group_persistence["Persistence"]
  node_hotelrepo["Hotel repo<br/>spring data repository"]
  node_roomrepo["Room repo<br/>spring data repository"]
  node_reservationrepo["Reservation repo<br/>spring data repository"]
  node_reviewrepo["Review repo<br/>spring data repository"]
  node_amenityrepo["Amenity repo<br/>spring data repository"]
  node_roomtyperepo["Room type repo<br/>spring data repository"]
  node_linkrepos["Link repos<br/>association repositories"]
  node_hotel[("Hotel<br/>jpa entity<br/>[Hotel.java]")]
  node_room[("Room<br/>jpa entity<br/>[Room.java]")]
  node_reservation[("Reservation<br/>jpa entity<br/>[Reservation.java]")]
  node_amenity[("Amenity<br/>jpa entity<br/>[Amenity.java]")]
  node_roomtype[("Room type<br/>jpa entity<br/>[RoomType.java]")]
  node_payment[("Payment<br/>jpa entity<br/>[Payment.java]")]
  node_joinentities[("Join entities<br/>association entities<br/>[HotelAmenity.java]")]
  node_joinids["Join IDs<br/>composite keys"]
  node_db[("Relational DB<br/>database")]
end

subgraph group_tests["Tests"]
  node_apitests["API tests<br/>mockmvc tests"]
  node_repotests["Repo tests<br/>repository tests"]
end

node_app -->|"loads"| node_restconfig
node_app -->|"exposes"| node_hotelrepo
node_app -->|"wires"| node_errors
node_restconfig -->|"configures"| node_hotelrepo
node_restconfig -->|"configures"| node_roomrepo
node_restconfig -->|"configures"| node_reservationrepo
node_restconfig -->|"configures"| node_amenityrepo
node_restconfig -->|"configures"| node_roomtyperepo
node_hotelrepo -->|"persists"| node_hotel
node_roomrepo -->|"persists"| node_room
node_reservationrepo -->|"persists"| node_reservation
node_reviewrepo -->|"serves"| node_reviewproj
node_amenityrepo -->|"persists"| node_amenity
node_roomtyperepo -->|"persists"| node_roomtype
node_linkrepos -->|"persists"| node_joinentities
node_hotelproj -->|"shapes"| node_hotel
node_roomproj -->|"shapes"| node_room
node_reservationproj -->|"shapes"| node_reservation
node_reviewproj -->|"reads"| node_reviewrepo
node_amenityproj -->|"shapes"| node_amenity
node_roomtypeproj -->|"shapes"| node_roomtype
node_joinentities -->|"keys"| node_joinids
node_joinentities -->|"links"| node_amenity
node_hotel -->|"stores"| node_db
node_room -->|"stores"| node_db
node_reservation -->|"stores"| node_db
node_amenity -->|"stores"| node_db
node_roomtype -->|"stores"| node_db
node_payment -->|"stores"| node_db
node_apitests -->|"verifies"| node_restconfig
node_apitests -->|"verifies"| node_hotelrepo
node_repotests -->|"verifies"| node_hotelrepo
node_repotests -->|"verifies"| node_roomrepo
node_repotests -->|"verifies"| node_reservationrepo
node_errors -->|"protects"| node_apitests

click node_app "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/HotelApplication.java"
click node_restconfig "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/config/RestConfig.java"
click node_errors "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/exceptions/GlobalExceptionHandler.java"
click node_hotelproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/HotelProjections.java"
click node_roomproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/RoomProjections.java"
click node_reservationproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/ReservationProjection.java"
click node_reviewproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/ReviewProjection.java"
click node_amenityproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/AmenityProjection.java"
click node_roomtypeproj "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/RoomTypeProjections.java"
click node_hotelrepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/HotelRepository.java"
click node_roomrepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/RoomRepository.java"
click node_reservationrepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/ReservationRepository.java"
click node_reviewrepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/ReviewRepository.java"
click node_amenityrepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/AmenityRepository.java"
click node_roomtyperepo "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/RoomTypeRepository.java"
click node_hotel "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Hotel.java"
click node_room "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Room.java"
click node_reservation "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Reservation.java"
click node_amenity "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Amenity.java"
click node_roomtype "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/RoomType.java"
click node_payment "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Payment.java"
click node_joinentities "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/HotelAmenity.java"
click node_joinids "https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/dtos/HotelAmenityId.java"
click node_apitests "https://github.com/riddhisf/hotelmanagement/blob/main/src/test/java/com/capg/hotel/Repositories/HotelRepositoryMockMvcTest.java"
click node_repotests "https://github.com/riddhisf/hotelmanagement/blob/main/src/test/java/com/capg/hotel/repositories/HotelRepositoryTest.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_restconfig,node_errors,node_hotelproj,node_roomproj,node_reservationproj,node_reviewproj,node_amenityproj,node_roomtypeproj toneBlue
class node_hotelrepo,node_roomrepo,node_reservationrepo,node_reviewrepo,node_amenityrepo,node_roomtyperepo,node_linkrepos,node_hotel,node_room,node_reservation,node_amenity,node_roomtype,node_payment,node_joinentities,node_joinids,node_db toneAmber
class node_apitests,node_repotests toneMint
```

## Components

### API boundary

Bootstrapping, REST exposure, projections, and centralized error handling.

- [Hotel app](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/HotelApplication.java): spring boot entrypoint · Bootstraps the Spring context for the hotel management backend. · `src/main/java/com/capg/hotel/HotelApplication.java`
- [REST config](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/config/RestConfig.java): spring data rest config · Centralizes repository exposure and REST behavior. · `src/main/java/com/capg/hotel/config/RestConfig.java`
- [Errors](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/exceptions/GlobalExceptionHandler.java): exception handler · Maps application and persistence errors into consistent HTTP responses. · `src/main/java/com/capg/hotel/exceptions/GlobalExceptionHandler.java`
- [Hotel views](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/HotelProjections.java): projection · Shapes hotel API responses. · `src/main/java/com/capg/hotel/projections/HotelProjections.java`
- [Room views](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/RoomProjections.java): projection · Shapes room API responses. · `src/main/java/com/capg/hotel/projections/RoomProjections.java`
- [Reservation view](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/ReservationProjection.java): projection · Shapes reservation API responses. · `src/main/java/com/capg/hotel/projections/ReservationProjection.java`
- [Review view](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/ReviewProjection.java): projection · Shapes review API responses. · `src/main/java/com/capg/hotel/projections/ReviewProjection.java`
- [Amenity views](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/AmenityProjection.java): projection · Shapes amenity-related API responses, including linked hotels and rooms. · `src/main/java/com/capg/hotel/projections/AmenityProjection.java`
- [Room type view](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/projections/RoomTypeProjections.java): projection · Shapes room type API responses. · `src/main/java/com/capg/hotel/projections/RoomTypeProjections.java`

### Persistence

Repositories and the JPA-backed domain model.

- [Hotel repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/HotelRepository.java): spring data repository · Persistence API for hotels. · `src/main/java/com/capg/hotel/repositories/HotelRepository.java`
- [Room repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/RoomRepository.java): spring data repository · Persistence API for rooms. · `src/main/java/com/capg/hotel/repositories/RoomRepository.java`
- [Reservation repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/ReservationRepository.java): spring data repository · Persistence API for reservations. · `src/main/java/com/capg/hotel/repositories/ReservationRepository.java`
- [Review repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/ReviewRepository.java): spring data repository · Persistence API for reviews. · `src/main/java/com/capg/hotel/repositories/ReviewRepository.java`
- [Amenity repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/AmenityRepository.java): spring data repository · Persistence API for amenities. · `src/main/java/com/capg/hotel/repositories/AmenityRepository.java`
- [Room type repo](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/repositories/RoomTypeRepository.java): spring data repository · Persistence API for room types. · `src/main/java/com/capg/hotel/repositories/RoomTypeRepository.java`
- **Link repos**: association repositories · Persistence APIs for hotel-amenity and room-amenity join entities.
- [Hotel](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Hotel.java): jpa entity · Core lodging aggregate persisted as a relational table. · `src/main/java/com/capg/hotel/entities/Hotel.java`
- [Room](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Room.java): jpa entity · Room inventory and availability boundary. · `src/main/java/com/capg/hotel/entities/Room.java`
- [Reservation](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Reservation.java): jpa entity · Booking record and lifecycle boundary. · `src/main/java/com/capg/hotel/entities/Reservation.java`
- [Amenity](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Amenity.java): jpa entity · Reusable feature or service attached to hotels and rooms. · `src/main/java/com/capg/hotel/entities/Amenity.java`
- [Room type](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/RoomType.java): jpa entity · Categorizes rooms by class or configuration. · `src/main/java/com/capg/hotel/entities/RoomType.java`
- [Payment](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/Payment.java): jpa entity · Payment record associated with reservations. · `src/main/java/com/capg/hotel/entities/Payment.java`
- [Join entities](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/entities/HotelAmenity.java): association entities · Many-to-many link rows for hotel and room amenity relationships. · `src/main/java/com/capg/hotel/entities/HotelAmenity.java`
- [Join IDs](https://github.com/riddhisf/hotelmanagement/blob/main/src/main/java/com/capg/hotel/dtos/HotelAmenityId.java): composite keys · Composite key types used by amenity join tables. · `src/main/java/com/capg/hotel/dtos/HotelAmenityId.java`
- **Relational DB**: database · Back-end relational persistence store.

### Tests

API and repository-level verification.

- [API tests](https://github.com/riddhisf/hotelmanagement/blob/main/src/test/java/com/capg/hotel/Repositories/HotelRepositoryMockMvcTest.java): mockmvc tests · Verifies repository-exposed HTTP behavior and contracts. · `src/test/java/com/capg/hotel/Repositories/HotelRepositoryMockMvcTest.java`
- [Repo tests](https://github.com/riddhisf/hotelmanagement/blob/main/src/test/java/com/capg/hotel/repositories/HotelRepositoryTest.java): repository tests · Verifies query behavior, persistence mapping, and repository logic. · `src/test/java/com/capg/hotel/repositories/HotelRepositoryTest.java`

## Connections

- Hotel app → REST config: loads · Application startup activates REST configuration.
- Hotel app → Hotel repo: exposes · Bootstraps repository-backed API endpoints.
- Hotel app → Errors: wires · Registers centralized exception handling.
- REST config → Hotel repo: configures · Controls repository exposure and REST behavior.
- REST config → Room repo: configures · Controls repository exposure and REST behavior.
- REST config → Reservation repo: configures · Controls repository exposure and REST behavior.
- REST config → Amenity repo: configures · Controls repository exposure and REST behavior.
- REST config → Room type repo: configures · Controls repository exposure and REST behavior.
- Hotel repo → Hotel: persists · Repository manages hotel entities.
- Room repo → Room: persists · Repository manages room entities.
- Reservation repo → Reservation: persists · Repository manages reservation entities.
- Review repo → Review view: serves · Review repository data is exposed through projection views.
- Amenity repo → Amenity: persists · Repository manages amenity entities.
- Room type repo → Room type: persists · Repository manages room type entities.
- Link repos → Join entities: persists · Repositories manage association rows.
- Hotel views → Hotel: shapes · Hotel response views are built from hotel entities.
- Room views → Room: shapes · Room response views are built from room entities.
- Reservation view → Reservation: shapes · Reservation response views are built from reservation entities.
- Review view → Review repo: reads · Review projection layer sits on top of repository-backed data.
- Amenity views → Amenity: shapes · Amenity response views are built from amenity entities.
- Room type view → Room type: shapes · Room type response views are built from room type entities.
- Join entities → Join IDs: keys · Association entities use composite ID types.
- Join entities → Amenity: links · Join tables connect amenities to hotels and rooms.
- Hotel → Relational DB: stores · Hotel state is persisted in the database.
- Room → Relational DB: stores · Room state is persisted in the database.
- Reservation → Relational DB: stores · Reservation state is persisted in the database.
- Amenity → Relational DB: stores · Amenity state is persisted in the database.
- Room type → Relational DB: stores · Room type state is persisted in the database.
- Payment → Relational DB: stores · Payment state is persisted in the database.
- API tests → REST config: verifies · API tests exercise repository-exposed REST behavior.
- API tests → Hotel repo: verifies · HTTP tests cover repository endpoints.
- Repo tests → Hotel repo: verifies · Repository tests cover persistence behavior.
- Repo tests → Room repo: verifies · Repository tests cover persistence behavior.
- Repo tests → Reservation repo: verifies · Repository tests cover persistence behavior.
- Errors → API tests: protects · Central error handling affects API contract behavior.
