How samriddhibisht09/hotelms works
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: main.py FastAPI application · models.py Hotel domain models · hotels.py Hotel operations APIs · rag_service.py RAG service
Components 21
Static client
Server-mounted multi-page browser client.
- Browser pages · Multi-page guest, admin, and owner interfaces.
frontend/index.html - Browser API client · Shared browser-to-API communication.
frontend/js/api.js
FastAPI API
HTTP application, domain routes, and access control.
- ASGI entry · Re-exports the configured application.
main.py - FastAPI application · Configures routers, CORS, and frontend delivery.
backend/app/main.py - Auth dependencies · Resolves current users and role access.
backend/app/api/deps.py - JWT security · Central JWT authentication and security logic.
backend/app/core/security.py - Runtime settings
backend/app/core/config.py - Auth and user APIs · Authentication and user lifecycle endpoints.
backend/app/api/routes/auth.py - Admin and owner APIs · Administrative and hotel-owner controls.
backend/app/api/routes/admin.py - Hotel operations APIs · Hotels, rooms, amenities, bookings, reviews, and coupons.
backend/app/api/routes/hotels.py - Booking APIs
backend/app/api/routes/bookings.py - API contracts · Request and response contracts.
backend/app/schemas.py
Data platform
Relational persistence and schema evolution.
- Hotel domain models · Relational hotel-management domain.
backend/app/models.py - Database sessions · PostgreSQL persistence access.
backend/app/db/session.py - Schema migrations · 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 · Accepts hotel documents for ingestion.
backend/app/api/routes/documents.py - Document indexing · Loads, cleans, chunks, embeds, and indexes documents.
backend/app/rag/indexing.py - Vector retrieval · Queries indexed document chunks.
backend/app/rag/vector_search.py - AI APIs · AI-facing retrieval and chat endpoints.
backend/app/api/routes/ai.py - RAG service · Uses retrieved context to prepare AI responses.
backend/app/rag/rag_service.py - Groq integration
backend/app/services/groq_service.py
Connections 25
- 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