# suhassalian27/e-commerce-website-using-reactjs-nodejs architecture

> Architecture diagram of the GitHub repository suhassalian27/e-commerce-website-using-reactjs-nodejs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/suhassalian27/e-commerce-website-using-reactjs-nodejs
- Repository: https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs

## Overview

##### Project Type and Purpose
- This is a full-stack e-commerce web application built on the MERN stack.
- Frontend: React + Redux; Backend: Node.js + Express; Database: MongoDB (via Mongoose); Authentication: JWT.

##### File Structure
- Top-level “frontend” and “backend” folders – clear separation of concerns.
- Frontend:
- public/ – static HTML/CSS (index.html, manifest, images)
- src/ – React components (Screens/ & reusable components), Redux (actions, reducers, store), serviceWorker
- Backend:
- models/ – Mongoose schemas (userModel, productModel)
- routes/ – Express routers (userRoute, productRoute)
- server.js – Express app entry point, middleware setup
- config/data.js & util.js – initial data injection, utility functions
- Root: .babelrc, package.json for build tooling; template/ – legacy/static demonstration files.

##### README for Additional Insights
- Uses React-Bootstrap for UI, Axios for HTTP
- RESTful API endpoints for products, users, orders
- Features: signup/signin (with JWT), admin product CRUD, cart workflow, order placement
- Dev & Deploy notes: local npm scripts, MongoDB prerequisite

##### Main Components
a. Client Layer (Browser)
- React App:
- Screens (Home, ProductDetail, Cart, Checkout, Admin)
- Components (Carousel, CheckoutSteps, Form controls)
- Redux Store (reducers for cart, user, products; actions invoking Axios)
b. API Layer (Express Server)
- Route Handlers (userRoute, productRoute)
- Middleware (bodyParser, JWT auth guard, error handlers)
- Controllers/Models (Mongoose interacts with MongoDB)
c. Data Layer
- MongoDB Database (collections: users, products, orders)
d. External Services (optional / future)
- Payment Gateway (Stripe placeholder)
- Image storage (local/public/images or cloud)
e. Deployment (optional)
- Node server hosted on Heroku/AWS; React hosted on Netlify or served statically.

##### Relationships & Data Flow
- Browser → React UI: user interacts with components
- React → Redux store: updates UI state (cart, user, products)
- Redux actions → Axios HTTP calls → Express routes
- Express route → Controller → Mongoose model → MongoDB
- MongoDB → Mongoose → Express → JSON response → React → Redux → UI
- JWT token passed in HTTP headers for protected routes

##### Architectural Patterns & Design Principles
- Frontend: Component-based design with unidirectional data flow (Redux)
- Backend: RESTful API, MVC-inspired separation (routes/controllers/models)
- Stateless authentication using JWT; middleware enforces RBAC (user vs. admin)
- Single source of truth for application state in Redux

##### Detailed Callouts
- Frontend static assets served from public/ or via build pipeline
- serviceWorker registration for PWA capabilities
- util.js for helper functions in backend
- data.js seed script – illustrate optional initialization process

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        direction TB
        Browser["Browser"]:::external
        Index["Index.js"]:::frontend
        App["App.js"]:::frontend
        subgraph "Screens"
            direction TB
            Home["HomeScreen.js"]:::frontend
            ProductDetail["ProductScreen.js"]:::frontend
            ProductsAdmin["ProductsScreen.js"]:::frontend
            Cart["CartScreen.js"]:::frontend
            Shipping["ShippingScreen.js"]:::frontend
            Payment["PaymentScreen.js"]:::frontend
            PlaceOrder["PlaceOrderScreen.js"]:::frontend
            SignIn["SigninScreen.js"]:::frontend
            Register["RegisterScreen.js"]:::frontend
        end
        subgraph "Components"
            direction TB
            Carousel["Corousel.js"]:::frontend
            CheckoutSteps["CheckoutSteps.js"]:::frontend
        end
        Store["store.js"]:::frontend
        subgraph "Redux"
            direction TB
            ProdActions["productActions.js"]:::frontend
            CartActions["CartAction.js"]:::frontend
            UserActions["userAction.js"]:::frontend
            ProdReducers["productReducers.js"]:::frontend
            CartReducers["cartReducers.js"]:::frontend
            UserReducer["userReducer.js"]:::frontend
            ProdConstants["productConstants.js"]:::frontend
            CartConstants["cartConstants.js"]:::frontend
            UserConstants["userConstants.js"]:::frontend
        end
        SW["serviceWorker.js"]:::frontend
        Public["public/index.html\nimages/"]:::frontend
    end

    subgraph "Server Layer"
        direction TB
        Server["server.js"]:::backend
        Config["config.js\ndata.js\nutil.js"]:::backend
        subgraph "Routes"
            direction TB
            ProdRoute["productRoute.js"]:::backend
            UserRoute["userRoute.js"]:::backend
        end
        subgraph "Models"
            direction TB
            ProductModel["productModel.js"]:::backend
            UserModel["usermodel.js"]:::backend
        end
    end

    DB["MongoDB"]:::db
    Payment["Payment Gateway"]:::external
    Storage["Image Storage"]:::external

    %% Client Layer Connections
    Browser --> Index --> App
    App --> Home
    App --> ProductDetail
    App --> ProductsAdmin
    App --> Cart
    App --> Shipping
    App --> Payment
    App --> PlaceOrder
    App --> SignIn
    App --> Register
    App --> Carousel
    App --> CheckoutSteps
    App --> Store
    Store --> ProdActions
    Store --> CartActions
    Store --> UserActions

    %% Client to Server
    ProdActions -->|"HTTP/JSON"| Server
    CartActions -->|"HTTP/JSON"| Server
    UserActions -->|"HTTP/JSON"| Server

    %% Server Layer Connections
    Server --> Config
    Server --> ProdRoute
    Server --> UserRoute
    ProdRoute --> ProductModel
    UserRoute --> UserModel
    ProductModel --> DB
    UserModel --> DB

    %% External Services
    Server --> Payment
    App --> Storage

    %% Click Events
    click Index "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/index.js"
    click App "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/App.js"
    click Home "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/HomeScreen.js"
    click ProductDetail "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/ProductScreen.js"
    click ProductsAdmin "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/ProductsScreen.js"
    click Cart "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/CartScreen.js"
    click Shipping "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/ShippingScreen.js"
    click Payment "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/PaymentScreen.js"
    click PlaceOrder "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/PlaceOrderScreen.js"
    click SignIn "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/SigninScreen.js"
    click Register "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/Screens/RegisterScreen.js"
    click Carousel "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/components/Corousel.js"
    click CheckoutSteps "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/components/CheckoutSteps.js"
    click Store "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/store.js"
    click ProdActions "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/actions/productActions.js"
    click CartActions "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/actions/CartAction.js"
    click UserActions "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/actions/userAction.js"
    click ProdReducers "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/reducers/productReducers.js"
    click CartReducers "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/reducers/cartReducers.js"
    click UserReducer "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/reducers/userReducer.js"
    click ProdConstants "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/constants/productConstants.js"
    click CartConstants "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/constants/cartConstants.js"
    click UserConstants "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/constants/userConstants.js"
    click SW "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/src/serviceWorker.js"
    click Public "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/frontend/public/index.html"
    click Server "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/server.js"
    click Config "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/config.js"
    click Config "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/data.js"
    click Config "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/util.js"
    click ProdRoute "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/routes/productRoute.js"
    click UserRoute "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/routes/userRoute.js"
    click ProductModel "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/models/productModel.js"
    click UserModel "https://github.com/suhassalian27/e-commerce-website-using-reactjs-nodejs/blob/master/backend/models/usermodel.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#000;
    classDef backend fill:#D5F5E3,stroke:#27AE60,color:#000;
    classDef db fill:#FCF3CF,stroke:#F1C40F,color:#000;
    classDef external stroke-dasharray: 5 5,fill:#FADBD8,stroke:#E74C3C,color:#000;
```
