# hamzamagdy0/online-sabroso-restaurant-website architecture

> Architecture diagram of the GitHub repository hamzamagdy0/online-sabroso-restaurant-website, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamzamagdy0/online-sabroso-restaurant-website
- Repository: https://github.com/hamzamagdy0/online-sabroso-restaurant-website

## Overview

##### Project type and purpose
- This is a full-stack restaurant management web application (“Sabroso Restaurant Website”) whose primary goals are:
- Customer-facing menu browsing and reservations
- User authentication and profile management
- Admin dashboard for menu and reservation management
- Real-time order tracking (via REST APIs).

##### File structure
- Top-level files and folders:
- app.js: entry point where Express is configured.
- controllers/: business logic grouped by domain (admin, user).
- routes/: HTTP endpoints grouped by resource (auth, menu, reservations, users).
- models/: Mongoose schemas for menu, reservations, users.
- views/: EJS templates for all UI screens.
- public/: static assets (CSS, JS, images).
- .env: environment variables (MongoDB URI, JWT secret, port).
- Pattern: An MVC-style separation—routes → controllers → models ←→ database, with views rendering server-side HTML.

##### README for additional insights
- Architecture hints: Node.js + Express backend, MongoDB via Mongoose, EJS templating, JWT for authentication, CSS/JS static assets, Nodemon for development.
- API endpoint list clarifies how clients interact with the backend.

##### Detail and component separation
- Don’t hesitate to break large blocks into smaller ones: for example, split “routes” into authRoute, menuRoute, reservationsRoute, usersRoute.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Zone
    subgraph "Frontend Zone"
        direction TB
        Browser["Web Browser"]:::client
        Views["EJS Templates (views/)"]:::client
        CSS["Static CSS (public/CSS/)"]:::client
        JS["Static JS (public/JS/)"]:::client
        Images["Static Images (public/Images/)"]:::client
    end

    %% Backend Zone
    subgraph "Backend Zone"
        direction TB
        Server["Express Server (app.js)"]:::server
        subgraph "Routing Layer"
            direction TB
            AuthRoute["routes/authRoute.js"]:::server
            MenuRoute["routes/menuRoute.js"]:::server
            ResRoute["routes/reservationsRoute.js"]:::server
            UserRoute["routes/usersRoute.js"]:::server
        end
        AuthService["JWT Auth Service"]:::auth
        subgraph "Controller Layer"
            direction TB
            AdminCtrl["controllers/admin.js"]:::server
            UserCtrl["controllers/user.js"]:::server
        end
        subgraph "Data Access Layer"
            direction TB
            MenuModel["models/menu.js"]:::data
            ResModel["models/reservations.js"]:::data
            UserModel["models/users.js"]:::data
        end
        Database["MongoDB"]:::data
        Config["Configuration (.env)"]:::config
        PackageJSON["package.json"]:::config
        PackageLock["package-lock.json"]:::config
    end

    %% Documentation
    subgraph "Documentation"
        direction TB
        README["README.md"]:::docs
        About["about.txt"]:::docs
    end

    %% Relationships
    Browser -->|requests views| Server
    Server -->|serves| Views
    Server -->|serves| CSS
    Server -->|serves| JS
    Server -->|serves| Images

    Browser -->|HTTP requests| AuthRoute
    Browser -->|HTTP requests| MenuRoute
    Browser -->|HTTP requests| ResRoute
    Browser -->|HTTP requests| UserRoute

    AuthRoute -->|calls| AdminCtrl
    MenuRoute -->|calls| AdminCtrl
    ResRoute -->|calls| AdminCtrl
    UserRoute -->|calls| UserCtrl

    AuthRoute -->|uses| AuthService
    Server -->|loads config| Config
    AuthService -->|reads| Config

    AdminCtrl -->|queries| MenuModel
    AdminCtrl -->|queries| ResModel
    UserCtrl -->|queries| UserModel

    MenuModel -->|CRUD| Database
    ResModel -->|CRUD| Database
    UserModel -->|CRUD| Database

    PackageJSON -->|defines| Server
    PackageLock -->|locks| Server

    README -->|documents| Server
    About -->|documents| Server

    %% Click Events
    click Views "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/tree/master/views/"
    click CSS "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/tree/master/public/CSS/"
    click JS "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/tree/master/public/JS/"
    click Images "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/tree/master/public/Images/"
    click Server "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/app.js"
    click AuthRoute "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/routes/authRoute.js"
    click MenuRoute "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/routes/menuRoute.js"
    click ResRoute "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/routes/reservationsRoute.js"
    click UserRoute "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/routes/usersRoute.js"
    click AdminCtrl "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/controllers/admin.js"
    click UserCtrl "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/controllers/user.js"
    click MenuModel "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/models/menu.js"
    click ResModel "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/models/reservations.js"
    click UserModel "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/models/users.js"
    click Config "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/.env"
    click PackageJSON "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/package.json"
    click PackageLock "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/package-lock.json"
    click README "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/README.md"
    click About "https://github.com/hamzamagdy0/online-sabroso-restaurant-website/blob/master/about.txt"

    %% Styles
    classDef client fill:#b3d9ff,stroke:#333,stroke-width:1px
    classDef server fill:#b3ffb3,stroke:#333,stroke-width:1px
    classDef data fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef auth fill:#ff9999,stroke:#333,stroke-width:1px
    classDef config fill:#e6e6e6,stroke:#333,stroke-width:1px
    classDef docs fill:#f2e6ff,stroke:#333,stroke-width:1px
```
