# prudhvi-1618/dineease architecture

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

- Interactive diagram: https://gitdiagram.com/prudhvi-1618/dineease
- Repository: https://github.com/prudhvi-1618/dineease

## Overview

##### Project type and purpose
- This is a full-stack web application called “Digital Diner” – a restaurant ordering system with a React frontend and a Node/Express backend.
- It uses a hybrid data architecture: MongoDB for menu items (flexible schema) and PostgreSQL for orders (relational history).

##### File structure
- Top-level folders:
- backend/ – Express app with config, controllers, models, and routes
- frontend/ – React (Vite) app with components, pages, and an api.js client
- Config files in backend/src/config set up MongoDB and PostgreSQL connections.
- backend/src/controllers + models implement an MVC-style layering.
- frontend/src/api.js centralizes HTTP calls (Axios).

##### README for additional insights
- Tech stack: React, Axios, React Router; Node.js/Express; Mongoose & node-postgres.
- Key endpoints: GET /api/menu, GET /api/menu/categories, POST /api/orders, GET /api/orders/history.
- Deployment targets: Frontend on Vercel; Backend on Render.

##### Essential elements
– Don’t clutter with every single file—group by logical components (controllers/models/routes → “API Layer”).
– Capture all major data flows, especially the hybrid DB interactions.
– Detail the two connection modules (MongoDbConnect.js and postgresConnect.js) to illustrate how the API orchestrates data access.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        RC["React Client"]:::frontend
        Router["React Router & App Entry"]:::frontend
        APIClient["HTTP Client (Axios)"]:::frontend
        UICmp["UI Components"]:::frontend
        Pages["Page Layouts & Routes"]:::frontend
    end

    %% API Layer
    subgraph "API Layer (Express)"
        direction TB
        Index["API Entry Point (index.js)"]:::backend
        subgraph "Config Modules"
            MongoConnect["MongoDB Connection Module"]:::backend
            PostgresConnect["PostgreSQL Connection Module"]:::backend
        end
        subgraph "Routes"
            MenuRoutes["Menu Item Routes"]:::backend
            OrderRoutes["Order Routes"]:::backend
            OTProutes["OTP Routes"]:::backend
        end
        subgraph "Controllers"
            MenuCtrl["Menu Item Controller"]:::backend
            OrderCtrl["Order Controller"]:::backend
            OTPCtrl["OTP Controller"]:::backend
        end
        subgraph "Models & Scripts"
            MenuModel["Menu Item Data Model"]:::backend
            OrderModel["Order Data Model"]:::backend
            DBInit["DB Schema Init Script"]:::backend
        end
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        MongoDB["MongoDB Cluster"]:::database
        PostgreSQL["PostgreSQL Cluster"]:::database
    end

    %% Hosting
    subgraph "Hosting"
        direction TB
        Vercel["Vercel (Frontend)"]:::external
        Render["Render (Backend)"]:::external
    end

    %% Data Flows
    RC -->|"navigates pages"| Router
    Router -->|"calls API via Axios"| APIClient
    APIClient -->|"GET/POST /api/*"| Index
    Index --> MongoConnect
    Index --> PostgresConnect

    Index --> MenuRoutes
    Index --> OrderRoutes
    Index --> OTProutes

    MenuRoutes --> MenuCtrl
    OrderRoutes --> OrderCtrl
    OTProutes --> OTPCtrl

    MenuCtrl --> MenuModel
    MenuCtrl --> MongoDB
    OrderCtrl --> OrderModel
    OrderCtrl --> PostgreSQL
    OTPCtrl --> PostgreSQL

    OrderModel --> DBInit

    Vercel --> RC
    Render --> Index

    %% Click Events
    click RC "https://github.com/prudhvi-1618/dineease/tree/master/frontend/"
    click APIClient "https://github.com/prudhvi-1618/dineease/blob/master/frontend/src/api.js"
    click Router "https://github.com/prudhvi-1618/dineease/blob/master/frontend/src/App.jsx"
    click UICmp "https://github.com/prudhvi-1618/dineease/tree/master/frontend/src/components/"
    click Pages "https://github.com/prudhvi-1618/dineease/tree/master/frontend/src/pages/"
    click Index "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/index.js"
    click MongoConnect "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/config/MongoDbConnect.js"
    click PostgresConnect "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/config/postgresConnect.js"
    click MenuCtrl "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/controllers/menuItem.js"
    click OrderCtrl "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/controllers/order.js"
    click OTPCtrl "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/controllers/otp.js"
    click MenuRoutes "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/routes/menuItem.js"
    click OrderRoutes "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/routes/order.js"
    click OTProutes "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/routes/otp.js"
    click MenuModel "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/models/menuItem.js"
    click OrderModel "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/models/order.js"
    click DBInit "https://github.com/prudhvi-1618/dineease/blob/master/backend/src/data/createTable.js"
    click Index "https://github.com/prudhvi-1618/dineease/blob/master/backend/package.json"
    click RC "https://github.com/prudhvi-1618/dineease/blob/master/frontend/package.json"

    %% Styles
    classDef frontend fill:#bbe1fa,stroke:#1b262c,color:#0f4c75;
    classDef backend fill:#c3fade,stroke:#3282b8,color:#1b262c;
    classDef database fill:#ffd8a9,stroke:#ee7452,color:#6f1d1b;
    classDef external fill:#e0e0e0,stroke:#5f5f5f,color:#2c3e50;
```
