# shahriarsajeeb/eshop-tutorial architecture

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

- Interactive diagram: https://gitdiagram.com/shahriarsajeeb/eshop-tutorial
- Repository: https://github.com/shahriarsajeeb/eshop-tutorial

## Overview

##### Project type and purpose
- This is a full-stack e-commerce/marketplace platform with three key user‐facing portals (customer, shop owner, admin) plus real-time chat.
- Frontend: React + Redux SPA (UI components, routing, state management).
- Backend: Node.js/Express REST API (controllers, models, middleware) + MongoDB.
- Real-time service: Socket.IO server for messaging.

##### File structure
- Top-level directories:
- backend/ – REST API (app.js, server.js, controllers, models, middleware, utils)
- frontend/ – React application (public/, src/ with components, pages, redux, routes)
- socket/ – separate Node.js Socket.IO server for real‐time messaging
- Database config (.env, Database.js), authentication middleware (auth.js, jwtToken.js), email utility (sendMail.js), payment controllers (payment.js).
- Frontend uses React Router, protected routes, Redux actions/reducers, Tailwind config.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client-side (React SPA)
    subgraph "Client-side (React SPA)"
        direction TB
        Index["index.js"]:::frontend
        App["App.js"]:::frontend
        Components["components/"]:::frontend
        Pages["pages/"]:::frontend
        RoutesDir["routes"]:::frontend
        RoutesFile["Routes.js"]:::frontend
        ProtectedRoute["ProtectedRoute.js"]:::frontend
        AdminRoute["AdminRoutes.js"]:::frontend
        SellerRoute["SellerProtectedRoute.js"]:::frontend
        ReduxDir["redux"]:::frontend
        Store["store.js"]:::frontend
        Actions["actions/"]:::frontend
        Reducers["reducers/"]:::frontend
        Styles["styles.js"]:::frontend
        Assets["Assests/"]:::frontend
        Tailwind["tailwind.config.js"]:::frontend

        Index --> App
        App --> Components
        App --> Pages
        App --> RoutesDir
        RoutesDir --> RoutesFile
        RoutesDir --> ProtectedRoute
        RoutesDir --> AdminRoute
        RoutesDir --> SellerRoute
        App --> ReduxDir
        ReduxDir --> Store
        ReduxDir --> Actions
        ReduxDir --> Reducers
        App --> Styles
        Styles --> Assets
        Styles --> Tailwind
    end

    %% Backend REST API
    subgraph "Backend REST API (Express)"
        direction TB
        ServerJS["server.js"]:::backend
        AppJS["app.js"]:::backend
        ConfigDB["Database.js"]:::backend
        Controllers["controller/"]:::backend
        Models["model/"]:::backend
        MiddlewareDir["middleware/"]:::backend
        UtilsDir["utils/"]:::backend
        PaymentController["payment.js"]:::backend

        ServerJS --> AppJS
        AppJS --> ConfigDB
        AppJS --> Controllers
        AppJS --> Models
        AppJS --> MiddlewareDir
        AppJS --> UtilsDir
        Controllers --> PaymentController
    end

    %% Socket.IO Server
    subgraph "Socket.IO Server"
        direction TB
        SocketIndex["index.js"]:::realtime
        SocketEnv[".env"]:::realtime

        SocketIndex --> SocketEnv
    end

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

    %% External Services
    subgraph "External Services"
        direction TB
        PaymentGateway[("Payment Gateway")]:::external
        EmailService[("Email Service")]:::external
    end

    %% Interactions
    Index -->|HTTP/HTTPS| ServerJS
    App -->|HTTP/HTTPS| ServerJS
    Index -.WebSocket.-> SocketIndex
    ServerJS -->|CRUD via Mongoose| MongoDB
    SocketIndex -->|Persist chat| MongoDB
    ServerJS -->|Process payments| PaymentGateway
    ServerJS -->|Send emails| EmailService

    %% Click Events
    click Index "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/index.js"
    click App "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/App.js"
    click Components "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/frontend/src/components/"
    click Pages "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/frontend/src/pages/"
    click RoutesFile "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/routes/Routes.js"
    click ProtectedRoute "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/routes/ProtectedRoute.js"
    click AdminRoute "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/routes/AdminRoutes.js"
    click SellerRoute "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/routes/SellerProtectedRoute.js"
    click Store "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/redux/store.js"
    click Actions "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/frontend/src/redux/actions/"
    click Reducers "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/frontend/src/redux/reducers/"
    click Styles "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/frontend/src/styles/styles.js"
    click Assets "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/frontend/src/Assests/"
    click Tailwind "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/tailwind.config.js"
    click ServerJS "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/backend/server.js"
    click AppJS "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/backend/app.js"
    click ConfigDB "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/backend/db/Database.js"
    click Controllers "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/backend/controller/"
    click Models "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/backend/model/"
    click MiddlewareDir "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/backend/middleware/"
    click UtilsDir "https://github.com/shahriarsajeeb/eshop-tutorial/tree/master/backend/utils/"
    click PaymentController "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/backend/controller/payment.js"
    click SocketIndex "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/socket/index.js"
    click SocketEnv "https://github.com/shahriarsajeeb/eshop-tutorial/blob/master/socket/.env"

    %% Styles
    classDef frontend fill:#E8F0FE,stroke:#2E5AAC,color:#2E5AAC
    classDef backend fill:#E6F4EA,stroke:#238636,color:#238636
    classDef realtime fill:#FFF4E5,stroke:#B66300,color:#B66300
    classDef database fill:#F0F0F0,stroke:#555555,color:#555555,shape:cylinder
    classDef external fill:#F8E8FE,stroke:#7A4FB3,color:#7A4FB3

    class MongoDB database
    class PaymentGateway,EmailService external
```
