# abhishek9525-max/e-commerce-megakart architecture

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

- Interactive diagram: https://gitdiagram.com/abhishek9525-max/e-commerce-megakart
- Repository: https://github.com/abhishek9525-max/e-commerce-megakart

## Overview

##### Project type and purpose
- This is a full-stack e-commerce web application built on the MERN stack (MongoDB, Express.js, React.js, Node.js).
- The goal is to provide a user-friendly shopping platform with features like product browsing, shopping cart, checkout, order management, and an admin dashboard.

##### File structure
- Top-level directories:
- backend – contains server-side code (Express.js, API routes, database models, middleware)
- frontend – contains client-side React app (components, pages, Redux slices, styling)
- backend/config holds database connection logic (db.js).
- backend/models follows an MVC-style schema definition (Product, User, Order, Cart, Checkout, Subscriber).
- backend/routes implements RESTful endpoints for products, users, cart, orders, checkout, admin operations, uploads, subscriptions.
- backend/middleware contains authentication logic (authMiddleware.js).
- backend/server.js boots the Express server and applies middleware.
- frontend/src/components organizes reusable UI bits (Common, Layout, Products, Cart, Admin).
- frontend/src/pages defines routeable pages (Home, Login, Register, Profile, MyOrders, OrderDetails, AdminHome).
- frontend/src/redux sets up global state management with Redux slices and a store.
- Configuration files: Vite (vite.config.js), Tailwind (tailwind.config.js), ESLint, PostCSS.

##### README for additional insights
- Confirms the tech stack: React, Tailwind CSS, Node/Express, MongoDB.
- Features: authentication, product catalog, cart & checkout, order management, RESTful API.
- Deployment target: cloud platforms (Vercel configs are present in both backend and frontend).

a. Main components
- Client (React.js + Redux + Tailwind CSS)
- API layer (Express.js server)
- Business logic & middleware (auth, error handling)
- Data layer (MongoDB database, Mongoose models)
- External services (e.g., PayPal for payment, cloud storage for uploads)
b. Relationships & interactions
- The browser loads the React app (served from Vercel).
- React components dispatch actions to Redux; Redux makes HTTP requests to the Express API.
- Express routes authenticate requests via authMiddleware, invoke controllers that read/write MongoDB via Mongoose.
- Payment requests forward to PayPal’s API; file uploads forwarded to storage service via uploadRoutes.
c. Architectural patterns & design principles
- MVC-style separation on the backend (models, routes/controllers, middleware).
- Unidirectional data flow in the frontend (React → Redux → API → Redux store → React).
- Layered architecture: Client UI → API layer → Data layer.
- Component hierarchy in React: Shared components, page-level components, admin vs. public.
d. Key technologies
- Frontend: React, Redux, Vite, Tailwind CSS
- Backend: Node.js, Express.js, Mongoose (MongoDB)
- Database: MongoDB Atlas or self-hosted instance
- Deployment: Vercel for frontend, Vercel (or similar) for backend
- External services: PayPal, file storage (e.g., AWS S3)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["Browser"]:::external
        ReactApp["React App"]:::frontend
        ReduxStore["Redux Store"]:::frontend
        subgraph "Redux Slices"
            direction TB
            authSlice["authSlice"]:::frontend
            productSlice["productSlice"]:::frontend
            cartSlice["cartSlice"]:::frontend
            checkoutSlice["checkoutSlice"]:::frontend
            orderSlice["orderSlice"]:::frontend
            adminSlice["adminSlice"]:::frontend
            adminProductSlice["adminProductSlice"]:::frontend
            adminOrderSlice["adminOrderSlice"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            Common["Common Components"]:::frontend
            Layout["Layout Components"]:::frontend
            Products["Product Components"]:::frontend
            CartComp["Cart Components"]:::frontend
            AdminComp["Admin Components"]:::frontend
        end
        subgraph "Pages"
            direction TB
            Home["Home & Collection"]:::frontend
            AuthPages["Login/Register"]:::frontend
            ProfilePages["Profile & Orders"]:::frontend
            AdminPage["Admin Dashboard"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        ExpressServer["Express Server"]:::backend
        AuthMW["Auth Middleware"]:::backend
        subgraph "API Routes"
            direction TB
            ProductRoutes["Product Routes"]:::backend
            UserRoutes["User Routes"]:::backend
            CartRoutes["Cart Routes"]:::backend
            OrderRoutes["Order Routes"]:::backend
            CheckoutRoutes["Checkout Routes"]:::backend
            AdminRoutes["Admin Routes"]:::backend
            SubscribeRoute["Subscribe Route"]:::backend
            UploadRoutes["Upload Routes"]:::backend
        end
        subgraph "Data Layer"
            direction TB
            Models["Mongoose Models"]:::backend
            DBConfig["DB Config"]:::backend
            Seeder["DB Seeder"]:::backend
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MongoDB["MongoDB"]:::db
        PayPal["PayPal API"]:::external
        Storage["File Storage"]:::external
    end

    %% Deployments
    subgraph "Deployment Configs"
        direction TB
        FE_Vercel["Frontend Vercel Config"]:::backend
        BE_Vercel["Backend Vercel Config"]:::backend
    end

    %% Connections
    Browser -->|"loads"| ReactApp
    ReactApp -->|"uses"| ReduxStore
    ReactApp -->|"renders"| UIComponents
    ReactApp -->|"navigates"| Pages
    ReduxStore -->|"dispatches API calls"| ExpressServer
    ExpressServer -->|"validates"| AuthMW
    AuthMW -->|"routes to controllers"| ProductRoutes
    AuthMW --> UserRoutes
    AuthMW --> CartRoutes
    AuthMW --> OrderRoutes
    AuthMW --> CheckoutRoutes
    AuthMW --> AdminRoutes
    AuthMW --> SubscribeRoute
    AuthMW --> UploadRoutes
    ProductRoutes -->|"reads/writes"| Models
    UserRoutes --> Models
    CartRoutes --> Models
    OrderRoutes --> Models
    CheckoutRoutes --> Models
    AdminRoutes --> Models
    SubscribeRoute --> Models
    Seeder --> Models
    Models -->|“persist data”| MongoDB
    UploadRoutes -->|"uploads"| Storage
    CheckoutRoutes -->|"process payment"| PayPal

    %% Click Events
    click ReactApp "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/App.jsx"
    click ReduxStore "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/store.js"
    click authSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/authSlice.js"
    click productSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/productSlice.js"
    click cartSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/cartSlice.js"
    click checkoutSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/checkoutSlice.js"
    click orderSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/orderSlice.js"
    click adminSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/adminSlice.js"
    click adminProductSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/adminProductSlice.js"
    click adminOrderSlice "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/redux/slices/adminOrderSlice.js"
    click Common "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/frontend/src/components/Common"
    click Layout "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/frontend/src/components/Layout"
    click Products "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/frontend/src/components/Products"
    click CartComp "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/frontend/src/components/Cart"
    click AdminComp "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/frontend/src/components/Admin"
    click Home "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/pages/Home.jsx"
    click AuthPages "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/pages/Login.jsx"
    click ProfilePages "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/pages/Profile.jsx"
    click AdminPage "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/src/pages/AdminHomePage.jsx"
    click ExpressServer "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/server.js"
    click AuthMW "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/middleware/authMiddleware.js"
    click ProductRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/productRoutes.js"
    click UserRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/userRoutes.js"
    click CartRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/cartRoutes.js"
    click OrderRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/orderRoutes.js"
    click CheckoutRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/checkoutRoutes.js"
    click AdminRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/adminRoutes.js"
    click SubscribeRoute "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/subscribeRoute.js"
    click UploadRoutes "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/routes/uploadRoutes.js"
    click Models "https://github.com/abhishek9525-max/e-commerce-megakart/tree/main/backend/models"
    click DBConfig "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/config/db.js"
    click Seeder "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/seeder.js"
    click FE_Vercel "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/frontend/vercel.json"
    click BE_Vercel "https://github.com/abhishek9525-max/e-commerce-megakart/blob/main/backend/vercel.json"

    %% Styles
    classDef frontend fill:#E8F0FF,stroke:#1E3A8A,stroke-width:1px
    classDef backend fill:#F0F5F9,stroke:#334155,stroke-width:1px
    classDef db fill:#D1FAE5,stroke:#065F46,stroke-width:1px
    classDef external fill:#FEF3C7,stroke:#92400E,stroke-width:1px
```
