# nil1729/food-order-app architecture

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

- Interactive diagram: https://gitdiagram.com/nil1729/food-order-app
- Repository: https://github.com/nil1729/food-order-app

## Overview

##### Project type and purpose
- This is a full-stack food-ordering web application (SPA) built with Vue.js on the client, Node.js/Express for the API server, MongoDB for persistent storage, Firebase for file storage and authentication, and Razorpay for payment processing.

##### File structure
- Top-level “client/” directory contains the Vue.js SPA: components, layouts, pages, Vuex store, router, Firebase front-end config.
- Root folder holds the Express app (`server.js`, `index.js`, `routes/`, `models/`, `middleware/`, `config/`), Docker/Nginx configs, admin scripts.
- Config files (`config/db.js`, `config/admin.js`, `config/razorpay.js`) set up MongoDB, Firebase Admin SDK, Razorpay.
- `models/` defines Mongoose schemas for User, Product, Order.
- `routes/` defines the REST API endpoints (auths, products, orders, admin).
- `middleware/` contains authentication, pagination.
- Tests folder shows one server integration test.

##### README for additional insights
- The README confirms the tech stack and describes how Firebase Authentication and Storage are used, plus Razorpay for payments.
- It notes an admin mode for product management.

a. Main components
- Client (Vue.js SPA with Vuex & Vue Router)
- API Server (Node.js/Express)
- Data Store (MongoDB Atlas)
- File Storage & Auth (Firebase Storage & Firebase Authentication)
- Payment Gateway (Razorpay)
- Admin interface (Node script / Express admin routes)
- Reverse Proxy (Nginx) / Docker

b. Relationships & interactions
- User browser ←→ SPA (HTTPS)
- SPA → API server (REST calls for products, cart, orders, profile)
- API server ↔ MongoDB (CRUD on products, orders, users)
- API server ↔ Firebase Admin SDK (upload product images to Storage, validate tokens)
- SPA ↔ Firebase Auth (client-side login via Google/email)
- SPA → Razorpay (checkout widget) → Razorpay backend
- API server → Razorpay (verify and capture payments)
- Admin script/UI → API server → MongoDB

c. Architectural patterns & design principles
- Client: Component-based SPA, state managed by Vuex, route-based code splitting.
- API: MVC-like organization (routes → controllers in `routes/`, models in `models/`, middleware for auth/pagination).
- External services abstracted by config modules (`config/razorpay.js`, `config/admin.js`).
- Separation of concerns: authentication, business logic, data access.

d. Key technologies/frameworks
- Vue.js, Vuex, Vue Router (frontend)
- Node.js, Express, Mongoose (backend)
- MongoDB Atlas (NoSQL database)
- Firebase Storage & Admin SDK, Firebase Auth (file storage & user auth)
- Razorpay Checkout & REST API (payments)
- Nginx (reverse-proxy), Docker (containerization)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["User Browser"]:::frontend
        SPA["Vue.js SPA"]:::frontend
        Store["Vuex Store"]:::frontend
        Router["Vue Router"]:::frontend
        FirebaseClient["Firebase Auth & Storage SDK"]:::external
        PaymentWidget["Razorpay Checkout Widget"]:::external

        Browser --> SPA
        SPA --> Store
        SPA --> Router
        SPA --> FirebaseClient
        SPA --> PaymentWidget
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        API["Express API Server"]:::backend

        subgraph "Routes (API Endpoints)"
            direction TB
            AuthRoutes["Auth Routes"]:::backend
            ProductRoutes["Product Routes"]:::backend
            OrderRoutes["Order Routes"]:::backend
            AdminRoutes["Admin Routes"]:::backend
        end

        subgraph "Middleware"
            direction TB
            AuthMiddleware["Auth Middleware"]:::backend
            PaginateMiddleware["Pagination Middleware"]:::backend
        end

        subgraph "Config Modules"
            direction TB
            DBConfig["MongoDB Config"]:::backend
            FirebaseAdminConfig["Firebase Admin SDK Config"]:::backend
            RazorpayConfig["Razorpay Config"]:::backend
        end

        AdminCLI["Admin Interface CLI"]:::backend

        SPA -->|"REST"| API
        API --> AuthRoutes
        API --> ProductRoutes
        API --> OrderRoutes
        API --> AdminRoutes
        AuthRoutes --> AuthMiddleware
        ProductRoutes --> PaginateMiddleware
        API --> DBConfig
        API --> FirebaseAdminConfig
        API --> RazorpayConfig
        AdminCLI --> API
    end

    %% Data & External Services
    subgraph "Data & Services"
        direction TB
        MongoDB["MongoDB Atlas"]:::database
        FirebaseAdmin["Firebase Admin & Storage"]:::external
        Razorpay["Razorpay Payment Gateway"]:::external

        API --> MongoDB
        API --> FirebaseAdmin
        API --> Razorpay
    end

    %% Deployment
    subgraph "Deployment"
        direction TB
        Docker["Docker Container"]:::infra
        Nginx["Nginx Reverse Proxy"]:::infra

        Docker --> Nginx
        Nginx --> API
        Nginx --> SPA
    end

    %% Click Events
    click SPA "https://github.com/nil1729/food-order-app/tree/master/client/src/"
    click Store "https://github.com/nil1729/food-order-app/tree/master/client/src/store/"
    click Router "https://github.com/nil1729/food-order-app/blob/master/client/src/routes/routes.js"
    click FirebaseClient "https://github.com/nil1729/food-order-app/blob/master/client/src/firebase/config.js"
    click API "https://github.com/nil1729/food-order-app/blob/master/server.js"
    click AuthRoutes "https://github.com/nil1729/food-order-app/blob/master/routes/auths.js"
    click ProductRoutes "https://github.com/nil1729/food-order-app/blob/master/routes/products.js"
    click OrderRoutes "https://github.com/nil1729/food-order-app/blob/master/routes/orders.js"
    click AdminRoutes "https://github.com/nil1729/food-order-app/blob/master/routes/admin.js"
    click AuthMiddleware "https://github.com/nil1729/food-order-app/blob/master/middleware/auth.js"
    click PaginateMiddleware "https://github.com/nil1729/food-order-app/blob/master/middleware/paginate.js"
    click DBConfig "https://github.com/nil1729/food-order-app/blob/master/config/db.js"
    click FirebaseAdminConfig "https://github.com/nil1729/food-order-app/blob/master/config/admin.js"
    click RazorpayConfig "https://github.com/nil1729/food-order-app/blob/master/config/razorpay.js"
    click AdminCLI "https://github.com/nil1729/food-order-app/blob/master/admin/index.js"
    click MongoDB "https://github.com/nil1729/food-order-app/blob/master/config/db.js"
    click Docker "https://github.com/nil1729/food-order-app/tree/master/Dockerfile"
    click Nginx "https://github.com/nil1729/food-order-app/blob/master/nginx.conf"

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#0b5394,color:#0b5394
    classDef backend fill:#d9ead3,stroke:#38761d,color:#38761d
    classDef database fill:#f9cb9c,stroke:#b45f06,color:#b45f06
    classDef external fill:#ead1dc,stroke:#a64d79,color:#a64d79
    classDef infra fill:#ececec,stroke:#666666,color:#333333
```
