# monil80/booking-system architecture

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

- Interactive diagram: https://gitdiagram.com/monil80/booking-system
- Repository: https://github.com/monil80/booking-system

## Overview

##### Main Components
- Frontend: The booking-system-frontend folder contains a Next.js (v15) application that uses the App Router, Tailwind CSS, and Shadcn for UI. It includes application pages for authentication (login, signup, demo) and main functionalities such as booking, dashboard, and shared components for navigation, UI widgets, and context management.
- Backend: The booking-system-backend folder is a NestJS (Node.js) application. It is organized into modules for different domains – authentication, booking, and user management. You also have shared/common services (e.g., Prisma service for database interactions, mail service for email notifications) and configuration files.
- Database: Although you don’t see explicit PostgreSQL files, the README indicates PostgreSQL as the underlying database, connected via Prisma ORM. The Prisma directory confirms that database schema definitions and the generated ORM client code play a significant role.
- Authentication & Authorization: Both layers implement authentication. The frontend uses JWT for session management and validation flows (using Zod for client-side validation). On the backend, modules (like auth/auth.controller.ts and jwt.strategy.ts) handle JWT verification, email verification, and other auth concerns.

##### Architectural Patterns and Design Principles
- Modular Architecture: The backend uses NestJS modules (e.g., auth, booking, user) which clearly separate different domains. Illustrate these as distinct modules under the backend component.
- RESTful or API-based Communication: Show how the frontend calls backend endpoints, receiving JSON responses.
- Use of ORM and Database Abstraction: Emphasize how Prisma abstracts direct SQL interactions, allowing the backend to deal with database entities smoothly.
- Reusable UI Components: The frontend has many shared components (from simple UI elements to context providers). Although these may not need to be diagrammed at a granular level, it’s useful to note that the Presentation Layer is component-driven.

##### Relevant Technologies/Frameworks
- For Frontend: Next.js, Tailwind CSS, Shadcn UI.
- For Backend: NestJS, Prisma ORM, Node.js.
- For Database: PostgreSQL.
- For Authentication: JWT.
- For Validation: Zod (in the frontend).
- Optionally, if email delivery is done via a 3rd party service, you may mention Email Service integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE_UI["User Interface (Next.js)"]:::frontend
        FE_Auth["Authentication Pages"]:::frontend
        FE_Main["Main Features"]:::frontend
        FE_UIComp["Shared UI Components"]:::frontend
        FE_Context["Context Management"]:::frontend
        FE_Services_FE["Frontend Services"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE_App["API Server (NestJS)"]:::backend
        subgraph "Modules"
            BE_Auth["Auth Module"]:::backend
            BE_JWT["JWT Strategy"]:::backend
            BE_Booking["Booking Module"]:::backend
            BE_User["User Module"]:::backend
            BE_Common["Common Services (Prisma & Mail)"]:::backend
        end
        BE_App --> BE_Auth
        BE_App --> BE_Booking
        BE_App --> BE_User
        BE_App --> BE_Common
        BE_Auth --> BE_JWT

        %% Prisma Integration as part of common services
        BE_Common --> BE_Prisma["Prisma Integration"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB_Postgres["PostgreSQL Database"]:::database
    end

    %% External Email Service node
    Email_Service["Email Service"]:::external

    %% Connections between layers
    User -->|"access"| FE_UI
    FE_UI -->|"API request"| BE_App
    FE_Auth -->|"auth call"| BE_Auth
    BE_Prisma -->|"query via Prisma"| DB_Postgres
    BE_Common -->|"sends notifications"| Email_Service

    %% (Optional) Internal Frontend Details
    FE_UI -->|"includes"| FE_Auth
    FE_UI -->|"includes"| FE_Main
    FE_UI -->|"includes"| FE_UIComp
    FE_UI -->|"includes"| FE_Context
    FE_UI -->|"includes"| FE_Services_FE

    %% Class definitions for coloring
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events for Frontend
    click FE_UI "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/"
    click FE_Auth "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/src/app/(auth)/"
    click FE_Main "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/src/app/(main)/"
    click FE_UIComp "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/src/components/ui/"
    click FE_Context "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/src/common/context/"
    click FE_Services_FE "https://github.com/monil80/booking-system/tree/main/booking-system-frontend/src/common/services/"

    %% Click Events for Backend
    click BE_App "https://github.com/monil80/booking-system/tree/main/booking-system-backend/"
    click BE_Auth "https://github.com/monil80/booking-system/tree/main/booking-system-backend/src/auth/"
    click BE_JWT "https://github.com/monil80/booking-system/blob/main/booking-system-backend/src/auth/jwt.strategy.ts"
    click BE_Booking "https://github.com/monil80/booking-system/tree/main/booking-system-backend/src/booking/"
    click BE_User "https://github.com/monil80/booking-system/tree/main/booking-system-backend/src/user/"
    click BE_Common "https://github.com/monil80/booking-system/tree/main/booking-system-backend/src/common/service/"
    click BE_Prisma "https://github.com/monil80/booking-system/tree/main/booking-system-backend/prisma/"
```
