# rishinion/e-commerce-virtual-bazar architecture

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

- Interactive diagram: https://gitdiagram.com/rishinion/e-commerce-virtual-bazar
- Repository: https://github.com/rishinion/e-commerce-virtual-bazar

## Overview

##### Project Type and Purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) e-commerce web application with two user roles (“Admin” and “Shopper”) and an integrated dynamic chatbot for order assistance and FAQs.

##### File Structure
- Top-level “client” folder contains a Vite-powered React app (App.jsx, Chatbot.jsx) organized into:
- pages/ (shopping, admin, auth, not-found)
- components/ (admin-view, shopping-view, auth, common, ui)
- store/ (Redux slices for auth, admin, shop)
- lib, config, assets
- Top-level “server” folder contains an Express.js REST API:
- routes/ (auth, shop, admin, common, chatbot)
- controllers/ (business logic for each route)
- models/ (Mongoose schemas)
- helpers/ (cloudinary, PayPal integrations, chatbot engine)
- chatbot.js (chatbot server logic)

##### README Insights
- Features: user registration/login (JWT + CORS), product management, cart & orders, payment via PayPal, Cloudinary image uploads, dynamic chatbot.
- Stack: React, Node.js/Express, MongoDB, REST API, Redux, Tailwind/CSS modules.

a. Main Components
- User Interface (React SPA)
- API Layer (Express Server) with sub-modules:
- Auth Service (JWT issuance, validation)
- Shop Service (products, cart, orders, reviews, search)
- Admin Service (product & order administration)
- Common Service (features, FAQs)
- Chatbot Service (chatbot.js + controllers/helpers)
- Database (MongoDB Atlas)
- External Services: Cloudinary (image hosting), PayPal (payments), Optional Chatbot NLP provider (if any)

b. Relationships & Data Flows
- Browser → React Components → Redux Actions → REST Calls → Express API
- Express API Routes → Controllers → Mongoose Models → MongoDB
- Controllers call Helpers → communicate with Cloudinary/PayPal & return results
- Chatbot widget in React → WebSocket or HTTP → Chatbot Service → logic & external NLP → replies

c. Architectural Patterns & Principles
- Layered Architecture (Presentation → API/Service → Persistence)
- Modular REST Micro-services within one Node process (logical separation by routes/controllers)
- State Management in client via Redux slices (auth, shop, admin)
- Separation of Concerns: image and payment logic in helpers, domain logic in controllers

d. Key Technologies
- React (Vite), Redux Toolkit, Tailwind CSS
- Node.js, Express.js, Mongoose
- JWT, CORS for security
- MongoDB, Cloudinary, PayPal

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        subgraph "UI Layer"
            App["React SPA"]:::client
            Chatbot["Chatbot Widget"]:::client
            main["React Entry Point"]:::client
        end
        Config["Client Config"]:::client
        Utils["Client Utility Library"]:::client
        subgraph "Pages"
            Home["Home Page"]:::client
            Listing["Listing Page"]:::client
            ProductDetails["Product Details Page"]:::client
            Checkout["Checkout Page"]:::client
            PayPalReturn["PayPal Return Page"]:::client
            PaymentSuccess["Payment Success Page"]:::client
            ReturnSuccess["Return Success Page"]:::client
            Search["Search Page"]:::client
            Account["Account Page"]:::client
        end
        subgraph "Admin Pages"
            Dashboard["Admin Dashboard"]:::client
            AdminProducts["Products Management"]:::client
            AdminOrders["Orders Management"]:::client
            FeaturesMgmt["Features Management"]:::client
            CustomerCare["Customer Care Support"]:::client
        end
        subgraph "Auth Pages"
            Login["Login Page"]:::client
            Register["Register Page"]:::client
            UnAuth["Unauthenticated Page"]:::client
        end
        subgraph "Components"
            CheckAuth["Authentication Guard"]:::client
            FormElements["Form Elements"]:::client
            UIPrimitives["UI Primitives"]:::client
        end
        subgraph "Redux Store"
            AuthSlice["Auth Slice"]:::client
            CommonSlice["Common Slice"]:::client
            ShopProducts["Shop Products Slice"]:::client
            ShopCart["Shop Cart Slice"]:::client
            ShopOrder["Shop Order Slice"]:::client
            ShopAddress["Shop Address Slice"]:::client
            ShopReview["Shop Review Slice"]:::client
            ShopSearch["Shop Search Slice"]:::client
            AdminProdSlice["Admin Products Slice"]:::client
            AdminOrderSlice["Admin Order Slice"]:::client
            StoreSetup["Store Setup"]:::client
        end
    end

    %% Relationships in Client
    App -->|renders| Home
    App -->|renders| Dashboard
    Home --> Listing
    Listing --> ProductDetails
    ProductDetails --> Checkout
    Checkout --> PayPalReturn
    PayPalReturn --> PaymentSuccess
    PaymentSuccess --> ReturnSuccess
    Home --> Search
    Home --> Account
    Dashboard --> AdminProducts
    Dashboard --> AdminOrders
    Dashboard --> FeaturesMgmt
    Dashboard --> CustomerCare
    App --> Chatbot
    App --> CheckAuth
    App --> FormElements
    App --> UIPrimitives
    App --> Config
    App --> Utils
    App --> main
    App -->|dispatch| StoreSetup
    StoreSetup --> AuthSlice
    StoreSetup --> CommonSlice
    StoreSetup --> ShopProducts
    StoreSetup --> ShopCart
    StoreSetup --> ShopOrder
    StoreSetup --> ShopAddress
    StoreSetup --> ShopReview
    StoreSetup --> ShopSearch
    StoreSetup --> AdminProdSlice
    StoreSetup --> AdminOrderSlice

    %% Client to Server
    App -->|"API Calls (HTTP/HTTPS)"| ServerEntry
    Chatbot -->|"Chat via WS/HTTP"| ChatbotRoutes

    %% Server Tier
    subgraph "Server Tier"
        ServerEntry["Express API (server.js)"]:::api
        subgraph "Auth Service"
            AuthRoutes["Auth Routes"]:::api
            AuthController["Auth Controller"]:::api
            UserModel["User Model"]:::persistence
        end
        subgraph "Shop Service"
            ShopRoutes["Shop Routes"]:::api
            ShopControllers["Shop Controllers"]:::api
            ProductModel["Product Model"]:::persistence
            CartModel["Cart Model"]:::persistence
            OrderModel["Order Model"]:::persistence
            ReviewModel["Review Model"]:::persistence
            AddressModel["Address Model"]:::persistence
        end
        subgraph "Admin Service"
            AdminRoutes["Admin Routes"]:::api
            AdminProductsController["Products Controller"]:::api
            AdminOrderController["Order Controller"]:::api
        end
        subgraph "Common Service"
            CommonRoutes["Feature Routes"]:::api
            FeatureController["Feature Controller"]:::api
            FeatureModel["Feature Model"]:::persistence
        end
        subgraph "Chatbot Service"
            ChatbotRoutes["Chatbot Routes"]:::api
            ChatbotLogic["Chatbot Logic"]:::api
        end
        subgraph "Helpers"
            Cloudinary["Cloudinary Helper"]:::external
            PayPalHelper["PayPal Helper"]:::external
        end
    end

    %% Server Relationships
    ServerEntry --> AuthRoutes
    AuthRoutes --> AuthController
    AuthController --> UserModel
    ServerEntry --> ShopRoutes
    ShopRoutes --> ShopControllers
    ShopControllers --> ProductModel
    ShopControllers --> CartModel
    ShopControllers --> OrderModel
    ShopControllers --> ReviewModel
    ShopControllers --> AddressModel
    ServerEntry --> AdminRoutes
    AdminRoutes --> AdminProductsController
    AdminRoutes --> AdminOrderController
    ServerEntry --> CommonRoutes
    CommonRoutes --> FeatureController
    FeatureController --> FeatureModel
    ServerEntry --> ChatbotRoutes
    ChatbotRoutes --> ChatbotLogic
    ChatbotLogic -->|uses| Cloudinary
    ChatbotLogic -->|uses| PayPalHelper

    %% Database & External
    ServerEntry -->|connects| MongoDB["MongoDB Atlas"]:::db
    AuthController --> MongoDB
    ShopControllers --> MongoDB
    AdminProductsController --> MongoDB
    FeatureController --> MongoDB
    ChatbotLogic -->|integrates| NLPProvider["NLP Provider"]:::external
    PayPalHelper --> PayPalExt["PayPal"]:::external
    Cloudinary --> CloudinaryExt["Cloudinary"]:::external

    %% Click Events
    click App "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/client/src/App.jsx"
    click Chatbot "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/client/src/Chatbot.jsx"
    click main "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/client/src/main.jsx"
    click Config "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/client/src/config/index.js"
    click Utils "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/client/src/lib/utils.js"
    click ServerEntry "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/server.js"
    click AuthRoutes "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/routes/auth/auth-routes.js"
    click AuthController "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/controllers/auth/auth-controller.js"
    click UserModel "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/models/User.js"
    click ChatbotRoutes "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/routes/chatbot-routes.js"
    click ChatbotLogic "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/chatbot.js"
    click Cloudinary "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/helpers/cloudinary.js"
    click PayPalHelper "https://github.com/rishinion/e-commerce-virtual-bazar/blob/main/server/helpers/paypal.js"

    %% Styles
    classDef client fill:#DCEEFB,stroke:#0366D6,color:#0366D6
    classDef api fill:#ECFDF5,stroke:#10B981,color:#065F46
    classDef persistence fill:#FFFAEB,stroke:#F59E0B,color:#92400E
    classDef db fill:#FFF7ED,stroke:#F97316,color:#9A3412
    classDef external fill:#F0F9FF,stroke:#3B82F6,color:#1E3A8A
```
