# bhaveshmp/mealmate architecture

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

- Interactive diagram: https://gitdiagram.com/bhaveshmp/mealmate
- Repository: https://github.com/bhaveshmp/mealmate

## Overview

##### Project Type & Purpose
- A React single-page application scaffolded by Vite
- UI built with Tailwind CSS and Flowbite React components
- No custom backend server—uses Supabase (Auth, Postgres DB, Storage) as BaaS
- Provides a restaurant management/dashboard interface (roles: admin, chef, employee) for managing menu items, coupons, image uploads, and scan logs

##### File Structure Analysis
- Top-level configuration:
– .env, vite.config.js, tailwind.config.js, postcss.config.js, eslint.config.js
– package.json / package-lock.json for dependencies and scripts
- Public/static assets:
– index.html, public/ folder, src/assets (e.g., beep.m4a)
- Source code in src/:
– main.jsx & App.jsx: application bootstrap and routing
– api.js & lib/supabaseClient.js: data-access wrappers
– components/: reusable UI bits and “backend” helpers (InsertUser, ImageHandling)
– pages/: route-level views (login, register, home, scan, menuitems, profile, dashboards)
- No server directory—front end communicates directly with Supabase

##### README Insights
- A minimal Vite + React template with HMR and ESLint presets
- Suggests two official plugins: @vitejs/plugin-react or plugin-react-swc
- Encourages TypeScript for production, but current code is JavaScript

##### Main Components & Their Interactions
a. Developer & Tooling Layer
– IDE/Git → Vite Dev Server (HMR)
– ESLint, Prettier, Tailwind CLI, Flowbite plugin

b. Build & Deployment Layer
– Vite Bundler compiles React/JSX → PostCSS/Tailwind generates CSS → Output = static assets
– CI/CD (optional) → Static hosting (Example: Netlify, Vercel, S3+CDN)

c. Client-Side SPA Layer
– Browser loads index.html → initializes main.jsx → renders App.jsx
– Routing to pages/ (login, home, adminDashboard, etc.)
– Components/ handle UI and data calls
– Data-access via supabaseClient.js and api.js

d. External BaaS Layer (Supabase)
– Auth: user sign-in/up, JWT handling
– Database: CRUD on menu items, coupons, user roles
– Storage: image uploads & retrieval

##### Architectural Patterns & Principles
- SPA architecture: client-heavy, client routing, component reuse
- BaaS microservice: no custom server code, front end uses Supabase JS SDK
- Modular structure: common UI, dashboard subcomponents, “backend” helper components
- Clear separation: UI layer vs data-access layer

1. Developer & Tooling
2. Build & CI/CD
3. Client-Side SPA
4. External Services

– In each tier, represent:
- Developer tools (IDE, Git)
- Vite dev server & plugins
- Bundling & static hosting

- Dev tools → Vite Dev Server → Bundler → Static Host → Browser
- Browser → Supabase (Auth), → Supabase (DB), → Supabase (Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & Tooling Layer
    subgraph "Developer & Tooling" 
        direction TB
        IDE["IDE (VSCode)"]:::tooling
        Git["Git"]:::tooling
        DotEnv[".env"]:::tooling
        GitIgnore[".gitignore"]:::tooling
        README["README.md"]:::tooling
        JSConfig["jsconfig.json"]:::tooling
        ESLintC["eslint.config.js"]:::tooling
        TailwindC1["tailwind.config.js"]:::tooling
        PostCSSC1["postcss.config.js"]:::tooling
        PackageJSON["package.json / package-lock.json"]:::tooling
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment" 
        direction TB
        ViteDev["Vite Dev Server & Plugins"]:::build
        ViteConfig["vite.config.js"]:::build
        PostCSSC2["postcss.config.js"]:::build
        TailwindC2["tailwind.config.js"]:::build
        HTML["public/index.html"]:::build
        Bundler["Vite Bundler"]:::build
        StaticHost["Static Hosting (Netlify, Vercel, S3+CDN)"]:::build
    end

    %% Client-Side SPA Layer
    subgraph "Client-Side SPA" 
        direction TB
        Browser["Browser"]:::frontend
        subgraph "Entry & Routing"
            direction TB
            Main["src/main.jsx"]:::frontend
            App["src/App.jsx"]:::frontend
            IndexCSS["src/index.css"]:::frontend
            Pages["src/pages/"]:::frontend
        end
        subgraph "Data-Access Layer"
            direction TB
            SupabaseClient["src/lib/supabaseClient.js"]:::data
            API["src/api.js"]:::data
        end
        subgraph "UI Components"
            direction TB
            Components["src/components/"]:::frontend
            Common["src/components/common/"]:::frontend
            Carousel["src/components/Carousel.jsx"]:::frontend
            Hero["src/components/HomeHeroSection.jsx"]:::frontend
        end
        subgraph "Backend Helper Components"
            direction TB
            BackendHelper["src/components/backend/"]:::frontend
        end
        subgraph "Dashboard Components"
            direction TB
            DashboardComp["src/components/dashboard/"]:::frontend
        end
        subgraph "Public & Static Assets"
            direction TB
            PublicDir["public/"]:::assets
            Assets["src/assets/"]:::assets
        end
    end

    %% External Services Layer
    subgraph "External BaaS (Supabase)" 
        direction TB
        Auth["Auth Service"]:::external
        DB["Postgres Database"]:::external
        Storage["Storage Service"]:::external
    end

    %% Connections
    IDE -->|"code/git"| ViteDev
    Git -->|push/pull| ViteDev
    ViteDev -->|"config"| Bundler
    ViteConfig --> Bundler
    PostCSSC2 --> Bundler
    TailwindC2 --> Bundler
    Bundler -->|deploy static assets| StaticHost
    HTML -->|initial load| Browser
    StaticHost -->|serves| Browser

    Browser --> Main
    Main --> App
    App --> Pages
    App --> IndexCSS
    App -->|"routes"| Pages

    Pages -->|"renders"| Browser
    Components -->|"UI render"| Browser
    Carousel --> Components
    Hero --> Components
    Common --> Components

    SupabaseClient --> API
    API -->|"SDK calls"| SupabaseClient
    Browser --> SupabaseClient
    Browser --> API

    Browser -->|"supabase-js"| Auth
    Browser -->|"supabase-js"| DB
    Browser -->|"supabase-js"| Storage

    BackendHelper --> Components
    DashboardComp --> Components

    PublicDir -->|static assets| Browser
    Assets -->|media| Browser

    %% Click Events
    click DotEnv "https://github.com/bhaveshmp/mealmate/blob/main/.env"
    click GitIgnore "https://github.com/bhaveshmp/mealmate/blob/main/.gitignore"
    click README "https://github.com/bhaveshmp/mealmate/blob/main/README.md"
    click JSConfig "https://github.com/bhaveshmp/mealmate/blob/main/jsconfig.json"
    click ESLintC "https://github.com/bhaveshmp/mealmate/blob/main/eslint.config.js"
    click TailwindC1 "https://github.com/bhaveshmp/mealmate/blob/main/tailwind.config.js"
    click PostCSSC1 "https://github.com/bhaveshmp/mealmate/blob/main/postcss.config.js"
    click PackageJSON "https://github.com/bhaveshmp/mealmate/blob/main/package.json"
    click ViteConfig "https://github.com/bhaveshmp/mealmate/blob/main/vite.config.js"
    click PostCSSC2 "https://github.com/bhaveshmp/mealmate/blob/main/postcss.config.js"
    click TailwindC2 "https://github.com/bhaveshmp/mealmate/blob/main/tailwind.config.js"
    click HTML "https://github.com/bhaveshmp/mealmate/blob/main/public/index.html"
    click Main "https://github.com/bhaveshmp/mealmate/blob/main/src/main.jsx"
    click App "https://github.com/bhaveshmp/mealmate/blob/main/src/App.jsx"
    click IndexCSS "https://github.com/bhaveshmp/mealmate/blob/main/src/index.css"
    click Pages "https://github.com/bhaveshmp/mealmate/tree/main/src/pages/"
    click SupabaseClient "https://github.com/bhaveshmp/mealmate/blob/main/src/lib/supabaseClient.js"
    click API "https://github.com/bhaveshmp/mealmate/blob/main/src/api.js"
    click Components "https://github.com/bhaveshmp/mealmate/tree/main/src/components/"
    click Common "https://github.com/bhaveshmp/mealmate/tree/main/src/components/common/"
    click Carousel "https://github.com/bhaveshmp/mealmate/blob/main/src/components/Carousel.jsx"
    click Hero "https://github.com/bhaveshmp/mealmate/blob/main/src/components/HomeHeroSection.jsx"
    click BackendHelper "https://github.com/bhaveshmp/mealmate/tree/main/src/components/backend/"
    click DashboardComp "https://github.com/bhaveshmp/mealmate/tree/main/src/components/dashboard/"
    click PublicDir "https://github.com/bhaveshmp/mealmate/tree/main/public/"
    click Assets "https://github.com/bhaveshmp/mealmate/tree/main/src/assets/"

    %% Styles
    classDef tooling fill:#D6EFFF,stroke:#1E3A8A,color:#1E3A8A
    classDef build fill:#FFE7D9,stroke:#C2410C,color:#C2410C
    classDef frontend fill:#D1FAE5,stroke:#065F46,color:#065F46
    classDef data fill:#FEF3C7,stroke:#92400E,color:#92400E
    classDef assets fill:#F3E8FF,stroke:#6B21A8,color:#6B21A8
    classDef external fill:#FEE2E2,stroke:#991B1B,color:#991B1B
```
