# avii-ks/foodiegoo architecture

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

- Interactive diagram: https://gitdiagram.com/avii-ks/foodiegoo
- Repository: https://github.com/avii-ks/foodiegoo

## Overview

##### Project Type and Purpose
- This is a full-stack MERN (MongoDB, Express.js, React.js, Node.js) food-delivery application with two React frontends (Customer App and Admin Panel), a Node/Express REST API backend, a MongoDB database, and Stripe for payments.
- The Customer App lets users browse items, manage carts, place orders (credit/debit card via Stripe or COD), and track order status. The Admin Panel enables restaurant staff to manage menu items, orders, and view analytics in real time.

##### File Structure
- Top-level directories:
- frontend/ – React customer application
- admin/ – React admin panel
- backend/ – Node.js/Express API server
- backend/ follows an MVC-style organization:
- config/ (db.js)
- models/ (Mongoose schemas)
- controllers/ (business logic)
- routes/ (Express routers)
- middleware/ (auth)
- Configuration and deployment files: .env.example, vercel.json, deploy scripts, start.sh.
- Frontends use Vite as build tool, React Router, Axios, and a Context API for state.

##### Main Components and Their Roles
- Customer Frontend (React):
- Pages: Home, Menu, Cart, Place Order, My Orders, Verify
- Components: Navbar, FoodDisplay, LoginPopup, etc.
- StoreContext (React Context) to manage cart and user state
- Admin Frontend (React):
- Pages: List, Add, Orders
- Components: Sidebar, Navbar, Tables, Forms
- Backend API (Node/Express):
- Exposes REST endpoints (/api/user, /api/food, /api/order, /api/cart)
- Uses JWT for auth, Stripe SDK for payments, Multer for image uploads
- Connects to MongoDB (via Mongoose) – collections: users, foods, orders
- MongoDB Atlas or local instance – persisting user profiles, cart data, menu items, and orders
- Stripe – external payment processing service

##### Relationships and Data Flows
- User Browser ↔ Customer React App
- HTTP requests for static assets and bundle from web server (Netlify/Vercel)
- Customer React App → Backend REST API
- Axios POST/GET for authentication, menu retrieval, cart operations, order placement
- Customer React App → Stripe Checkout (redirect or client SDK)
- Admin React App → Backend REST API
- Axios GET/POST to fetch/update food items and orders
- Backend → MongoDB
- Mongoose reads/writes documents
- Backend → Stripe
- Creates payment intent, verifies payment, updates order status

##### Architectural Patterns and Principles
- Separation of concerns: distinct codebases for customer UI, admin UI, and API
- MVC pattern on the backend with controllers → routes → models
- Stateless REST API with JWT-based authentication
- Real-time-style updates (Admin polls every 10s, can be replaced with WebSockets)
- Client-side state management via React Context in the Customer App
- Deployment via serverless (Vercel for frontends, Render or similar for backend)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        subgraph "Customer React App"
            direction TB
            CustApp["Customer React App"]:::frontend
            HomePage["Home Page"]:::frontend
            ExploreMenu["ExploreMenu Component"]:::frontend
            FoodDisplay["FoodDisplay Component"]:::frontend
            FoodItem["FoodItem Component"]:::frontend
            NavbarCust["Navbar"]:::frontend
            LoginPopup["Login Popup"]:::frontend
            CartPage["Cart Page"]:::frontend
            PlaceOrderPage["Place Order Page"]:::frontend
            MyOrdersPage["My Orders Page"]:::frontend
            VerifyPage["Order Verification Page"]:::frontend
            StoreContext["StoreContext"]:::frontend
        end
        subgraph "Admin React App"
            direction TB
            AdminApp["Admin React App"]:::frontend
            ListPage["List Menu Items Page"]:::frontend
            AddPage["Add Menu Item Page"]:::frontend
            OrdersPage["Orders Management Page"]:::frontend
            Sidebar["Sidebar Navigation"]:::frontend
            NavbarAdmin["Top Navbar"]:::frontend
        end
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        API["Node/Express API Server"]:::backend
        ServerEntry["server.js"]:::backend
        DBConfig["db.js"]:::backend
        AuthMW["Authentication Middleware"]:::backend
        subgraph "Controllers"
            UserCtrl["User Controller"]:::backend
            FoodCtrl["Food Controller"]:::backend
            OrderCtrl["Order Controller"]:::backend
            CartCtrl["Cart Controller"]:::backend
        end
        subgraph "Routes"
            UserRoute["User Routes"]:::backend
            FoodRoute["Food Routes"]:::backend
            OrderRoute["Order Routes"]:::backend
            CartRoute["Cart Routes"]:::backend
        end
        subgraph "Models"
            UserModel["User Model"]:::backend
            FoodModel["Food Model"]:::backend
            OrderModel["Order Model"]:::backend
            OtherModel["Other Schema"]:::backend
        end
        StripeTest["Stripe Test Script"]:::backend
    end

    %% Data & Services Layer
    subgraph "Data & Services Layer"
        MongoDB[(MongoDB)]:::db
        Stripe[(Stripe)]:::external
    end

    %% Connections
    CustApp -->|"HTTPS/REST"| API
    AdminApp -->|"HTTPS/REST"| API
    API -->|"Mongoose CRUD"| MongoDB
    API -->|"Stripe SDK/Webhooks"| Stripe

    %% Click Events for Customer Components
    click CustApp "https://github.com/avii-ks/foodiegoo/tree/main/frontend/"
    click HomePage "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/pages/home/Home.jsx"
    click ExploreMenu "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/components/ExploreMenu/ExploreMenu.jsx"
    click FoodDisplay "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/components/FoodDisplay/FoodDisplay.jsx"
    click FoodItem "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/components/FoodItem/FoodItem.jsx"
    click NavbarCust "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/components/navbar/navbar.jsx"
    click LoginPopup "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/components/LoginPopup/LoginPopup.jsx"
    click CartPage "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/pages/cart/cart.jsx"
    click PlaceOrderPage "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/pages/placeorder/placeorder.jsx"
    click MyOrdersPage "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/pages/MyOrders/MyOrders.jsx"
    click VerifyPage "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/pages/Verify/Verify.jsx"
    click StoreContext "https://github.com/avii-ks/foodiegoo/blob/main/frontend/src/context/StoreContext.jsx"

    %% Click Events for Admin Components
    click AdminApp "https://github.com/avii-ks/foodiegoo/tree/main/admin/"
    click ListPage "https://github.com/avii-ks/foodiegoo/blob/main/admin/src/pages/List/List.jsx"
    click AddPage "https://github.com/avii-ks/foodiegoo/blob/main/admin/src/pages/Add/Add.jsx"
    click OrdersPage "https://github.com/avii-ks/foodiegoo/blob/main/admin/src/pages/Orders/Orders.jsx"
    click Sidebar "https://github.com/avii-ks/foodiegoo/blob/main/admin/src/components/Sidebar/Sidebar.jsx"
    click NavbarAdmin "https://github.com/avii-ks/foodiegoo/blob/main/admin/src/components/Navbar/Navbar.jsx"

    %% Click Events for Backend Components
    click API "https://github.com/avii-ks/foodiegoo/tree/main/backend/"
    click ServerEntry "https://github.com/avii-ks/foodiegoo/blob/main/backend/server.js"
    click DBConfig "https://github.com/avii-ks/foodiegoo/blob/main/backend/config/db.js"
    click UserCtrl "https://github.com/avii-ks/foodiegoo/blob/main/backend/controllers/userController.js"
    click FoodCtrl "https://github.com/avii-ks/foodiegoo/blob/main/backend/controllers/foodController.js"
    click OrderCtrl "https://github.com/avii-ks/foodiegoo/blob/main/backend/controllers/orderController.js"
    click CartCtrl "https://github.com/avii-ks/foodiegoo/blob/main/backend/controllers/cartController.js"
    click AuthMW "https://github.com/avii-ks/foodiegoo/blob/main/backend/middleware/auth.js"
    click UserRoute "https://github.com/avii-ks/foodiegoo/blob/main/backend/routes/userRoute.js"
    click FoodRoute "https://github.com/avii-ks/foodiegoo/blob/main/backend/routes/foodRoute.js"
    click OrderRoute "https://github.com/avii-ks/foodiegoo/blob/main/backend/routes/orderRoute.js"
    click CartRoute "https://github.com/avii-ks/foodiegoo/blob/main/backend/routes/cartRoute.js"
    click UserModel "https://github.com/avii-ks/foodiegoo/blob/main/backend/models/userModel.js"
    click FoodModel "https://github.com/avii-ks/foodiegoo/blob/main/backend/models/foodModel.js"
    click OrderModel "https://github.com/avii-ks/foodiegoo/blob/main/backend/models/orderModel.js"
    click OtherModel "https://github.com/avii-ks/foodiegoo/blob/main/backend/models/f_m_ad.js"
    click StripeTest "https://github.com/avii-ks/foodiegoo/blob/main/backend/test-stripe.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:#6c757d,color:#6c757d;
```
