How mohamed-taman/hotel-booking-ai-assistant works
1. Overall shape
- This is a single Spring Boot application with a full-stack UI. The backend owns all business logic, persistence, AI orchestration, and endpoint exposure; the frontend is a Vaadin/Hilla React client bundled into the same deployable artifact.
2. Request entry points
- End users interact through the browser UI in src/main/frontend, which is built with React, TypeScript, and Vite.
- The UI talks to backend “UI services” under rs.siriusxi.hbca.ui, rather than calling repositories or AI code directly.
3. UI boundary
- AssistantUIService handles the chat conversation path.
- HotelBookingUIService exposes booking-related data to the UI.
- src/main/resources/META-INF/resources provides static assets such as global styling, while the React view files define the interactive chat screen.
4. Conversation / AI subsystem
- CustomerSupportAssistant is the AI-facing orchestration layer.
- It uses Spring AI to send user messages to an OpenAI chat model, maintain conversation context, and stream responses back to the UI.
- This layer is the main boundary between natural-language input and executable hotel operations.
5. Tool calling and business actions
- BookingToolsConfig wires “tools” that the model can invoke for real actions such as lookup, modification, or cancellation.
- This creates a controlled path from LLM intent → tool invocation → domain service execution, rather than letting the model access data directly.
6. Core business service
- HotelBookingService is the central domain service for booking operations.
- It enforces the booking rules and delegates to repositories for persistence.
- BookingDetailsMapper translates domain entities into UI-friendly DTOs, keeping the UI insulated from persistence details.
7. Persistence model
- The domain is intentionally small: Booking, Customer, BookingStatus, and RoomType.
- Data access is through Spring Data repositories: BookingRepository and CustomerRepository.
- The app uses a file-backed H2 database, with schema and seed data managed by Flyway migrations in src/main/resources/db/migration.
8. Knowledge / RAG layer
- Hotel policy text lives in booking-terms.txt.
- The app uses a file-backed vector store for retrieval-augmented generation so the assistant can answer policy questions and validate booking changes against the terms.
- SystemMessage.st holds the system prompt template that shapes assistant behavior.
9. Startup and wiring
- HCSAApplication is the Spring Boot entry point and is also where the vector-store initialization is tied into application startup.
- Configuration classes under config/ assemble the application context: general app wiring, AI tools, security, OpenTelemetry/logging, and context propagation.
10. Cross-cutting concerns
- SecurityConfig defines the request security boundary.
- TraceIdFilter, ContextPropagationConfiguration, and OpenTelemetryAppenderInstaller show that observability is a first-class concern: trace IDs are propagated into logs and telemetry can be exported via OpenTelemetry/OTLP.
- logback-spring.xml and application.yaml complete the runtime logging/telemetry setup.
11. Build and runtime topology
- The project is built with Maven, but it also has a Node/Vite toolchain for the frontend.
- Docker support packages the whole stack into one container; compose.yaml is present for optional local infrastructure.
- Tests are minimal in the repo snapshot, centered around application startup verification.
12. External dependencies that matter architecturally
- OpenAI is the main external AI service.
- A local OTLP-compatible backend can receive traces/metrics/logs if configured.
- No separate microservices are visible; the architecture is a modular monolith with clear internal layers: UI → AI orchestration → domain services → repositories → H2/Flyway, plus a side path to the vector store for policy retrieval.
Main entry points: CustomerSupportAssistant.java Support Assistant · HotelBookingService.java Booking Service · frontend React UI · AssistantUIService.java Assistant API
Components 20
Frontend UI
Browser client and UI-facing services.
- React UI · Interactive browser app built with React, TypeScript, and Vite.
src/main/frontend - Chat View · Main interactive chat screen and view entry files.
src/main/frontend/views/@index.tsx - Message UI · Message rendering and conversation list components.
src/main/frontend/components/Message.tsx - Static Assets · Global styles and other served static resources.
src/main/resources/META-INF/resources/styles.css - Assistant API · UI boundary for chat conversation requests and streaming responses.
src/main/java/rs/siriusxi/hbca/ui/AssistantUIService.java - Booking API · UI-facing service for booking data and detail retrieval.
src/main/java/rs/siriusxi/hbca/ui/HotelBookingUIService.java
AI Orchestration
Conversation handling, tool calling, and prompt/knowledge integration.
- Support Assistant · Coordinates model calls, context, and response streaming.
src/main/java/rs/siriusxi/hbca/service/ai/CustomerSupportAssistant.java - Tool Wiring · Registers model-invokable tools for booking lookup and modification.
src/main/java/rs/siriusxi/hbca/config/BookingToolsConfig.java - System Prompt · System message template that shapes assistant behavior.
src/main/resources/SystemMessage.st - Policy Text · Hotel booking terms used for retrieval and policy checks.
src/main/resources/booking-terms.txt
Domain Model
Booking rules, entities, repositories, and mapping.
- Booking Service · Central booking rules and persistence coordination.
src/main/java/rs/siriusxi/hbca/service/HotelBookingService.java - Details Mapper · Converts booking entities into UI-friendly DTOs.
src/main/java/rs/siriusxi/hbca/service/mapper/BookingDetailsMapper.java - Booking · Core booking aggregate persisted in the database.
src/main/java/rs/siriusxi/hbca/domain/Booking.java - Customer · Customer record associated with bookings.
src/main/java/rs/siriusxi/hbca/domain/Customer.java - Repositories · Persistence access for bookings and customers.
src/main/java/rs/siriusxi/hbca/repository/BookingRepository.java
Platform
Application bootstrap, configuration, persistence, and observability.
- App Bootstrap · Application startup and vector-store initialization.
src/main/java/rs/siriusxi/hbca/HCSAApplication.java - App Config · General application wiring and runtime configuration support.
src/main/java/rs/siriusxi/hbca/config/AppConfig.java - Security · Defines the request security boundary.
src/main/java/rs/siriusxi/hbca/config/SecurityConfig.java - Observability · Trace propagation, logging enrichment, and OpenTelemetry setup.
src/main/java/rs/siriusxi/hbca/config/ContextPropagationConfiguration.java - Data Layer · Flyway migrations and application data source/runtime configuration.
src/main/resources/db/migration/V1__Create_schema.sql
Connections 22
- React UI → Chat View: renders · The browser client mounts the main view.
- Chat View → Message UI: uses · The view composes message components.
- React UI → Assistant API: calls · UI requests chat responses from the assistant service.
- React UI → Booking API: calls · UI requests booking data from the booking service.
- Static Assets → React UI: styles · Shared static resources support the client UI.
- Assistant API → Support Assistant: delegates · UI boundary forwards conversation work to the AI orchestration layer.
- Support Assistant → Tool Wiring: invokes · Assistant can call booking tools during conversation.
- Support Assistant → System Prompt: shaped by · Prompt template guides assistant behavior.
- Support Assistant → Policy Text: retrieves · Policy text supports answer grounding and validation.
- Tool Wiring → Booking Service: executes · Tools route real actions into the booking service.
- Booking API → Details Mapper: formats · Booking UI service returns DTO-shaped data.
- Booking Service → Repositories: persists via · Booking logic delegates storage access to repositories.
- Booking Service → Booking: manages · Service operates on booking entities.
- Booking Service → Customer: reads/writes · Service coordinates customer data as part of booking operations.
- Details Mapper → Booking: maps · Mapper transforms booking entities for the UI.
- App Bootstrap → App Config: starts with · Bootstrap wires the application context.
- App Bootstrap → Data Layer: initializes · Startup ties into schema, seed data, and database setup.
- App Config → Security: includes · Configuration assembles security concerns.
- App Config → Observability: includes · Configuration assembles logging and telemetry concerns.
- Observability → Data Layer: exports · Observability can emit runtime signals around the data layer.
- Assistant API → Security: protected by · Assistant endpoints are subject to security configuration.
- Booking API → Security: protected by · Booking endpoints are subject to security configuration.