# unnatibamania/canteen-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/unnatibamania/canteen-management-system
- Repository: https://github.com/unnatibamania/canteen-management-system

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) web application called “Canteen Management System.”
- Purpose: Allow students/teachers to browse food items, place orders, have admin confirmation, and process payments (online via Stripe or offline).

##### File structure
- Top-level:
- server.js (entry point of Express)
- config/db.js (MongoDB connection)
- models/ (Mongoose schemas: auth, food, order)
- routes/ (Express routers: auth, food, order)
- middleware/ (authentication & Cloudinary image upload)
- Frontend:
- frontend/src: React application built with Redux for state management
- pages/, components/, redux/ (actions, reducers, types, store)
- public/ & build/: static assets and production bundle
- Package files and .gitignore at both root and frontend.

##### README for technical stack & features
- Backend: Express.js + MongoDB
- Frontend: React.js + Redux
- Core features: user auth, order placement, admin confirmation, Stripe integration for payments.

##### Final advice
- Be detailed: break out sub-components (e.g., Redux store, middleware) where it clarifies responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    Browser["Client (Browser)"]:::frontend

    subgraph "Frontend Layer"
        ReactApp["React App"]:::frontend
        subgraph "Redux Store"
            Store["Store & Root Reducer"]:::frontend
            subgraph "Redux Modules"
                AuthModule["Auth Module"]:::frontend
                FoodModule["Food Module"]:::frontend
                CartModule["Cart Module"]:::frontend
                OrderModule["Order Module"]:::frontend
                AlertModule["Alert Module"]:::frontend
            end
        end
        subgraph "Pages"
            HomePage["HomePage"]:::frontend
            SignInPage["SignIn/SignUp Pages"]:::frontend
            FoodPage["Food Listing Page"]:::frontend
            CartPage["Cart Page"]:::frontend
            DashboardPage["Dashboard/Admin Pages"]:::frontend
        end
        subgraph "UI Components"
            Navbar["Navbar"]:::frontend
            FoodCard["FoodCard"]:::frontend
            StripeButton["StripeButton"]:::frontend
            PrivateComp["PrivateComponent"]:::frontend
            Loader["Loader & Alert"]:::frontend
        end
    end

    %% API Layer
    subgraph "API Layer"
        Express["Express App (server.js)"]:::backend
        subgraph "Routes"
            AuthRoutes["Auth Routes"]:::backend
            FoodRoutes["Food Routes"]:::backend
            OrderRoutes["Order Routes"]:::backend
        end
        subgraph "Middleware"
            AuthMW["Auth Middleware"]:::backend
            CloudMW["Cloudinary Middleware"]:::backend
        end
        subgraph "Models"
            AuthModel["Auth Model"]:::backend
            FoodModel["Food Model"]:::backend
            OrderModel["Order Model"]:::backend
        end
    end

    %% Database and External
    Mongo["MongoDB"]:::db
    Stripe["Stripe"]:::external
    Cloudinary["Cloudinary"]:::external

    %% Connections
    Browser --> ReactApp
    ReactApp --> Store
    ReactApp --> HomePage
    ReactApp --> SignInPage
    ReactApp --> FoodPage
    ReactApp --> CartPage
    ReactApp --> DashboardPage
    ReactApp --> Navbar
    ReactApp --> FoodCard
    ReactApp --> StripeButton
    ReactApp --> PrivateComp
    ReactApp --> Loader

    Store --> AuthModule
    Store --> FoodModule
    Store --> CartModule
    Store --> OrderModule
    Store --> AlertModule

    HomePage --> Express
    SignInPage --> Express
    FoodPage --> Express
    CartPage --> Express
    DashboardPage --> Express

    Express --> AuthRoutes
    Express --> FoodRoutes
    Express --> OrderRoutes

    AuthRoutes --> AuthMW
    FoodRoutes --> AuthMW
    OrderRoutes --> AuthMW
    FoodRoutes --> CloudMW

    AuthRoutes --> AuthModel
    FoodRoutes --> FoodModel
    OrderRoutes --> OrderModel

    AuthModel --> Mongo
    FoodModel --> Mongo
    OrderModel --> Mongo

    FoodRoutes --> Stripe
    OrderRoutes --> Stripe
    FoodRoutes --> Cloudinary
    Cloudinary --> FoodModel

    %% Click Events
    click ReactApp "https://github.com/unnatibamania/canteen-management-system/tree/main/frontend/src"
    click ReactApp "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/index.js"
    click ReactApp "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/App.js"
    click Store "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/store.js"
    click Store "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/rootReducer.js"
    click AuthModule "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/auth/auth.actions.js"
    click FoodModule "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/food/food.actions.js"
    click CartModule "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/cart/cart.actions.js"
    click OrderModule "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/order/order.actions.js"
    click AlertModule "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/redux/alert/alert.actions.jsx"
    click Navbar "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/components/navbar/Navbar.jsx"
    click FoodCard "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/components/food-card/FoodCard.jsx"
    click StripeButton "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/components/stripe-button/StripeButton.jsx"
    click PrivateComp "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/components/private-component/PrivateComponent.jsx"
    click Loader "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/components/loader/Loader.jsx"
    click HomePage "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/pages/home-page/HomePage.jsx"
    click SignInPage "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/pages/sign-in-page/SignInPage.jsx"
    click FoodPage "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/pages/food-page/FoodPage.jsx"
    click CartPage "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/pages/cart/CartPage.jsx"
    click DashboardPage "https://github.com/unnatibamania/canteen-management-system/blob/main/frontend/src/pages/dashboard/Dashboard.jsx"
    click Express "https://github.com/unnatibamania/canteen-management-system/blob/main/server.js"
    click AuthRoutes "https://github.com/unnatibamania/canteen-management-system/blob/main/routes/auth.routes.js"
    click FoodRoutes "https://github.com/unnatibamania/canteen-management-system/blob/main/routes/food.routes.js"
    click OrderRoutes "https://github.com/unnatibamania/canteen-management-system/blob/main/routes/order.routes.js"
    click AuthMW "https://github.com/unnatibamania/canteen-management-system/blob/main/middleware/auth.js"
    click CloudMW "https://github.com/unnatibamania/canteen-management-system/blob/main/middleware/cloudinary.js"
    click AuthModel "https://github.com/unnatibamania/canteen-management-system/blob/main/models/auth.models.js"
    click FoodModel "https://github.com/unnatibamania/canteen-management-system/blob/main/models/food.models.js"
    click OrderModel "https://github.com/unnatibamania/canteen-management-system/blob/main/models/order.models.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#818182,color:#818182
```
