# yogndrr/mern-ecommerce-site architecture

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

- Interactive diagram: https://gitdiagram.com/yogndrr/mern-ecommerce-site
- Repository: https://github.com/yogndrr/mern-ecommerce-site

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express.js, React, Node.js) ecommerce application named ShopCart.
- Purpose:
- Customers browse products, search/filter, add to cart, checkout, leave reviews.
- Sellers register, add/manage products, view orders and sales metrics.

##### File structure
- Top-level folders:
- backend/ – Express API.
· index.js: app entry point.
· controllers/: customerController, productController, orderController, sellerController (MVC grouping).
· models/: Mongoose schemas for Customer, Product, Order, Seller.
· routes/route.js: defines REST endpoints.
· middleware/authMiddleware.js: JWT auth enforcement.
· utils/token.js: JWT generation.
- frontend/ – React single-page app.
· public/: static HTML, manifest, robots.txt.
· src/:
> App.jsx, index.js: React entry.
> components/: reusable UI components (TableTemplate, Popup, etc.).
> pages/: screens organized by role (authentication, home, customer/, seller/).
> redux/: Redux Toolkit store, slices, async handlers.
> utils/: helper functions, styles, chart data.
- Patterns:
- Backend uses MVC + REST API + JWT for auth.
- Frontend uses component-based architecture + Redux for state management + React-ApexCharts for data viz.

##### README for additional insights
- Confirms MERN stack, key features, tech choices (Material UI, Styled Components, JWT).
- Deployment: backend on Render, frontend on Vercel.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Side
    subgraph "Client (Browser)" 
        direction TB
        Browser["User Browser"]:::client
        ReactApp["React Frontend Application"]:::client
        ReduxStore["Redux Store"]:::client
        AuthModule["Authentication Module"]:::client
        CustomerPages["Customer Pages"]:::client
        CustomerComponents["Customer Components"]:::client
        SellerPages["Seller Pages"]:::client
        SellerComponents["Seller Components"]:::client
        SharedComponents["Shared UI Components"]:::client
        FrontendUtils["Frontend Utilities & Styles"]:::client
        PublicAssets["Public Assets & HTML"]:::client
    end

    %% Server Side
    subgraph "Server (Render Deployment)"
        direction TB
        ExpressAPI["Express.js Backend API"]:::server
        Routes["REST Routes Definition"]:::server
        Controllers["Controllers (MVC)"]:::server
        Models["Mongoose Models"]:::server
        AuthMiddleware["JWT Authentication Middleware"]:::auth
        TokenService["JWT Token Service"]:::auth
        DB[(MongoDB Database)]:::db
    end

    %% Deployments
    Vercel["Vercel (Frontend)"]:::deployment
    Render["Render (Backend)"]:::deployment

    %% Client to Server Flow
    Browser --> ReactApp
    ReactApp --> ReduxStore
    ReduxStore --> ExpressAPI
    ReactApp --> AuthModule
    ReactApp --> CustomerPages
    ReactApp --> SellerPages
    ReactApp --> SharedComponents
    ReactApp --> PublicAssets
    ReactApp --> FrontendUtils

    %% Server Flow
    ExpressAPI --> Routes
    Routes --> Controllers
    Controllers --> Models
    Models --> DB
    Routes --> AuthMiddleware
    AuthMiddleware --> TokenService
    TokenService -.->|Issues/Verifies JWT| AuthMiddleware

    %% Data Viz
    SellerPages --> SellerComponents

    %% Deploy arrows
    ReactApp --> Vercel
    ExpressAPI --> Render

    %% Click Events
    click ReactApp "https://github.com/yogndrr/mern-ecommerce-site/tree/main/frontend/src"
    click ReduxStore "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/redux/store.js"
    click AuthModule "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/pages/AuthenticationPage.jsx"
    click CustomerPages "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/pages/customer/pages/CheckoutAftermath.jsx"
    click CustomerComponents "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/pages/customer/components/Cart.jsx"
    click SellerPages "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/pages/seller/pages/AddProduct.jsx"
    click SellerComponents "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/pages/seller/components/SalesChart.jsx"
    click SharedComponents "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/components/AlertDialogSlide.jsx"
    click FrontendUtils "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/src/utils/helperFunctions.js"
    click PublicAssets "https://github.com/yogndrr/mern-ecommerce-site/blob/main/frontend/public/index.html"
    click ExpressAPI "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/index.js"
    click Routes "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/routes/route.js"
    click Controllers "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/controllers/customerController.js"
    click Models "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/models/customerSchema.js"
    click AuthMiddleware "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/middleware/authMiddleware.js"
    click TokenService "https://github.com/yogndrr/mern-ecommerce-site/blob/main/backend/utils/token.js"

    %% Styles
    classDef client fill:#d0e6ff,stroke:#036,stroke-width:1px
    classDef server fill:#d0f0d0,stroke:#063,stroke-width:1px
    classDef db fill:#ffe0e0,stroke:#900,stroke-width:1px
    classDef auth fill:#fff3cd,stroke:#cca,stroke-width:1px
    classDef deployment fill:#f0f0f0,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5
```
