# jiwankumar12yes/vr-trading-e-com architecture

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

- Interactive diagram: https://gitdiagram.com/jiwankumar12yes/vr-trading-e-com
- Repository: https://github.com/jiwankumar12yes/vr-trading-e-com

## Overview

##### Project type and purpose
- This is a MERN-stack (MongoDB, Express, React, Node) e-commerce web application (“VR-Trading-E-Com”) with a RESTful API backend and a React frontend.
- The README’s “E-com Mern Stack App With API” line confirms it’s a full-stack web app designed to sell products online, manage categories, users, orders, and handle authentication.

##### File structure
- Top-level:
- client/ – React app; build/ contains the production static assets (CSS, JS bundles, index.html, manifest).
- config/db.js – database connection (MongoDB URI, options).
- controllers/ – business-logic handlers (auth, category, product).
- models/ – Mongoose schemas for user, product, category, order.
- routes/ – Express route definitions mapping HTTP endpoints to controller methods.
- middlewares/ – Express middleware (e.g. auth token validation).
- helpers/ – utility functions (e.g. password hashing, token generation).
- server.js – application entry point, Express app setup, middleware registration, route mounting, server listen.
- package.json / package-lock.json – npm dependencies and scripts.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser and Frontend
    Browser["User's Browser"]:::external
    subgraph "React SPA" 
        direction TB
        ClientRoot["client/"]:::frontend
        IndexHTML["index.html"]:::frontend
        CSS["main.*.css"]:::frontend
        JSBundle["main.*.js"]:::frontend
    end

    %% Backend API
    subgraph "Express API" 
        direction TB
        Server["server.js"]:::backend
        subgraph "Routing Layer"
            direction TB
            AuthRoute["auth.route.js"]:::backend
            CategoryRoute["category.route.js"]:::backend
            ProductRoute["productRoutes.js"]:::backend
        end
        subgraph "Middleware Layer"
            direction TB
            AuthMiddleware["auth.middleware.js"]:::backend
        end
        subgraph "Controllers Layer"
            direction TB
            AuthController["auth.controller.js"]:::backend
            CategoryController["category.controller.js"]:::backend
            ProductController["productController.js"]:::backend
        end
        subgraph "Helpers Layer"
            direction TB
            AuthHelper["auth.helper.js"]:::backend
        end
        subgraph "Models Layer"
            direction TB
            UserModel["user.model.js"]:::backend
            CategoryModel["category.model.js"]:::backend
            ProductModel["productModel.js"]:::backend
            OrderModel["orderModel.js"]:::backend
        end
    end

    %% Database
    DB[("MongoDB")]:::database

    %% External Services
    PaymentGateway["Payment Gateway"]:::external
    EmailService["Email Service"]:::external

    %% Connections
    Browser -->|"loads"| IndexHTML
    IndexHTML -->|"loads assets"| CSS
    IndexHTML -->|"loads assets"| JSBundle
    JSBundle -->|"API requests"| Server

    Server --> AuthRoute
    Server --> CategoryRoute
    Server --> ProductRoute

    AuthRoute --> AuthMiddleware
    CategoryRoute --> AuthMiddleware
    ProductRoute --> AuthMiddleware

    AuthMiddleware --> AuthController
    CategoryRoute --> CategoryController
    ProductRoute --> ProductController

    AuthController --> AuthHelper
    AuthController --> UserModel

    CategoryController --> CategoryModel
    ProductController --> ProductModel

    UserModel --> DB
    CategoryModel --> DB
    ProductModel --> DB
    OrderModel --> DB

    Server -->|"worker tasks"| PaymentGateway
    Server -->|"email notifications"| EmailService

    %% Click Events
    click ClientRoot "https://github.com/jiwankumar12yes/vr-trading-e-com/tree/main/client/"
    click IndexHTML "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/client/build/index.html"
    click CSS "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/client/build/static/css/main.*.css"
    click JSBundle "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/client/build/static/js/main.*.js"
    click Server "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/server.js"
    click AuthRoute "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/routes/auth.route.js"
    click CategoryRoute "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/routes/category.route.js"
    click ProductRoute "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/routes/productRoutes.js"
    click AuthMiddleware "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/middlewares/auth.middleware.js"
    click AuthController "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/controllers/auth.controller.js"
    click CategoryController "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/controllers/category.controller.js"
    click ProductController "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/controllers/productController.js"
    click AuthHelper "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/helpers/auth.helper.js"
    click UserModel "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/models/user.model.js"
    click CategoryModel "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/models/category.model.js"
    click ProductModel "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/models/productModel.js"
    click OrderModel "https://github.com/jiwankumar12yes/vr-trading-e-com/blob/main/models/orderModel.js"
    click PaymentGateway "https://github.com/jiwankumar12yes/vr-trading-e-com/tree/main/external/payment"
    click EmailService "https://github.com/jiwankumar12yes/vr-trading-e-com/tree/main/external/email"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#4285F4,color:#000
    classDef backend fill:#E6F4EA,stroke:#34A853,color:#000
    classDef database fill:#FFF4E5,stroke:#FBBC05,color:#000
    classDef external fill:#F0F0F0,stroke:#888,color:#000
```
