# atanu2k4/munchmate_admin architecture

> Architecture diagram of the GitHub repository atanu2k4/munchmate_admin, 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_admin
- Repository: https://github.com/atanu2k4/munchmate_admin

## Overview

##### Project Type and Purpose
- This is a single-page admin dashboard (full-stack BaaS) built with React and Vite.
- It provides restaurant owners with UI for managing menu items, tracking orders, scanning QR codes, and viewing invoices in real time.

##### File Structure
- Top-level config files: `package.json`, `vite.config.js`, `vercel.json`, `eslint.config.js`.
- Public assets: `index.html`, `public/`.
- Source folder:
- `src/main.jsx` – application entry point & ReactDOM.render
- `src/App.jsx` – root component with route/layout logic
- `src/config.js` – Firebase SDK initialization
- `src/components/` – feature components (AdminMenu, AdminOrders, AdminScanQR, AdminNav, OrderInvoiceDetail)
- `src/App.css` & `src/index.css` – global & utility styles

##### README for Additional Insights
- Backend (BaaS): Firebase Firestore (real‐time DB), Firebase Auth, Firebase Storage
- External service: Cloudinary for image uploads
- Hosting: Vercel (via `vercel.json`) or Firebase Hosting

##### Main Components & Interactions
a. Frontend SPA (Browser)
- React app loads `index.html` → `main.jsx` → `App.jsx`
- User interacts with UI components under `src/components/`
- State management via React Hooks
b. Firebase Services
- Firestore: orders collection, menu items collection, real-time listeners
- Auth: user sign-in (if enabled)
- Storage: file uploads (if used)
c. Cloudinary
- Image upload endpoint for menu item photos
d. Hosting/CDN
- Served from Vercel or Firebase Hosting

Data Flow Example (Order Lifecycle):
1. Admin clicks “Mark Delivered” in `AdminOrders.jsx`.
2. React calls Firestore SDK (`config.js`) to update document status.
3. Firestore triggers real-time update → UI re-renders with new status.

##### Architectural Patterns & Principles
- Component-based UI (atomic React components)
- SPA routing & layout in `App.jsx`
- Serverless BaaS backend (no custom node server)
- Real-time data via Firestore listeners
- Externalized media storage: Cloudinary
- CSS utilities (Tailwind) + motion library (Framer Motion)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        HTML["index.html"]:::frontend
        BUNDLE["React SPA"]:::frontend
        main["main.jsx"]:::frontend
        app["App.jsx"]:::frontend
        subgraph "React UI Components"
            direction TB
            Nav["AdminNav"]:::frontend
            Menu["AdminMenu"]:::frontend
            Orders["AdminOrders"]:::frontend
            QR["AdminScanQR"]:::frontend
            Invoice["OrderInvoiceDetail"]:::frontend
        end
        styles1["App.css"]:::styles
        styles2["index.css"]:::styles
        assets["src/assets"]:::assets
        public["public/"]:::assets
        BUNDLE -->|"loads via Vite"| main
        main -->|"renders"| app
        app --> Nav
        app --> Menu
        app --> Orders
        app --> QR
        app --> Invoice
        BUNDLE -->|"styles"| styles1
        BUNDLE -->|"styles"| styles2
        BUNDLE -->|"assets"| assets
        HTML -->|"served by"| BUNDLE
        public -->|"public assets"| BUNDLE
    end

    %% Backend Services
    subgraph "Backend Services (Firebase)"
        direction TB
        SDK["Firebase SDK (config.js)"]:::service
        Auth["Firebase Auth"]:::service
        Firestore["Firestore (DB)"]:::database
        Storage["Firebase Storage"]:::service
    end
    BUNDLE -->|"init SDK"| SDK
    SDK --> Auth
    SDK --> Firestore
    SDK --> Storage
    Orders -->|"onSnapshot()/update()"| Firestore
    app -->|"signIn()"| Auth

    %% External Services
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary API"]:::service
        Hosting["Vercel/Firebase Hosting"]:::cloud
    end
    Menu -->|"uploadImage()"| Cloudinary
    Hosting -->|"serves HTML/CSS/JS"| HTML
    Hosting -->|"serves bundle"| BUNDLE

    %% Project Configs
    subgraph "Project Files & Configs"
        direction TB
        pkg["package.json"]:::frontend
        vite["vite.config.js"]:::frontend
        vercel["vercel.json"]:::frontend
        eslint["eslint.config.js"]:::frontend
        readme["README.md"]:::frontend
    end

    %% Click Events
    click main "https://github.com/atanu2k4/munchmate_admin/blob/master/src/main.jsx"
    click app "https://github.com/atanu2k4/munchmate_admin/blob/master/src/App.jsx"
    click SDK "https://github.com/atanu2k4/munchmate_admin/blob/master/src/config.js"
    click Menu "https://github.com/atanu2k4/munchmate_admin/blob/master/src/components/AdminMenu.jsx"
    click Orders "https://github.com/atanu2k4/munchmate_admin/blob/master/src/components/AdminOrders.jsx"
    click QR "https://github.com/atanu2k4/munchmate_admin/blob/master/src/components/AdminScanQR.jsx"
    click Nav "https://github.com/atanu2k4/munchmate_admin/blob/master/src/components/AdminNav.jsx"
    click Invoice "https://github.com/atanu2k4/munchmate_admin/blob/master/src/components/OrderInvoiceDetail.jsx"
    click styles1 "https://github.com/atanu2k4/munchmate_admin/blob/master/src/App.css"
    click styles2 "https://github.com/atanu2k4/munchmate_admin/blob/master/src/index.css"
    click assets "https://github.com/atanu2k4/munchmate_admin/tree/master/src/assets/"
    click HTML "https://github.com/atanu2k4/munchmate_admin/blob/master/index.html"
    click public "https://github.com/atanu2k4/munchmate_admin/tree/master/public/"
    click pkg "https://github.com/atanu2k4/munchmate_admin/blob/master/package.json"
    click vite "https://github.com/atanu2k4/munchmate_admin/blob/master/vite.config.js"
    click vercel "https://github.com/atanu2k4/munchmate_admin/blob/master/vercel.json"
    click eslint "https://github.com/atanu2k4/munchmate_admin/blob/master/eslint.config.js"
    click readme "https://github.com/atanu2k4/munchmate_admin/blob/master/README.md"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef database fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef service fill:#FFF9C4,stroke:#F57F17,color:#F57F17
    classDef cloud fill:#E0E0E0,stroke:#424242,color:#424242
    classDef styles fill:#F3E5F5,stroke:#4A148C,color:#4A148C
    classDef assets fill:#FFE0B2,stroke:#E65100,color:#E65100
```
