# isamitprajapati/blinkit-clone-full-stack-ecommerce architecture

> Architecture diagram of the GitHub repository isamitprajapati/blinkit-clone-full-stack-ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/isamitprajapati/blinkit-clone-full-stack-ecommerce
- Repository: https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce

## Overview

##### Project Type and Purpose
- The project is a full-stack e-commerce application built with MongoDB, Express, React, and Node.js.
- Its primary purpose is to offer an online shopping experience with features such as product uploads, an admin panel for managing products, categories, subcategories, secure user authentication, and additional functionalities like OTP email verification, password recovery, and integration with external services like Stripe.

##### And Identify Main Components from the File Structure
- Client (Frontend)
- Located under the “client” directory.
- Contains a React-based single-page application (SPA) using Vite as the build tool.
- Organized into views/pages (e.g., Login, Home, Product, Cart, Checkout, Admin pages) and reusable UI components (e.g., Header, Footer, ProductCardAdmin).
- State management through Redux slices (e.g., cartProduct.js, productSlice.js) and a global provider for theme or authentication.
- Routing is handled in the “route” directory, ensuring navigational flow among different views.

- Server (Backend)
- Located under the “server” directory.
- Implements REST API endpoints using Express.
- Follows an MVC-like pattern with directories such as:
▪ controllers: Business logic for products, orders, addresses, users, categories, and uploads.
▪ models: Schema definitions for various entities (products, users, orders, etc.).
▪ routes: Endpoint definitions that tie controllers to URL paths.
▪ middleware: Security layers including authentication and admin-checks.
▪ config: Setup files for database connection, email, Stripe integration, etc.
▪ utils: Supplemental functions to generate tokens, manage image uploads (e.g., via Cloudinary), and templates for email verification and forgot-password scenarios.

- External Services and Integrations:
- Authentication tokens: The system uses access and refresh tokens for secure session handling.
- Payment/Stripe: Integration for payment processing.
- Email Service: For OTP-based verification and password recovery.
- Cloud-based Image Uploads: Likely Cloudinary integration for asset handling.

a. Main Blocks:
▪ Inside, denote the UI layers, including the pages, state management (Redux), routing, and providers.
▪ Inside, further subdivide into:
- Route layer: Manages endpoint mappings.
- Controllers: Implements business logic.
- Middleware: Authentication, admin permissions, file uploads.
- Models: MongoDB schemas for database interactions.
- Utilities and Configurations: Includes token generation, external integrations (Stripe, SendEmail, Cloudinary, etc.).
- Database & External Services:
▪ Represent MongoDB as the primary datastore.

b. Relationships & Data Flow:
- Within the Server, show flows from the route layer to controllers and model interactions with the database.
- Middleware layers intercepting requests to enforce security (authentication and admin checks).

c. Architectural Patterns:
- For the Backend, clearly denote an MVC-like architecture:
▪ “Models” for data representation.
▪ “Controllers” for business logic.
▪ “Routes” to receive client requests.
- For the Client Application, showcase separation of UI components, state management, and routing.
- Mention integration of Redux for state management and the use of Vite for modern build processes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        R["React Client"]:::frontend
        CP["Client Pages/Views"]:::frontend
        UC["UI Components"]:::frontend
        RT["Routing"]:::frontend
        SM["State Management"]:::frontend
        GP["Global Provider"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        ES["Express Server"]:::backend
        subgraph "Server Modules"
            RTB["Routes"]:::backend
            CT["Controllers"]:::backend
            MD["Middleware"]:::backend
            MDS["Models"]:::backend
            UT["Utility Functions"]:::backend
            CFG["Server Configuration"]:::backend
        end
    end

    %% Data & External Services
    subgraph "Data & External Services"
        DB["MongoDB"]:::db
        ST["Stripe Payment"]:::external
        EM["Email Service"]:::external
        CL["Cloudinary"]:::external
    end

    %% Connections between Frontend and Backend
    R -->|"API_Request"| RTB

    %% Backend internal flows
    RTB -->|"calls"| CT
    CT -->|"db_ops"| MDS
    MDS -->|"CRUD"| DB
    RTB -->|"uses"| MD
    UT -->|"integrates"| CFG
    CFG -->|"Stripe"| ST
    CFG -->|"Email"| EM
    UT -->|"ImageUpload"| CL

    %% Grouping associations within layers
    CP --- R
    UC --- R
    RT --- R
    SM --- R
    GP --- R

    RTB --- ES
    CT --- ES
    MD --- ES
    MDS --- ES
    UT --- ES
    CFG --- ES

    %% Styles
    classDef frontend fill:#DDEEFF,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFD2A6,stroke:#333,stroke-width:2px;
    classDef external fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef db fill:#C3FDB8,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend Components
    click R "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/client/"
    click CP "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/client/src/pages/"
    click UC "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/client/src/components/"
    click RT "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/client/src/route/"
    click SM "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/client/src/store/"
    click GP "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/blob/main/client/src/provider/GlobalProvider.jsx"

    %% Click Events for Backend Components
    click ES "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/"
    click RTB "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/route/"
    click CT "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/controllers/"
    click MD "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/middleware/"
    click MDS "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/models/"
    click CFG "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/config/"
    click UT "https://github.com/isamitprajapati/blinkit-clone-full-stack-ecommerce/tree/main/server/utils/"
```
