# 18harsh/movie-reservation-system architecture

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

- Interactive diagram: https://gitdiagram.com/18harsh/movie-reservation-system
- Repository: https://github.com/18harsh/movie-reservation-system

## Overview

##### Project Overview
- The purpose of the system is to allow customers to book movie tickets online, with features such as account registration, movie browsing, seat selection, and payment processing.
- The README images and website link highlight both the front‑end user experience and the Node.js back‑end.

##### Main Components
a. Frontend:
– Public folder: Contains static assets such as CSS, JavaScript files (e.g., chat.js, home.js, seats.js, etc.), and images.
– Templates folder: Uses Handlebars (hbs) to render dynamic pages (views and partials such as header, sidebar, filter).
– This clearly follows an MVC-like separation, where the views are defined in the templates and the static resources enhance the user interface.

b. Backend:
– src directory: Contains the main application logic (app.js), middleware (e.g., authentication in middleware/auth.js), models (user and movies), and routers (handling user and bid routes).
– The backend layer appears to follow a modular MVC-style structure with clear separation of concerns between the models, routers (controllers), and app-level configurations.
– The presence of “mongodb.js” in the project’s root and “src/db/mongoose.js” shows that MongoDB (accessed via Mongoose) is the database technology being used.

c. Database:
– MongoDB, with connections and schemas defined in the “db” and “models” directories.
– The README also includes screenshots of movie data and user data indicating its key role in the system.

##### Relationships and Interactions
- The user accesses the system via the frontend (browser). The separation between static assets (public) and dynamic HTML templates (templates) helps in understanding how views are rendered.
- The backend (Express/Node application in app.js) handles user requests routed through various endpoints defined under “src/routers”. It processes logic via middleware and models.
- The MongoDB database is accessed through a Mongoose connection, and models are used to interact with collections for movies and users.
- Additionally, there are indications of a real-time aspect (e.g., chat.js) that could imply WebSocket or long-polling for certain interactions.

##### Architectural Patterns and Design Principles to Highlight
– MVC Pattern: The clear separation between Models (src/models), Views (templates and public assets), and Controllers/Routers (src/routers) suggests an MVC approach.
– Modularization: The use of separate directories for middleware, database connection, and routing.
– Separation of Concerns: Frontend logic is managed in public and templates while the backend deals with API endpoints and business logic.
– Use of external services: The Procfile indicates the potential for deployment on platforms like Heroku, and the README shows a live website, implying CI/CD and cloud deployment practices.

##### Technologies, Frameworks, and Libraries
– Node.js: The core back‑end runtime.
– Express.js (implied through typical Node.js project structure with routers and middleware).
– Handlebars (hbs): For rendering dynamic HTML views.
– Mongoose: For interacting with MongoDB.
– HTML/CSS/JavaScript: As seen in the public folder for client-side functionalities.
– Likely some third‑party libraries for payment processing given the payment UI pages (though the detail isn’t fully exposed here).

##### Additional Notes
– Do not overcomplicate; capturing the major components and how they interact is the goal.
– Incorporate essential details like the deployment environment indicated by the Procfile and potential experimental code in the playground directory (which can be mentioned as additional development utilities).

## Diagram (Mermaid)

```mermaid
graph TD
    Client["Client (Browser)"]:::client

    subgraph "Frontend (UI)"
        Static["Static Assets"]:::frontend
        Templates["Templates/Views"]:::frontend
    end

    subgraph "Backend (Express Server)"
        App["Main Application (app.js)"]:::backend
        Middleware["Middleware (auth.js)"]:::backend
        Routers["Routers (bid.js,user.js)"]:::backend
        Models["Models (movies,user)"]:::backend
    end

    subgraph "Database (MongoDB)"
        DBConfig["DB Config (mongodb.js)"]:::database
        Mongoose["Mongoose Connection (src/db/mongoose.js)"]:::database
        DB["MongoDB Database"]:::database
    end

    subgraph "Deployment & Utilities"
        Proc["Procfile"]:::deployment
        Playground["Playground Utilities"]:::deployment
    end

    %% Data Flow from Client to Frontend
    Client -->|"LoadUI"| Templates
    Client -->|"LoadAssets"| Static

    %% Frontend to Backend flow
    Templates -->|"SubmitRequest"| App

    %% Backend internal flow
    App -->|"Authenticate"| Middleware
    App -->|"RouteRequest"| Routers
    Routers -->|"ProcessRequest"| Models
    Models -->|"QueryOrUpdate"| Mongoose
    Mongoose -->|"AccessData"| DB
    DB -->|"ReturnData"| Mongoose
    Mongoose -->|"FeedData"| Models
    Models -->|"SendResponse"| Routers
    Routers -->|"ReturnResponse"| App
    App -->|"RenderView"| Templates

    %% Deployment & Utilities connections (ancillary)
    App -->|"DeployConfig"| Proc
    App -->|"RunExperiments"| Playground

    %% Click Events
    click Static "https://github.com/18harsh/movie-reservation-system/tree/master/public"
    click Templates "https://github.com/18harsh/movie-reservation-system/tree/master/templates"
    click App "https://github.com/18harsh/movie-reservation-system/blob/master/src/app.js"
    click Middleware "https://github.com/18harsh/movie-reservation-system/blob/master/src/middleware/auth.js"
    click Models "https://github.com/18harsh/movie-reservation-system/tree/master/src/models"
    click Routers "https://github.com/18harsh/movie-reservation-system/tree/master/src/routers"
    click DBConfig "https://github.com/18harsh/movie-reservation-system/blob/master/mongodb.js"
    click Mongoose "https://github.com/18harsh/movie-reservation-system/blob/master/src/db/mongoose.js"
    click Proc "https://github.com/18harsh/movie-reservation-system/tree/master/Procfile"
    click Playground "https://github.com/18harsh/movie-reservation-system/tree/master/playground"

    %% Styles
    classDef client fill:#EEE,stroke:#333,stroke-width:2px
    classDef frontend fill:#FFEEAD,stroke:#333,stroke-width:2px
    classDef backend fill:#CDE9FF,stroke:#333,stroke-width:2px
    classDef database fill:#C1E1C1,stroke:#333,stroke-width:2px
    classDef deployment fill:#FDCEDA,stroke:#333,stroke-width:2px
```
