# ag2627/iconique architecture

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

- Interactive diagram: https://gitdiagram.com/ag2627/iconique
- Repository: https://github.com/ag2627/iconique

## Overview

##### Project type and purpose
- This is a full-stack e-commerce marketplace (“Iconique”) with a React-based frontend (Vite + JSX + Tailwind + Redux) and a Node/Express backend connected to MongoDB.
- Purpose: Enable sellers to list streetwear products (with images & stories) and buyers to browse, filter, purchase (including live auctions), review, wishlist, and pay via Razorpay.

##### File structure
- Top level:
- Backend/ – Express server implementation (index.js, package.json).
- src/ – React app (App.jsx, components/, redux/, service/api.js, utils/, context/).
- Config scripts: vite.config.js, tailwind.config.js, postcss.config.js, eslint.config.js.
- Backend substructure follows MVC + route organization:
- Database (db.js)
- Models (Mongoose schemas under Backend/Model)
- Controllers (business logic)
- Routes (grouped by feature: Address, Payment, Seller, etc.)
- Middleware (auth, input validation)
- Config (Cloudinary, Razorpay)
- Utils (JWT helper)
- Frontend:
- Components grouped by domain (Home, Details, Cart, Checkout, Profile, Seller, User, Orders, Payment)
- UI primitives under components/ui
- Redux slices in src/redux/store
- API wrapper in src/service/api.js
- Context/DataProvider for theme or shared state
- Utility scripts (load scripts, paytm, common utils)

##### README insights
- Describes core features: user auth, product listing, auctions, eco-badges, reviews, wishlist
- Lists tech stack: Node.js, MongoDB, React, Vite, Razorpay

##### Sketch a two-column canvas
- Left column: Frontend (React SPA)
- Right column: Backend & persistence
- External services along the right edge.

- UI Pages (Home, Details, Cart, Checkout, Profile, Seller Dashboard)
- State Management (Redux slices, Context)
- Service Layer (api.js, paymentServices)

- Routes (Address, Payment, Seller, Product, User, Wishlist, Order)
- Controllers (business logic)
- Models (Mongoose schemas)
- Middleware (auth, validation)
- Config modules (Cloudinary, Razorpay)

- From UI components → service layer → HTTP clients → Backend routes
- From controllers → models → MongoDB
- From controllers → Cloudinary & Razorpay & Email
- From Razorpay Webhooks → Backend Payment routes → Controllers

##### Data flows
- e.g. “POST /api/products” → ProductController → ProductModel.save()
- “GET /api/cart” → CartController → returns cart items

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Zone
    subgraph "Frontend (React SPA)"
        direction TB
        subgraph "UI Pages" 
            direction TB
            Home["Home Page"]:::frontend
            Details["Product Details Page"]:::frontend
            CartPg["Cart Page"]:::frontend
            CheckoutPg["Checkout Page"]:::frontend
            Profile["User Profile Page"]:::frontend
            SellerDash["Seller Dashboard Page"]:::frontend
            CommonUI["UI Primitives"]:::frontend
        end
        subgraph "State Management"
            direction TB
            ReduxStore["Redux Store"]:::state
            ProductSlice["Product Slice"]:::state
            CartSlice["Cart Slice"]:::state
            WishlistSlice["Wishlist Slice"]:::state
            DataProv["React Context Provider"]:::state
        end
        subgraph "Service Layer"
            direction TB
            APIWrapper["API Wrapper"]:::service
            PaymentServ["Payment Services"]:::service
            LoadScript["Load Script Utility"]:::service
        end
    end

    %% Server Zone
    subgraph "Backend (Express API)"
        direction TB
        ExpressAPI["API Gateway (index.js)"]:::backend
        subgraph "Routes"
            direction TB
            RouteLoader["Aggregated Route Loader"]:::backend
            AddressR["Address Routes"]:::backend
            PaymentR["Payment Routes"]:::backend
            ProductR["Product & Seller Routes"]:::backend
            OrderR["Order Routes"]:::backend
        end
        subgraph "Controllers"
            direction TB
            ProductC["Product Controller"]:::backend
            CartC["Cart Controller"]:::backend
            SellerOrderC["Seller Order Controller"]:::backend
            PaymentC["Payment Controller"]:::backend
            MailerC["Mailer (Email Service)"]:::backend
        end
        subgraph "Models"
            direction TB
            ProdM["Product Schema"]:::backend
            UserM["User Schema"]:::backend
            OrderM["Order Schema"]:::backend
            WishlistM["Wishlist Schema"]:::backend
            ReviewM["Review Schema"]:::backend
        end
        subgraph "Middleware"
            direction TB
            AuthMW["Authentication Middleware"]:::backend
            ValMW["Validation Middleware"]:::backend
        end
        subgraph "Config & Utils"
            direction TB
            DBConn["MongoDB Connection"]:::backend
            CloudConf["Cloudinary Config"]:::backend
            RazorConf["Razorpay Config"]:::backend
            JWTUtil["JWT Utility"]:::backend
        end
    end

    %% External Services
    MongoDB[(MongoDB)]:::db
    Cloudinary((Cloudinary)):::cloud
    Razorpay((Razorpay)):::cloud
    EmailSvc((Email Service)):::cloud

    %% Connections Frontend -> Backend
    Home -->|calls| APIWrapper
    Details -->|calls| APIWrapper
    CartPg -->|calls| APIWrapper
    CheckoutPg -->|calls| APIWrapper
    Profile -->|calls| APIWrapper
    SellerDash -->|calls| APIWrapper
    CommonUI -->|uses| APIWrapper

    %% State & Service interactions
    APIWrapper -->|dispatches to| ReduxStore
    ReduxStore -->|updates| ProductSlice
    ReduxStore -->|updates| CartSlice
    ReduxStore -->|updates| WishlistSlice
    DataProv -->|provides| ReduxStore
    PaymentServ -->|uses| LoadScript
    PaymentServ -->|integrates with| Razorpay

    %% Frontend to Backend HTTP
    APIWrapper -->|"REST/JSON over HTTPS"| ExpressAPI

    %% Backend internal flow
    ExpressAPI -->|load routes| RouteLoader
    RouteLoader --> AddressR
    RouteLoader --> PaymentR
    RouteLoader --> ProductR
    RouteLoader --> OrderR

    AddressR -->|invoke| ProductC
    PaymentR -->|invoke| PaymentC
    ProductR -->|invoke| ProductC
    ProductR -->|invoke| SellerOrderC
    OrderR -->|invoke| CartC

    ProductC -->|CRUD| ProdM
    CartC -->|CRUD| OrderM
    SellerOrderC -->|CRUD| OrderM
    PaymentC -->|process| Razorpay
    PaymentC -->|webhook| ExpressAPI
    MailerC -->|send| EmailSvc

    %% DB connections
    ProdM -->|uses| DBConn
    UserM -->|uses| DBConn
    OrderM -->|uses| DBConn
    WishlistM -->|uses| DBConn
    ReviewM -->|uses| DBConn

    %% Cloudinary usage
    ProductC -->|upload/download| Cloudinary

    %% Middleware usage
    AddressR --> AuthMW
    PaymentR --> AuthMW
    ProductR --> AuthMW
    OrderR --> AuthMW
    RouteLoader --> ValMW

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef state fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef service fill:#E0FFFF,stroke:#333,stroke-width:1px
    classDef backend fill:#CCFFCC,stroke:#333,stroke-width:1px
    classDef db fill:#DDDDDD,stroke:#333,stroke-width:1px
    classDef cloud fill:#F0F0F0,stroke:#333,stroke-width:1px

    %% Click events
    click Home "https://github.com/ag2627/iconique/blob/main/src/components/Home/Home.jsx"
    click Details "https://github.com/ag2627/iconique/blob/main/src/components/Details/ProductDetail.jsx"
    click CartPg "https://github.com/ag2627/iconique/blob/main/src/components/cart/Cart.jsx"
    click CheckoutPg "https://github.com/ag2627/iconique/blob/main/src/components/checkout/checkout.jsx"
    click Profile "https://github.com/ag2627/iconique/blob/main/src/components/Profile/ViewProfile.jsx"
    click SellerDash "https://github.com/ag2627/iconique/blob/main/src/components/Seller/SellerDashboard.jsx"
    click CommonUI "https://github.com/ag2627/iconique/tree/main/src/components/ui/"
    click ReduxStore "https://github.com/ag2627/iconique/blob/main/src/redux/store/store.js"
    click ProductSlice "https://github.com/ag2627/iconique/blob/main/src/redux/store/product-slice/index.js"
    click CartSlice "https://github.com/ag2627/iconique/blob/main/src/redux/store/cart-slice/index.js"
    click WishlistSlice "https://github.com/ag2627/iconique/blob/main/src/redux/store/wishlist-slice/index.js"
    click DataProv "https://github.com/ag2627/iconique/blob/main/src/context/DataProvider.jsx"
    click APIWrapper "https://github.com/ag2627/iconique/blob/main/src/service/api.js"
    click PaymentServ "https://github.com/ag2627/iconique/blob/main/src/service/paymentServices.jsx"
    click LoadScript "https://github.com/ag2627/iconique/blob/main/src/utils/loadScript.js"
    click ExpressAPI "https://github.com/ag2627/iconique/blob/main/Backend/index.js"
    click AddressR "https://github.com/ag2627/iconique/blob/main/Backend/Routes/Address/address-routes.js"
    click PaymentR "https://github.com/ag2627/iconique/blob/main/Backend/Routes/Payment/payment-routes.js"
    click ProductR "https://github.com/ag2627/iconique/blob/main/Backend/Routes/Seller/product-routes.js"
    click OrderR "https://github.com/ag2627/iconique/blob/main/Backend/Routes/Seller/order-routes.js"
    click RouteLoader "https://github.com/ag2627/iconique/blob/main/Backend/Routes/route.js"
    click ProductC "https://github.com/ag2627/iconique/blob/main/Backend/controller/product-controller.js"
    click CartC "https://github.com/ag2627/iconique/blob/main/Backend/controller/cart-controller.js"
    click SellerOrderC "https://github.com/ag2627/iconique/blob/main/Backend/controller/SellerOrder-controller.js"
    click PaymentC "https://github.com/ag2627/iconique/blob/main/Backend/controller/payment-controller.js"
    click MailerC "https://github.com/ag2627/iconique/blob/main/Backend/controller/mailer.js"
    click ProdM "https://github.com/ag2627/iconique/blob/main/Backend/Model/product-schema.js"
    click UserM "https://github.com/ag2627/iconique/blob/main/Backend/Model/user_schema.js"
    click OrderM "https://github.com/ag2627/iconique/blob/main/Backend/Model/OrderSchema.js"
    click WishlistM "https://github.com/ag2627/iconique/blob/main/Backend/Model/Wishlist.js"
    click ReviewM "https://github.com/ag2627/iconique/blob/main/Backend/Model/ReviewSchema.js"
    click AuthMW "https://github.com/ag2627/iconique/blob/main/Backend/Middleware/check-auth.js"
    click ValMW "https://github.com/ag2627/iconique/blob/main/Backend/Middleware/validateInput.js"
    click DBConn "https://github.com/ag2627/iconique/blob/main/Backend/Database/db.js"
    click CloudConf "https://github.com/ag2627/iconique/blob/main/Backend/config/cloudinary.js"
    click RazorConf "https://github.com/ag2627/iconique/blob/main/Backend/config/razorpay-config.js"
    click JWTUtil "https://github.com/ag2627/iconique/blob/main/Backend/utils/jwt.js"
```
