# samriddhibisht09/hotelms architecture

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

- Interactive diagram: https://gitdiagram.com/samriddhibisht09/hotelms
- Repository: https://github.com/samriddhibisht09/hotelms

## Overview

#### Purpose and Entry Points
This is a hotel booking and management system with a FastAPI backend and static HTML/CSS/JavaScript client. The deployable ASGI entry point is `main.py`, which re-exports the application created in `backend/app/main.py`. The backend also mounts and serves the frontend.

#### API Application Boundary
`backend/app/main.py` configures FastAPI, CORS, feature routers, and frontend delivery. HTTP endpoints are organized by domain under `backend/app/api/routes/`, with shared authentication, current-user lookup, and role authorization dependencies in `backend/app/api/deps.py`.

#### Identity and Authorization
JWT-based authentication and security primitives are centralized in `backend/app/core/security.py`; runtime settings are loaded through `backend/app/core/config.py`. Auth and user lifecycle APIs reside in `backend/app/api/routes/auth.py` and `backend/app/api/routes/users.py`. Administrative and hotel-owner controls are exposed through `backend/app/api/routes/admin.py`.

#### Hotel Operations Domain
The relational domain is defined in `backend/app/models.py`, with request/response contracts in `backend/app/schemas.py`. Core business APIs cover hotels, rooms, amenities, bookings, reviews, and coupons through paths such as `backend/app/api/routes/hotels.py`, `backend/app/api/routes/rooms.py`, and `backend/app/api/routes/bookings.py`. This is the principal boundary between the static client and persisted hotel-management data.

#### Persistence and Schema Evolution
The application uses SQLAlchemy sessions from `backend/app/db/session.py` against PostgreSQL. Alembic manages schema evolution under `backend/alembic/versions/`, including the initial model schema and later hotel-document and pgvector chunk additions in `backend/alembic/versions/f1a2b3c4d5e6_add_document_chunks_pgvector.py`. Seed data can be initialized through `backend/app/seed.py`.

#### Document Knowledge and AI Retrieval
Hotel documents are accepted through `backend/app/api/routes/documents.py` and processed by the RAG pipeline in `backend/app/rag/`. The flow is document loading/cleaning/chunking, embedding, storage/indexing, then vector retrieval: `backend/app/rag/document_loader.py`, `backend/app/rag/indexing.py`, and `backend/app/rag/vector_search.py`. Retrieved context is used by `backend/app/rag/rag_service.py`; AI-facing endpoints are in `backend/app/api/routes/ai.py`. Groq is the external LLM integration via `backend/app/services/groq_service.py`.

#### Frontend Client
The frontend is a server-mounted, multi-page static client rooted at `frontend/index.html`. Shared browser-to-API integration is concentrated in `frontend/js/api.js`, with feature scripts such as `frontend/js/auth.js`, `frontend/js/bookings.js`, and `frontend/js/chat.js`. Separate admin and owner dashboard pages provide role-specific operational views.

Main entry points: [`backend/app/main.py`](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/main.py) (FastAPI application), [`backend/app/models.py`](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/models.py) (Hotel domain models), [`backend/app/api/routes/hotels.py`](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/hotels.py) (Hotel operations APIs), [`backend/app/rag/rag_service.py`](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/rag_service.py) (RAG service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Static client"]
  node_frontend_pages["Browser pages<br/>static HTML<br/>[index.html]"]
  node_frontend_api["Browser API client<br/>JavaScript integration<br/>[api.js]"]
end

subgraph group_api["FastAPI API"]
  node_asgi_entry["ASGI entry<br/>Python entry point<br/>[main.py]"]
  node_app["FastAPI application<br/>application boundary<br/>[main.py]"]
  node_auth_deps["Auth dependencies<br/>request authorization<br/>[deps.py]"]
  node_security["JWT security<br/>identity primitives<br/>[security.py]"]
  node_settings["Runtime settings<br/>configuration<br/>[config.py]"]
  node_identity_routes["Auth and user APIs<br/>route modules<br/>[auth.py]"]
  node_admin_routes["Admin and owner APIs<br/>route module<br/>[admin.py]"]
  node_hotel_routes["Hotel operations APIs<br/>route modules<br/>[hotels.py]"]
  node_booking_routes["Booking APIs<br/>route module<br/>[bookings.py]"]
  node_contracts["API contracts<br/>schemas<br/>[schemas.py]"]
end

subgraph group_data["Data platform"]
  node_domain_models["Hotel domain models<br/>SQLAlchemy models<br/>[models.py]"]
  node_db_session[("Database sessions<br/>SQLAlchemy session<br/>[session.py]")]
  node_migrations["Schema migrations<br/>Alembic versions"]
end

subgraph group_rag["Document AI"]
  node_document_routes["Document APIs<br/>route module<br/>[documents.py]"]
  node_rag_indexing["Document indexing<br/>RAG pipeline<br/>[indexing.py]"]
  node_vector_search["Vector retrieval<br/>RAG retrieval<br/>[vector_search.py]"]
  node_ai_routes["AI APIs<br/>route module<br/>[ai.py]"]
  node_rag_service["RAG service<br/>context orchestration<br/>[rag_service.py]"]
  node_groq{{"Groq integration<br/>external LLM service<br/>[groq_service.py]"}}
end

node_asgi_entry -->|"exports"| node_app
node_app -->|"serves"| node_frontend_pages
node_frontend_pages -->|"uses"| node_frontend_api
node_frontend_api -->|"HTTP requests"| node_app
node_app -->|"mounts"| node_identity_routes
node_app -->|"mounts"| node_admin_routes
node_app -->|"mounts"| node_hotel_routes
node_app -->|"mounts"| node_booking_routes
node_app -->|"mounts"| node_document_routes
node_app -->|"mounts"| node_ai_routes
node_identity_routes -->|"uses"| node_auth_deps
node_admin_routes -->|"uses"| node_auth_deps
node_auth_deps -->|"validates JWTs"| node_security
node_app -->|"loads"| node_settings
node_hotel_routes -->|"uses"| node_contracts
node_hotel_routes -->|"manages"| node_domain_models
node_booking_routes -->|"persists"| node_domain_models
node_domain_models -->|"stored through"| node_db_session
node_migrations -->|"evolves schema for"| node_domain_models
node_document_routes -->|"ingests into"| node_rag_indexing
node_rag_indexing -->|"stores chunks and vectors"| node_db_session
node_ai_routes -->|"queries"| node_rag_service
node_rag_service -->|"retrieves context"| node_vector_search
node_vector_search -->|"searches vectors"| node_db_session
node_rag_service -->|"generates with"| node_groq

click node_asgi_entry "https://github.com/samriddhibisht09/hotelms/blob/master/main.py"
click node_app "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/main.py"
click node_auth_deps "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/deps.py"
click node_security "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/core/security.py"
click node_settings "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/core/config.py"
click node_identity_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/auth.py"
click node_admin_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/admin.py"
click node_hotel_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/hotels.py"
click node_booking_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/bookings.py"
click node_frontend_pages "https://github.com/samriddhibisht09/hotelms/blob/master/frontend/index.html"
click node_frontend_api "https://github.com/samriddhibisht09/hotelms/blob/master/frontend/js/api.js"
click node_domain_models "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/models.py"
click node_contracts "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/schemas.py"
click node_db_session "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/db/session.py"
click node_migrations "https://github.com/samriddhibisht09/hotelms/blob/master/backend/alembic/versions/f1a2b3c4d5e6_add_document_chunks_pgvector.py"
click node_document_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/documents.py"
click node_rag_indexing "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/indexing.py"
click node_vector_search "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/vector_search.py"
click node_ai_routes "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/ai.py"
click node_rag_service "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/rag_service.py"
click node_groq "https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/services/groq_service.py"

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_frontend_pages,node_frontend_api toneBlue
class node_asgi_entry,node_app,node_auth_deps,node_security,node_settings,node_identity_routes,node_admin_routes,node_hotel_routes,node_booking_routes,node_contracts toneAmber
class node_domain_models,node_db_session,node_migrations toneMint
class node_document_routes,node_rag_indexing,node_vector_search,node_ai_routes,node_rag_service,node_groq toneRose
```

## Components

### Static client

Server-mounted multi-page browser client.

- [Browser pages](https://github.com/samriddhibisht09/hotelms/blob/master/frontend/index.html): static HTML · Multi-page guest, admin, and owner interfaces. · `frontend/index.html`
- [Browser API client](https://github.com/samriddhibisht09/hotelms/blob/master/frontend/js/api.js): JavaScript integration · Shared browser-to-API communication. · `frontend/js/api.js`

### FastAPI API

HTTP application, domain routes, and access control.

- [ASGI entry](https://github.com/samriddhibisht09/hotelms/blob/master/main.py): Python entry point · Re-exports the configured application. · `main.py`
- [FastAPI application](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/main.py): application boundary · Configures routers, CORS, and frontend delivery. · `backend/app/main.py`
- [Auth dependencies](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/deps.py): request authorization · Resolves current users and role access. · `backend/app/api/deps.py`
- [JWT security](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/core/security.py): identity primitives · Central JWT authentication and security logic. · `backend/app/core/security.py`
- [Runtime settings](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/core/config.py): configuration · `backend/app/core/config.py`
- [Auth and user APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/auth.py): route modules · Authentication and user lifecycle endpoints. · `backend/app/api/routes/auth.py`
- [Admin and owner APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/admin.py): route module · Administrative and hotel-owner controls. · `backend/app/api/routes/admin.py`
- [Hotel operations APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/hotels.py): route modules · Hotels, rooms, amenities, bookings, reviews, and coupons. · `backend/app/api/routes/hotels.py`
- [Booking APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/bookings.py): route module · `backend/app/api/routes/bookings.py`
- [API contracts](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/schemas.py): schemas · Request and response contracts. · `backend/app/schemas.py`

### Data platform

Relational persistence and schema evolution.

- [Hotel domain models](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/models.py): SQLAlchemy models · Relational hotel-management domain. · `backend/app/models.py`
- [Database sessions](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/db/session.py): SQLAlchemy session · PostgreSQL persistence access. · `backend/app/db/session.py`
- [Schema migrations](https://github.com/samriddhibisht09/hotelms/blob/master/backend/alembic/versions/f1a2b3c4d5e6_add_document_chunks_pgvector.py): Alembic versions · Includes document and pgvector schema additions. · `backend/alembic/versions/f1a2b3c4d5e6_add_document_chunks_pgvector.py`

### Document AI

Hotel-document indexing, retrieval, and LLM responses.

- [Document APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/documents.py): route module · Accepts hotel documents for ingestion. · `backend/app/api/routes/documents.py`
- [Document indexing](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/indexing.py): RAG pipeline · Loads, cleans, chunks, embeds, and indexes documents. · `backend/app/rag/indexing.py`
- [Vector retrieval](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/vector_search.py): RAG retrieval · Queries indexed document chunks. · `backend/app/rag/vector_search.py`
- [AI APIs](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/api/routes/ai.py): route module · AI-facing retrieval and chat endpoints. · `backend/app/api/routes/ai.py`
- [RAG service](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/rag/rag_service.py): context orchestration · Uses retrieved context to prepare AI responses. · `backend/app/rag/rag_service.py`
- [Groq integration](https://github.com/samriddhibisht09/hotelms/blob/master/backend/app/services/groq_service.py): external LLM service · `backend/app/services/groq_service.py`

## Connections

- ASGI entry → FastAPI application: exports
- FastAPI application → Browser pages: serves
- Browser pages → Browser API client: uses
- Browser API client → FastAPI application: HTTP requests
- FastAPI application → Auth and user APIs: mounts
- FastAPI application → Admin and owner APIs: mounts
- FastAPI application → Hotel operations APIs: mounts
- FastAPI application → Booking APIs: mounts
- FastAPI application → Document APIs: mounts
- FastAPI application → AI APIs: mounts
- Auth and user APIs → Auth dependencies: uses
- Admin and owner APIs → Auth dependencies: uses
- Auth dependencies → JWT security: validates JWTs
- FastAPI application → Runtime settings: loads
- Hotel operations APIs → API contracts: uses
- Hotel operations APIs → Hotel domain models: manages
- Booking APIs → Hotel domain models: persists
- Hotel domain models → Database sessions: stored through
- Schema migrations → Hotel domain models: evolves schema for
- Document APIs → Document indexing: ingests into
- Document indexing → Database sessions: stores chunks and vectors
- AI APIs → RAG service: queries
- RAG service → Vector retrieval: retrieves context
- Vector retrieval → Database sessions: searches vectors
- RAG service → Groq integration: generates with
