# laribright/hotel-management architecture

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

- Interactive diagram: https://gitdiagram.com/laribright/hotel-management
- Repository: https://github.com/laribright/hotel-management

## Overview

##### Main Components

A. Frontend Layer:
- Next.js App Router Structure
- Web Routes ((web) directory)
- CMS Routes ((cms) directory)
- Component Library
- Theme Provider System
- Authentication Provider

B. Backend Layer:
- API Routes
- Authentication System (NextAuth.js)
- Middleware
- External Services Integration

C. Database & CMS:
- Sanity CMS
- Database Models (User, Room, Booking, Review)

D. External Services:
- Stripe Payment Integration
- Image Storage

**┌─ Client Layer ─────────────────────┐**
- Next.js Frontend                 │
- React Components                 │
- Theme System                     │
- ┬───────────────────┘
- ↓
**┌─ Application Layer ─────────────────┐**
- API Routes                        │
- Authentication                    │
- Business Logic                    │
- ┬───────────────────┘
- ↓
**┌─ Data & Services Layer ─────────────┐**
- Sanity CMS                        │
- Stripe Integration                │
- Storage                           │
- ┘

##### Specific Implementation Details

A. Frontend Components (Blue):
- Route structure (/rooms, /auth, /users)
- Components (Header, Footer, BookRoomCta)
- Theme and Auth providers

B. API Layer (Green):
- API routes (/api/auth, /api/room-reviews, /api/stripe)
- Middleware connections
- Authentication flow

C. Data & Services (Purple/Orange):
- Sanity CMS integration
- Stripe payment processing
- User data flow
- Booking system

##### Important Flows to Highlight

- Authentication Flow:
- User → Auth Provider → NextAuth → Sanity
- Booking Flow:
- User → Room Selection → Stripe → Booking Confirmation
- Review System:
- User → Room Review → API → Sanity CMS

##### Technical Stack Callouts

- Next.js 13+ with App Router
- Sanity CMS
- NextAuth.js
- Stripe Payment
- TypeScript
- Tailwind CSS

Remember to include:
- Component dependencies
- Data flow directions
- Security boundaries
- Integration points
- State management
- Error handling paths

This will provide a complete picture of the application's architecture while remaining accessible to other developers.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WebRoutes["Web Routes"]
        CMSRoutes["CMS Routes"]
        Components["Component Library"]
        ThemeProvider["Theme Provider"]
        AuthProvider["Auth Provider"]
        
        Components --> |Uses| ThemeProvider
        Components --> |Uses| AuthProvider
    end

    subgraph Application
        APIRoutes["API Routes"]
        AuthSystem["Auth System"]
        Middleware["Middleware"]
        APIUtils["API Utilities"]
        
        AuthSystem --> Middleware
        APIRoutes --> APIUtils
    end

    subgraph Data
        SanityCMS["Sanity CMS"]
        StripePayment["Stripe Payment"]
        Models["Database Models"]
        Schemas["Database Schemas"]
    end

    %% Core Component Details
    Components --> Header["Header Component"]
    Components --> Footer["Footer Component"]
    Components --> BookRoom["Book Room CTA"]
    Components --> RoomCard["Room Card"]

    %% Connections between layers
    WebRoutes --> APIRoutes
    CMSRoutes --> APIRoutes
    AuthProvider --> AuthSystem
    APIRoutes --> SanityCMS
    APIRoutes --> StripePayment
    SanityCMS --> Models
    SanityCMS --> Schemas

    %% Click events for component mapping
    click WebRoutes "https://github.com/laribright/hotel-management/tree/master/src/app/(web)"
    click CMSRoutes "https://github.com/laribright/hotel-management/tree/master/src/app/(cms)"
    click AuthProvider "https://github.com/laribright/hotel-management/blob/master/src/components/AuthProvider/AuthProvider.tsx"
    click ThemeProvider "https://github.com/laribright/hotel-management/blob/master/src/components/ThemeProvider/ThemeProvider.tsx"
    click APIRoutes "https://github.com/laribright/hotel-management/tree/master/src/app/api"
    click AuthSystem "https://github.com/laribright/hotel-management/blob/master/src/app/api/auth/[...nextauth]/route.ts"
    click Middleware "https://github.com/laribright/hotel-management/blob/master/src/middleware.ts"
    click SanityCMS "https://github.com/laribright/hotel-management/blob/master/src/libs/sanity.ts"
    click Models "https://github.com/laribright/hotel-management/tree/master/src/models"
    click StripePayment "https://github.com/laribright/hotel-management/blob/master/src/libs/stripe.ts"
    click Schemas "https://github.com/laribright/hotel-management/tree/master/schemas"
    click Header "https://github.com/laribright/hotel-management/blob/master/src/components/Header/Header.tsx"
    click Footer "https://github.com/laribright/hotel-management/blob/master/src/components/Footer/Footer.tsx"
    click BookRoom "https://github.com/laribright/hotel-management/blob/master/src/components/BookRoomCta/BookRoomCta.tsx"
    click RoomCard "https://github.com/laribright/hotel-management/blob/master/src/components/RoomCard/RoomCard.tsx"
    click APIUtils "https://github.com/laribright/hotel-management/blob/master/src/libs/apis.ts"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef data fill:#9C27B0,color:white
    classDef component fill:#03A9F4,color:white
    classDef external fill:#FF9800,color:white

    class WebRoutes,CMSRoutes,Components,ThemeProvider,AuthProvider frontend
    class APIRoutes,AuthSystem,Middleware,APIUtils backend
    class SanityCMS,Models,Schemas data
    class Header,Footer,BookRoom,RoomCard component
    class StripePayment external
```
