# abhayrajsingh23/foody-circle architecture

> Architecture diagram of the GitHub repository abhayrajsingh23/foody-circle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhayrajsingh23/foody-circle
- Repository: https://github.com/abhayrajsingh23/foody-circle

## Overview

##### Project type and purpose
- This is a full-stack web application using the MERN stack (MongoDB, Express.js, React.js, Node.js).
- It’s an online food delivery app (“Foody Circle”) that lets users browse a menu, register/login, place orders, and process payments via Razorpay.

##### File structure
- Top level:
- backend/   → Node.js + Express code
- public/    → static assets and the HTML entry point
- src/       → React application
- package.json (root)
- backend/:
- index.js  → server bootstrap
- db.js     → MongoDB connection logic
- models/   → Mongoose schemas (User.js, Order.js)
- Routes/   → API endpoints (CreateUser.js, DisplayData.js, OrderData.js)
- src/:
- App.js, Urls.js, Modal.js → core React components
- components/ → UI elements (Card, Navbar, Footer, ContextReducer, carousal)
- screens/    → page-level views (Home, Cart, MyOrder, Login, Signup)
- public/index.html → React mount point
- Configuration and scripts:
- backend/package.json, package-lock.json
- root-level package.json for monorepo scripts (if any)

##### README for additional insights
- Tech stack: React, Bootstrap-dark-5, Express, MongoDB Atlas, bcryptjs, JWT, Razorpay.
- Features: authentication, dynamic menu, checkout & payment, responsive UI.
- Deployment notes: free-tier backend host may sleep.

##### Main components
a. Frontend (React application)
– Public static files served by a simple web server (webpack-dev-server in dev)
– React components, state management via ContextReducer
– Communicates with backend over REST (HTTPS)
b. Backend (Node.js + Express)
– API layer with three main route groups: user auth (CreateUser), menu retrieval (DisplayData), order placement (OrderData)
– Business logic for hashing passwords (bcryptjs) and generating JWTs
– Razorpay integration module (calls out to payment gateway)
c. Database
– MongoDB Atlas cluster
– Mongoose models: User, Order
d. External services
– Razorpay payment gateway (payment API)
e. Optional utility/service
– JWT token validation middleware (in backend before protected routes)

##### Relationships and interactions
- User’s browser → HTTP(S) → Frontend React app
- React app → REST API calls → Express server
- Express server → CRUD operations → MongoDB Atlas
- Express server → API call → Razorpay → payment confirmation → Express → React
- JWT flow: on login/signup, Express returns JWT → stored by React (localStorage) → attached to Authorization header on protected calls

##### Architectural patterns and design principles
- Client–Server (separation of concerns)
- RESTful API layer
- Layered architecture in backend: Routes → Controllers/Services → Data layer (Mongoose)
- Stateless authentication with JWT
- Single-page application (SPA) on the frontend

##### Technologies and libraries to annotate
- Frontend: React.js, Bootstrap-dark-5, Context API, Razorpay.js SDK
- Backend: Node.js, Express.js, bcryptjs, jsonwebtoken (JWT), Mongoose
- Database: MongoDB Atlas
- Deployment: nodemon (dev), npm scripts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Static["public/index.html"]:::client
        click Static "https://github.com/abhayrajsingh23/foody-circle/blob/main/public/index.html"
        ReactApp["React SPA"]:::client
        click ReactApp "https://github.com/abhayrajsingh23/foody-circle/tree/main/src/"
        Static --> ReactApp
    end

    %% Frontend Application Components
    subgraph "Frontend - React Application"
        direction TB
        App["App.js"]:::client
        click App "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/App.js"
        Urls["Urls.js"]:::client
        click Urls "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/Urls.js"
        Modal["Modal.js"]:::client
        click Modal "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/Modal.js"
        ComponentsDir["components/"]:::client
        click ComponentsDir "https://github.com/abhayrajsingh23/foody-circle/tree/main/src/components/"
        Card["Card.js"]:::client
        click Card "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/components/Card.js"
        Navbar["Navbar.js"]:::client
        click Navbar "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/components/Navbar.js"
        Footer["Footer.js"]:::client
        click Footer "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/components/Footer.js"
        Carousel["carousal.js"]:::client
        click Carousel "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/components/carousal.js"
        ContextReducer["ContextReducer.js"]:::client
        click ContextReducer "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/components/ContextReducer.js"
        ScreensDir["screens/"]:::client
        click ScreensDir "https://github.com/abhayrajsingh23/foody-circle/tree/main/src/screens/"
        Home["Home.jsx"]:::client
        click Home "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/Home.jsx"
        Cart["Cart.js"]:::client
        click Cart "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/Cart.js"
        MyOrder["MyOrder.js"]:::client
        click MyOrder "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/MyOrder.js"
        Login["Login.jsx"]:::client
        click Login "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/Login.jsx"
        Signup["Signup.jsx"]:::client
        click Signup "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/Signup.jsx"
        MockData["mockData.js"]:::client
        click MockData "https://github.com/abhayrajsingh23/foody-circle/blob/main/src/screens/mockData.js"
    end

    ReactApp -->|Uses| App
    App --> Urls
    App --> Modal
    App --> ComponentsDir
    App --> ScreensDir

    %% Backend Layer
    subgraph "Server (Express API)"
        direction TB
        ServerIndex["index.js"]:::server
        click ServerIndex "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/index.js"
        DBConn["db.js"]:::server
        click DBConn "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/db.js"
        JWTMiddleware["JWT Middleware"]:::server
        subgraph "Routes"
            direction TB
            CreateUser["CreateUser.js"]:::server
            click CreateUser "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/Routes/CreateUser.js"
            DisplayData["DisplayData.js"]:::server
            click DisplayData "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/Routes/DisplayData.js"
            OrderData["OrderData.js"]:::server
            click OrderData "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/Routes/OrderData.js"
        end
        subgraph "Models"
            direction TB
            UserModel["User.js"]:::server
            click UserModel "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/models/User.js"
            OrderModel["Order.js"]:::server
            click OrderModel "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/models/Order.js"
        end
        PackageJSON["package.json"]:::server
        click PackageJSON "https://github.com/abhayrajsingh23/foody-circle/blob/main/backend/package.json"
    end

    ReactApp -->|REST Calls| ServerIndex
    ServerIndex --> DBConn
    ServerIndex --> JWTMiddleware
    ServerIndex --> CreateUser
    ServerIndex --> DisplayData
    ServerIndex --> OrderData
    CreateUser --> UserModel
    OrderData --> OrderModel

    %% Database
    DB[(MongoDB Atlas)]:::db
    DBConn --> DB
    UserModel --> DB
    OrderModel --> DB

    %% External Services
    Razorpay["Razorpay Gateway"]:::external
    OrderData -->|Payment Requests| Razorpay
    Razorpay -->|Payment Confirmation| OrderData

    %% Root Monorepo
    RootPackage["package.json"]:::server
    click RootPackage "https://github.com/abhayrajsingh23/foody-circle/blob/main/package.json"

    %% Flows
    CreateUser -->|POST /create-user| ServerIndex
    DisplayData -->|GET /menu| ServerIndex
    OrderData -->|POST /order| ServerIndex

    %% Styles
    classDef client fill:#AED6F1,stroke:#2980B9,color:#1B2631;
    classDef server fill:#ABEBC6,stroke:#27AE60,color:#1B2631;
    classDef db fill:#F9E79F,stroke:#F1C40F,color:#1B2631;
    classDef external fill:#D7BDE2,stroke:#8E44AD,color:#1B2631;
```
