# oniely/luma-bookings architecture

> Architecture diagram of the GitHub repository oniely/luma-bookings, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oniely/luma-bookings
- Repository: https://github.com/oniely/luma-bookings

## Overview

##### Main Components
- Client/User Interface: Represent the browser/client side where users interact with the Next.js app.
- Next.js Application Server:
- Public/Root area: This includes pages for viewing rooms, room details, booking widgets, etc.
- Authentication & Authorization: The “(auth)” directory, handling login, registration, verification, and booking confirmation (likely integrating with external services like Cognito as seen in src/lib/cognito.ts).
- Administration Panel: The “(admin)” section that manages hotel bookings, hotel details, user accounts, events, and packages.
- API Endpoints: Under src/app/api, these endpoints (e.g., in auth/[...nextAuth]) handle server-side actions, authentication flows, and potentially other business logic.
- Business Logic & Utilities:
- Action Modules: In src/lib/action (auth, events, reviews, rooms, user, and userreservations), which encapsulate business operations.
- Data Layer Helpers: axios configuration, type definitions (src/lib/types.ts), schemas (src/lib/schema), state management (src/lib/store), and utilities.
- Static Assets:
- Public Directory: Fonts and images are served directly to the client.
- Next Font Optimization: Usage of next/font for optimizing font loading.
- Deployment & Configuration Components:
- Dockerfile, compose.yaml, .env.example, and related configuration (e.g., ESLint, PostCSS) indicate containerization and environment setup.

##### Relationships and Interactions
- Public UI (pages in (root)): Room listing, room detail, booking widget, home pages.
- Authentication Module (pages in (auth)): Login, registration, booking confirmation, verification.
- Administrative Module (pages in (admin)): Admin dashboard, managing hotels, users, bookings, events, packages.
- API Layer: Represent API Routes as an internal service that the UI modules call to perform server-side operations.
- An “Action/Business Logic Layer” that shows how API routes invoke functions in src/lib/action modules and utilities to perform tasks such as user authentication, booking processing, etc.
- Interaction with External Services:
- Integration with services like AWS Cognito (as indicated by src/lib/cognito.ts) for authentication.
- External dependencies such as Next.js’ built-in data fetching and routing mechanisms.

##### Architectural Patterns and Design Principles
- A modular design by clearly separating concerns:
- Presentation/UI: Next.js pages and React components (located under src/components).
- Business Logic: Encapsulated within “action” modules and utilities.
- API Layer: Serverless functions (or API routes) that mediate between front-end requests and business logic.
- Use of file-based routing: Highlight that the “app” directory structure (with nested folders like (admin), (auth), (root)) follows Next.js conventions.
- Containerization for Deployment: Indicate the use of Docker and Docker Compose to manage deployment environments.

##### Essential Elements
- Clear labels for each major component (Client, UI Modules, API Endpoints, Business Logic/Actions, Static Assets, and Deployment/configuration components).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser/Client"]:::client
    end

    %% Next.js Application Server
    subgraph "Next.js Application Server"
        PublicUI["Public UI ((root))"]:::server
        AuthModule["Authentication Module ((auth))"]:::server
        AdminPanel["Administration Panel ((admin))"]:::server
        API["API Endpoints"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        ActionModules["Action Modules"]:::business
        Utilities["Utilities & Helpers"]:::business
    end

    %% External Services
    subgraph "External Services"
        Cognito["AWS Cognito"]:::external
    end

    %% Static Assets
    subgraph "Static Assets"
        Assets["Static Assets (public)"]:::assets
    end

    %% Deployment & Configuration Components
    subgraph "Deployment & Config"
        Docker["Dockerfile"]:::deployment
        Compose["Compose (compose.yaml)"]:::deployment
        Env["Env (.env.example)"]:::deployment
        NextConfig["Next Config (next.config.ts)"]:::deployment
        PostCSS["PostCSS (postcss.config.mjs)"]:::deployment
        ESLint["ESLint (eslint.config.mjs)"]:::deployment
    end

    %% Data Flow Arrows
    Browser --->|"HTTP_Request"| PublicUI
    Browser --->|"HTTP_Request"| AuthModule
    Browser --->|"HTTP_Request"| AdminPanel

    PublicUI --->|"calls_API"| API
    AuthModule --->|"calls_API"| API
    AdminPanel --->|"calls_API"| API

    API --->|"invokes"| ActionModules
    API --->|"invokes"| Utilities

    ActionModules --->|"auth_flow"| Cognito

    %% Styles
    classDef client fill:#ffdddd,stroke:#d62728,stroke-width:2px;
    classDef server fill:#cce5ff,stroke:#2a9df4,stroke-width:2px;
    classDef api fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef business fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef assets fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef deployment fill:#d1d1e1,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#842029,stroke-width:2px;

    %% Click Events
    click PublicUI "https://github.com/oniely/luma-bookings/tree/main/src/app/(root)"
    click AuthModule "https://github.com/oniely/luma-bookings/tree/main/src/app/(auth)"
    click Cognito "https://github.com/oniely/luma-bookings/blob/main/src/lib/cognito.ts"
    click AdminPanel "https://github.com/oniely/luma-bookings/tree/main/src/app/(admin)"
    click API "https://github.com/oniely/luma-bookings/tree/main/src/app/api"
    click ActionModules "https://github.com/oniely/luma-bookings/tree/main/src/lib/action"
    click Utilities "https://github.com/oniely/luma-bookings/tree/main/src/lib"
    click Assets "https://github.com/oniely/luma-bookings/tree/main/public"
    click Docker "https://github.com/oniely/luma-bookings/tree/main/Dockerfile"
    click Compose "https://github.com/oniely/luma-bookings/blob/main/compose.yaml"
    click Env "https://github.com/oniely/luma-bookings/blob/main/.env.example"
    click NextConfig "https://github.com/oniely/luma-bookings/blob/main/next.config.ts"
    click PostCSS "https://github.com/oniely/luma-bookings/blob/main/postcss.config.mjs"
    click ESLint "https://github.com/oniely/luma-bookings/blob/main/eslint.config.mjs"
```
