# atanu2k4/munchmate architecture

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

- Interactive diagram: https://gitdiagram.com/atanu2k4/munchmate
- Repository: https://github.com/atanu2k4/munchmate

## Overview

##### Project Type and Purpose
- This is a single-page, full-stack web application (frontend heavy) for online food ordering and pick-up, built with React (Vite) and backed by Firebase (Auth & Firestore) plus Cloudinary for image storage. Its core use cases: user authentication, menu browsing, real-time availability, cart/checkout, order history, and an admin panel for menu management.

##### File Structure & Architectural Patterns
- src/
- components/ – UI elements and pages (Landing, Menu, Cart, Orders, Payment, Admin interfaces)
- context/ – React Context provider (CartContext) for global state management
- config.js – Firebase and Cloudinary configuration
- main.jsx – React application entry point, bootstraps Router and Context
- App.jsx – Top-level component mounting the router and layout
- public/ & index.html – Static assets and HTML template served by Vite
- vite.config.js – Build and dev-server configuration
- eslint.config.js – Linting rules
- vercel.json – Deployment settings

Architectural patterns:
- SPA (Single Page Application) with React Router for client-side routing
- Global state via Context API (CartContext)
- Component-based UI with clearly separated presentational and container logic
- BaaS pattern: Firebase Auth/Firestore as backend services; Cloudinary for media

##### Main System Components
- Browser (Client)
- React SPA (Vite-bundled)
- UI Components & Pages
- React Router (routes: /, /menu, /cart, /signin, /signup, /profile, /orders, /admin)
- React Context (CartContext for cart state)
- Backend Services (External)
- Firebase Authentication – user sign-up/sign-in, session management, email verification
- Firebase Firestore – NoSQL database for users, menu items, orders, availability status
- Cloudinary – image hosting and CDN for menu item photos
- Third-party Libraries
- TailwindCSS – utility-first styling
- Framer Motion & GSAP – animations and transitions

##### Interactions and Data Flows
- On app load, client fetches static bundle from Vite dev/build server
- User navigates via React Router; pages request data via Firebase SDK (configured in src/config.js)
- Auth flows: SignUp/SignIn pages interact with Firebase Auth APIs → on success, store user in context or local state
- Menu page queries Firestore collections for items; UI shows real-time availability (Firestore listeners)
- CartContext accumulates selections; on checkout, Payment component writes order records to Firestore
- Admin pages write CRUD operations to Firestore for menu management; Cloudinary upload widget used for images
- All reads/writes occur over HTTPS to Firebase endpoints; Cloudinary assets served over CDN

##### Architectural Patterns & Design Principles
- Separation of concerns: UI components, state management, data access layers
- Reactive data bindings: Firestore listeners for real-time updates
- Stateless functional React components where possible
- Resilient BaaS integration (client-side only, no custom server)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend (Client)" 
        direction TB
        subgraph "Entry & Config"
            Main["main.jsx"]:::blue
            App["App.jsx"]:::blue
            Config["config.js"]:::blue
        end

        subgraph "State & Routing"
            Router["React Router"]:::green
            CartCtx["CartContext"]:::green
        end

        subgraph "Presentation Layer"
            Landing["Landing.jsx"]:::blue
            Menu["Menu.jsx"]:::blue
            CartPage["Cart.jsx"]:::blue
            Orders["Orders.jsx"]:::blue
            Payment["Payment.jsx"]:::blue
            SignIn["SignIn.jsx"]:::blue
            SignUp["SignUp.jsx"]:::blue
            Profile["UserProfile.jsx"]:::blue
            Navbar["Navbar.jsx"]:::blue
            Hero["Hero.jsx"]:::blue
            Aurora["Aurora.jsx"]:::blue
            Squares["Squares.jsx"]:::blue
            Cursor["CustomCursor.jsx"]:::blue
            Invoice["Invoice.jsx"]:::blue
            OrderNow["OrderNowButton.jsx"]:::blue
        end

        subgraph "Static & Config Files"
            IndexHTML["index.html"]:::blue
            Public["public/"]:::blue
            ViteCfg["vite.config.js"]:::blue
            ESLint["eslint.config.js"]:::blue
            Styles["index.css"]:::blue
            Assets["assets/"]:::blue
        end
    end

    %% BaaS Services
    subgraph "External BaaS Services"
        direction TB
        Auth["Firebase Auth"]:::orange_cloud
        Firestore["Firestore (NoSQL DB)"]:::orange_db
        Cloudinary["Cloudinary CDN"]:::orange_cloud
    end

    %% Interactions
    Main -->|"bootstraps"| App
    App -->|"loads Router & Context"| Router
    App -->|"provides CartContext"| CartCtx
    Router -->|"routes to pages"| Landing & Menu & CartPage & Orders & Payment & SignIn & SignUp & Profile
    CartCtx -->|"provides state to"| CartPage & Payment & Navbar
    Landing -->|"renders UI with Tailwind, Animations"| Hero & Aurora & Squares & Cursor & OrderNow
    Menu -->|"queries"| Firestore
    CartPage -->|"uses"| CartCtx
    Payment -->|"writes order to"| Firestore
    Orders -->|"reads order history from"| Firestore
    SignIn & SignUp -->|"auth via"| Auth
    Profile -->|"reads/writes user data from"| Firestore
    Navbar -->|"displays based on auth state from"| Auth
    Menu -->|"loads images from"| Cloudinary

    %% Protocol labels
    Menu -->|"HTTPS SDK call"| Firestore
    Payment -->|"HTTPS SDK call"| Firestore
    Orders -->|"real-time listener"| Firestore
    SignIn -->|"SDK call"| Auth
    SignUp -->|"SDK call"| Auth

    %% Config interactions
    Config -->|"provides keys to SDKs"| Auth & Firestore & Cloudinary

    %% Click Events
    click Main "https://github.com/atanu2k4/munchmate/blob/main/src/main.jsx"
    click App "https://github.com/atanu2k4/munchmate/blob/main/src/App.jsx"
    click Config "https://github.com/atanu2k4/munchmate/blob/main/src/config.js"
    click CartCtx "https://github.com/atanu2k4/munchmate/blob/main/src/context/CartContext.jsx"
    click Landing "https://github.com/atanu2k4/munchmate/blob/main/src/components/Landing.jsx"
    click Menu "https://github.com/atanu2k4/munchmate/blob/main/src/components/Menu.jsx"
    click CartPage "https://github.com/atanu2k4/munchmate/blob/main/src/components/Cart.jsx"
    click Orders "https://github.com/atanu2k4/munchmate/blob/main/src/components/Orders.jsx"
    click Payment "https://github.com/atanu2k4/munchmate/blob/main/src/components/Payment.jsx"
    click SignIn "https://github.com/atanu2k4/munchmate/blob/main/src/components/SignIn.jsx"
    click SignUp "https://github.com/atanu2k4/munchmate/blob/main/src/components/SignUp.jsx"
    click Profile "https://github.com/atanu2k4/munchmate/blob/main/src/components/UserProfile.jsx"
    click Navbar "https://github.com/atanu2k4/munchmate/blob/main/src/components/Navbar.jsx"
    click IndexHTML "https://github.com/atanu2k4/munchmate/blob/main/index.html"
    click Public "https://github.com/atanu2k4/munchmate/tree/main/public/"
    click ViteCfg "https://github.com/atanu2k4/munchmate/blob/main/vite.config.js"
    click ESLint "https://github.com/atanu2k4/munchmate/blob/main/eslint.config.js"
    click Styles "https://github.com/atanu2k4/munchmate/blob/main/src/index.css"
    click Assets "https://github.com/atanu2k4/munchmate/tree/main/src/assets/"
    click Hero "https://github.com/atanu2k4/munchmate/blob/main/src/components/Hero.jsx"
    click Aurora "https://github.com/atanu2k4/munchmate/blob/main/src/components/Aurora.jsx"
    click Squares "https://github.com/atanu2k4/munchmate/blob/main/src/components/Squares.jsx"
    click Cursor "https://github.com/atanu2k4/munchmate/blob/main/src/components/CustomCursor.jsx"
    click Invoice "https://github.com/atanu2k4/munchmate/blob/main/src/components/Invoice.jsx"
    click OrderNow "https://github.com/atanu2k4/munchmate/blob/main/src/components/OrderNowButton.jsx"

    %% Styles
    classDef blue fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef green fill:#DFFFE0,stroke:#28A745,color:#28A745;
    classDef orange_cloud fill:#FFE8CC,stroke:#D26900,color:#D26900,shape:cloud;
    classDef orange_db fill:#FFE8CC,stroke:#D26900,color:#D26900,shape:cylinder;
```
