# shreyas0017/munchmate architecture

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

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

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React (via Vite) that leverages Firebase as a backend and Cloudinary for image hosting. Its purpose is to enable university students to browse menus, place orders, manage profiles, and handle real-time order/inventory updates.

##### File structure
- Top level: index.html, public/ for static assets, package.json, vite.config.js, vercel.json (deployment).
- src/:
- main.jsx – React entry point, ties into index.html via Vite.
- App.jsx & App.css – root component and styling.
- components/ – UI building blocks (Landing, Menu, Cart, Orders, Payment, Auth flows, Admin/Invoice).
- context/CartContext.jsx – React Context for global cart state.
- config.js – Firebase & Cloudinary setup.
- No backend code in repo; project uses Firebase Auth & Firestore as a BaaS.

##### README
- Confirms tech stack: React + Vite, TailwindCSS, Framer Motion/GSAP for animations, React Router, React Context, Firebase Auth/Firestore, Cloudinary, deployed on Vercel.
- Mentions user flows: authentication, real-time availability, cart interactions, admin dashboard, profile management.

##### Main components & relationships
a. Frontend SPA (client-side)
- Browser with React/Vite runtime
- React Router for page navigation
- React Context (CartContext) for state management
- UI Components (Navbar, Menu, Cart, Payment, Profile, AdminDashboard, etc.)
- Animations (Framer Motion, GSAP) & Styles (TailwindCSS)
b. Hosting
- Vercel (static asset/CDN hosting + automatic deploy from Git)
c. Backend Services (external)
- Firebase Auth – user sign-up/sign-in flows, email verification
- Firebase Firestore – menu items, orders, user profiles, real-time updates
- Cloudinary – storing & delivering food images
d. Data flows & interactions
- SPA → Firebase Auth (REST/SDK calls) for login/sign-up
- SPA → Firestore for CRUD on menus, orders, profile
- SPA → Cloudinary for image upload (admin side) and fetch (public menus)
- Firestore real-time listeners feeding back availability & order status into the SPA

##### Architectural patterns & design principles
- Component-based UI (atomic React components)
- Single source of truth in React Context for cart state
- Unidirectional data flow (React → Context → Components → external services)
- Separation of concerns:
- Presentation layer (components + styles)
- State management (Context)
- Configuration layer (config.js)
- Routing layer (React Router)
- External BaaS services (Firebase, Cloudinary)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser (SPA)"
        direction TB
        Router["React Router"]:::routing
        CartContext["CartContext"]:::state
        config["config.js"]:::config

        subgraph "UI Components"
            direction TB
            Landing["Landing Page"]:::ui
            Navbar["Navbar"]:::ui
            Menu["Menu Display"]:::ui
            CartComp["Shopping Cart"]:::ui
            Orders["Orders List"]:::ui
            Payment["Payment Flow"]:::ui
            SignIn["Sign In"]:::ui
            SignUp["Sign Up"]:::ui
            Profile["User Profile"]:::ui
            UserDetails["User Details Edit"]:::ui
            Invoice["Admin/Invoice Generation"]:::ui
        end
    end

    Vercel["Vercel Hosting/CDN"]:::hosting

    Auth["Firebase Auth (BaaS)"]:::external
    Firestore["Firestore<br/>(NoSQL DB)"]:::db
    Cloudinary["Cloudinary (Image Hosting)"]:::external

    %% Connections
    Vercel -->|serves SPA| Router
    Router -->|routes to| Landing
    Router -->|routes to| Navbar
    Router -->|routes to| Menu
    Router -->|routes to| CartComp
    Router -->|routes to| Orders
    Router -->|routes to| Payment
    Router -->|routes to| SignIn
    Router -->|routes to| SignUp
    Router -->|routes to| Profile
    Router -->|routes to| UserDetails
    Router -->|routes to| Invoice

    CartContext -->|provides state to| CartComp
    CartContext -->|provides state to| Navbar
    CartContext -->|provides state to| Orders
    CartContext -->|provides state to| Payment

    Landing -->|navigates| SignIn
    Landing -->|navigates| SignUp

    SignIn -->|"auth requests"| Auth
    SignUp -->|"auth requests"| Auth

    Navbar -->|"fetches menus/orders"| Firestore
    Menu -->|"CRUD menus/orders"| Firestore
    CartComp -->|"sync cart"| Firestore
    Orders -->|"CRUD orders"| Firestore
    Payment -->|"record payment"| Firestore
    Invoice -->|"fetch invoice data"| Firestore

    Invoice -->|"upload images"| Cloudinary

    Firestore -->|"real-time updates"| Menu
    Firestore -->|"real-time updates"| Orders
    Firestore -->|"real-time updates"| CartComp

    config -->|configures SDKs| Auth
    config -->|configures SDKs| Firestore
    config -->|configures SDKs| Cloudinary

    %% Click Events
    click index.html "https://github.com/shreyas0017/munchmate/blob/main/index.html"
    click main "https://github.com/shreyas0017/munchmate/blob/main/src/main.jsx"
    click App "https://github.com/shreyas0017/munchmate/blob/main/src/App.jsx"
    click App.css "https://github.com/shreyas0017/munchmate/blob/main/src/App.css"
    click Router "https://github.com/shreyas0017/munchmate/blob/main/src/App.jsx"
    click CartContext "https://github.com/shreyas0017/munchmate/blob/main/src/context/CartContext.jsx"
    click config "https://github.com/shreyas0017/munchmate/blob/main/src/config.js"
    click Landing "https://github.com/shreyas0017/munchmate/blob/main/src/components/Landing.jsx"
    click Navbar "https://github.com/shreyas0017/munchmate/blob/main/src/components/Navbar.jsx"
    click Menu "https://github.com/shreyas0017/munchmate/blob/main/src/components/Menu.jsx"
    click CartComp "https://github.com/shreyas0017/munchmate/blob/main/src/components/Cart.jsx"
    click Orders "https://github.com/shreyas0017/munchmate/blob/main/src/components/Orders.jsx"
    click Payment "https://github.com/shreyas0017/munchmate/blob/main/src/components/Payment.jsx"
    click SignIn "https://github.com/shreyas0017/munchmate/blob/main/src/components/SignIn.jsx"
    click SignUp "https://github.com/shreyas0017/munchmate/blob/main/src/components/SignUp.jsx"
    click Profile "https://github.com/shreyas0017/munchmate/blob/main/src/components/UserProfile.jsx"
    click UserDetails "https://github.com/shreyas0017/munchmate/blob/main/src/components/UserDetails.jsx"
    click Invoice "https://github.com/shreyas0017/munchmate/blob/main/src/components/Invoice.jsx"
    click public "https://github.com/shreyas0017/munchmate/tree/main/public/"
    click vite.config.js "https://github.com/shreyas0017/munchmate/blob/main/vite.config.js"
    click vercel.json "https://github.com/shreyas0017/munchmate/blob/main/vercel.json"
    click index.css "https://github.com/shreyas0017/munchmate/blob/main/src/index.css"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1
    classDef routing fill:#C8E6C9,stroke:#43A047,color:#1B5E20
    classDef state fill:#C8E6C9,stroke:#43A047,color:#1B5E20
    classDef config fill:#EEEEEE,stroke:#9E9E9E,color:#424242
    classDef hosting fill:#CFD8DC,stroke:#607D8B,color:#263238
    classDef external fill:#FFE0B2,stroke:#FB8C00,color:#E65100
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100,shape:cylinder
```
