# bhupesh227/e_commerce_multivendor architecture

> Architecture diagram of the GitHub repository bhupesh227/e_commerce_multivendor, 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/bhupesh227/e_commerce_multivendor
- Repository: https://github.com/bhupesh227/e_commerce_multivendor

## Overview

##### Project type and purpose
- This is an Nx-powered monorepo hosting a full-stack e-commerce platform.
- It uses a microservices architecture for the backend (auth, order, product, seller, recommendation, chatting, logger, kafka, etc.), a central API gateway, and three separate Next.js frontends (admin-ui, sellers-ui, users-ui).
- Shared code lives in Nx libs (components, middleware, error‐handler, utils, Prisma/Redis/Stripe wrappers).

##### File structure
- Top-level “apps” directory: each folder is either a microservice (Node + Express/Koa style) or a Next.js UI.
- “apps/api-gateway” routes client traffic to the various microservices.
- “apps/*-service” are domain services; they each expose a REST or WebSocket interface and use shared libs (Prisma for DB, Redis for caching/messaging, Kafka for event bus).
- “apps/*-ui” are Next.js apps with React components, hooks, and API routes for client side interactions.
- “packages” contains shared UI components, middleware, and utility libraries.
- Prisma schema is at the root, meaning a centralized database or multiple schemas managed from here.
- CI and build configs (.github/workflows, nx.json, tsconfig) confirm an Nx workspace orchestrating builds and dependency graph.

##### Extra insights from README
- Uses generated build targets per app, and Nx plugins for consistency.

##### Detail without over-splitting
- Microservice as its own component.
- Shared libraries only once under a “Shared Libraries” block.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UIs Layer
    subgraph "UIs" 
        direction TB
        AdminUI["Admin UI"]:::ui
        SellersUI["Sellers UI"]:::ui
        UsersUI["Users UI"]:::ui
    end

    %% API Gateway Layer
    subgraph "API Gateway" 
        direction TB
        APIGateway["API Gateway"]:::gateway
    end

    %% Microservices Layer
    subgraph "Microservices"
        direction TB
        AuthService["Auth Service"]:::service
        OrderService["Order Service"]:::service
        ProductService["Product Service\n(cron jobs)"]:::service
        SellerService["Seller Service\n(cron jobs)"]:::service
        RecommendationService["Recommendation Service"]:::service
        ChattingService["Chatting Service\n(WebSocket)"]:::service
        LoggerService["Logger Service"]:::service
        KafkaService["Kafka Service"]:::service
    end

    %% Data & Messaging
    subgraph "Data & Messaging"
        direction TB
        DB[(Relational DB)]:::datastore
        Redis[(Redis Cache)]:::datastore
        Kafka[(Kafka Cluster)]:::datastore
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        ComponentsLib["UI Components Lib"]:::shared
        ErrorHandlerLib["Error Handler Lib"]:::shared
        PrismaLib["Prisma ORM Wrapper"]:::shared
        RedisLib["Redis Wrapper"]:::shared
        StripeLib["Stripe Integration Lib"]:::shared
        AuthMiddleware["Auth & Authorization\nMiddleware"]:::shared
        KafkaUtilLib["Kafka Utility Lib"]:::shared
    end

    %% External Integrations
    subgraph "External Integrations"
        direction TB
        Stripe["Stripe"]:::external
        EmailSvc["Email Service\n(SMTP)"]:::external
        ImageKit["ImageKit"]:::external
    end

    %% Connections: UIs to Gateway
    AdminUI -->|"HTTP/HTTPS"| APIGateway
    SellersUI -->|"HTTP/HTTPS"| APIGateway
    UsersUI -->|"HTTP/HTTPS"| APIGateway

    %% Gateway to Services
    APIGateway -->|"HTTP"| AuthService
    APIGateway -->|"HTTP"| OrderService
    APIGateway -->|"HTTP"| ProductService
    APIGateway -->|"HTTP"| SellerService
    APIGateway -->|"HTTP"| RecommendationService
    APIGateway -->|"HTTP"| ChattingService
    APIGateway -->|"HTTP"| LoggerService

    %% Services to Data Stores
    AuthService -->|reads/writes| DB
    OrderService -->|reads/writes| DB
    ProductService -->|reads/writes| DB
    SellerService -->|reads/writes| DB
    RecommendationService -->|reads/writes| DB
    LoggerService -->|reads/writes| DB

    %% Services to Redis
    AuthService -->|cache/session| Redis
    OrderService -->|cache| Redis
    ProductService -->|cache| Redis
    SellerService -->|cache| Redis

    %% Event-driven flows via Kafka
    OrderService -->|“order-created”| Kafka
    ProductService -->|“inventory-updated”| Kafka
    SellerService -->|“seller-activated”| Kafka
    RecommendationService -->|consumes| Kafka
    LoggerService -->|consumes| Kafka

    %% Chatting WebSocket
    ChattingService -->|"WebSocket"| UsersUI
    ChattingService -->|"WebSocket"| SellersUI

    %% Cron Jobs
    ProductService ---|“cron: inventory”| ProductService
    SellerService ---|“cron: activate”| SellerService

    %% Shared Libraries usage
    AuthService --> AuthMiddleware
    OrderService --> ErrorHandlerLib
    ProductService --> ErrorHandlerLib
    SellerService --> ErrorHandlerLib
    RecommendationService --> KafkaUtilLib
    ChattingService --> ErrorHandlerLib
    LoggerService --> KafkaUtilLib
    AuthService --> PrismaLib
    OrderService --> PrismaLib
    ProductService --> PrismaLib
    SellerService --> PrismaLib
    RecommendationService --> PrismaLib
    LoggerService --> PrismaLib
    AuthService --> RedisLib
    OrderService --> RedisLib

    %% External Integrations usage
    OrderService --> Stripe
    AuthService --> EmailSvc
    ProductService --> ImageKit

    %% Click Events
    click AdminUI "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/admin-ui"
    click SellersUI "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/sellers-ui"
    click UsersUI "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/users-ui"
    click APIGateway "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/api-gateway"
    click AuthService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/auth-service"
    click OrderService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/order-service"
    click ProductService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/product-service"
    click SellerService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/seller-service"
    click RecommendationService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/recommendation-service"
    click ChattingService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/chatting-service"
    click LoggerService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/logger-service"
    click KafkaService "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/apps/kafka-service"
    click ComponentsLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/components"
    click ErrorHandlerLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/error-handler"
    click PrismaLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/libs/prisma"
    click RedisLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/libs/redis"
    click StripeLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/libs/stripe"
    click AuthMiddleware "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/middleware"
    click KafkaUtilLib "https://github.com/bhupesh227/e_commerce_multivendor/tree/main/packages/utils/kafka"
    click DB "https://github.com/bhupesh227/e_commerce_multivendor/blob/main/prisma/schema.prisma"

    %% Styles
    classDef ui fill:#a8d5a2,stroke:#333,stroke-width:1px
    classDef gateway fill:#9fc5e8,stroke:#333,stroke-width:1px
    classDef service fill:#f4b183,stroke:#333,stroke-width:1px
    classDef datastore fill:#b4a7d6,stroke:#333,stroke-width:1px
    classDef shared fill:#b7b7b7,stroke:#333,stroke-width:1px
    classDef external fill:#d9d9d9,stroke:#333,stroke-width:1px
```
