# haroon-rashed/quickcart architecture

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

- Interactive diagram: https://gitdiagram.com/haroon-rashed/quickcart
- Repository: https://github.com/haroon-rashed/quickcart

## Overview

##### Project type and purpose
- Full-stack, server-rendered React application (Next.js 13 “app” router).
- Purpose: e-commerce platform with separate buyer and seller flows (product catalog, cart, orders, seller dashboard).

##### File structure
- app/ → Next.js “app router” pages (buyer-facing: all-products, cart, my-orders, product/[id], add-address, order-placed; seller-facing: under app/seller).
- components/ → reusable UI pieces for buyer and seller.
- context/AppContext.jsx → React Context for global state (cart, user session).
- pages/api/ → Next.js API routes (e.g. inngest event handler).
- config/db.js, models/*.js → Database connection and Mongoose models (User, Order, Product).
- lib/authSeller.js, middleware.ts → authentication/authorization logic for seller routes.
- config/inngest.js → Inngest event definitions for async workflows (e.g. order-placed events).
- public, assets/ → static assets and data (productData).
- next.config.mjs, tailwind.config.mjs, postcss.config.mjs → build and styling configs.

##### README
- Confirms Next.js foundation, no external microservices except Inngest for event processing.
- Deployed on Vercel, uses next/font and Tailwind CSS.

##### Main components & interactions
a. Client Browser
- Sends HTTP requests to Next.js for page rendering & fetches data via client-side fetch/React.
b. Next.js Server (hosted on Vercel)
- App Router (React Server Components + Client Components)
- pages/api (Serverless Functions)
- Middleware (route protection)
- React Context Provider (AppContext)
- Static asset serving (public/, assets/)
c. Database (MongoDB or compatible)
- Accessed via config/db.js and Mongoose models.
d. Inngest Event System
- pages/api/inngest.js & config/inngest.js define and trigger background jobs (e.g., email notifications or order processing).
e. External Services (optional)
- Vercel CDN for static assets
- Potential payment gateway (not in tree but likely)

##### Architectural patterns & design principles
- Server-Side Rendering (SSR) and Static Site Generation (SSG) via Next.js.
- Component-based UI with clear separation of buyer vs seller sub-apps.
- Context API for global state.
- API-First: business logic exposed as serverless endpoints under pages/api.
- Event-Driven: asynchronous workflows via Inngest.
- Middleware for authorization (seller vs buyer).

##### Capturing essential elements
- Do not omit:
- Next.js App Router (buyer vs seller)
- React Context for state management
- API routes and middleware
- Database connection & models
- Inngest event system
- Static assets serving & deployment context

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Client Layer
  subgraph "Client Layer"
    Browser(("Browser")):::external
  end

  %% Server Layer
  subgraph "Server"
    subgraph "Frontend (Buyer & Seller UI)"
      BuyerUI["Buyer UI"]:::frontend
      SellerUI["Seller UI"]:::frontend
      SharedUI["Shared UI Components"]:::frontend
      SellerUIComps["Seller-specific UI Components"]:::frontend
      ReactCtx["React Context"]:::frontend
    end
    subgraph "Backend/API Layer"
      API["API Layer"]:::backend
      InngestRoute["Inngest Event Routes"]:::backend
      Auth["Authentication/Authorization Logic"]:::backend
      Middleware["Middleware"]:::backend
    end
  end

  %% Data & Events Layer
  subgraph "Data & Event Layer"
    DB["Database"]:::data
    InngestBus["Inngest Event System"]:::data
  end

  %% Static & Configs Layer
  subgraph "Static & Configs"
    Static["Static Assets & Product Data"]:::static
    GlobalConfig["Global Styles & Build Configs"]:::static
  end

  %% External Services
  subgraph "External Services"
    Vercel["Vercel CDN"]:::external
    Payment["Payment Gateway"]:::external
  end

  %% Connections
  Browser -->|"renders pages"| BuyerUI
  Browser -->|"renders pages"| SellerUI
  Browser -->|"fetch assets"| Vercel

  SharedUI -->|"used by UI"| BuyerUI
  SharedUI -->|"used by UI"| SellerUI
  SellerUIComps -->|"used by UI"| SellerUI

  BuyerUI -->|"use Context"| ReactCtx
  SellerUI -->|"use Context"| ReactCtx

  BuyerUI -->|"fetch/mutate"| API
  SellerUI -->|"fetch/mutate"| API

  API -->|"CRUD operations"| DB
  API -->|"trigger events"| InngestBus
  InngestRoute -->|"define/handle events"| InngestBus
  InngestBus -->|"callbacks"| API

  API -->|"uses"| Auth
  API -->|"protected by"| Middleware

  Browser -->|"load static"| Static
  Static -->|"served via"| Vercel

  API -->|"process payments"| Payment

  %% Click Events
  click BuyerUI "https://github.com/haroon-rashed/quickcart/tree/main/app/"
  click SellerUI "https://github.com/haroon-rashed/quickcart/tree/main/app/seller/"
  click SharedUI "https://github.com/haroon-rashed/quickcart/tree/main/components/"
  click SellerUIComps "https://github.com/haroon-rashed/quickcart/tree/main/components/seller/"
  click ReactCtx "https://github.com/haroon-rashed/quickcart/blob/main/context/AppContext.jsx"
  click API "https://github.com/haroon-rashed/quickcart/tree/main/pages/api/"
  click InngestRoute "https://github.com/haroon-rashed/quickcart/blob/main/pages/api/inngest.js"
  click Auth "https://github.com/haroon-rashed/quickcart/blob/main/lib/authSeller.js"
  click Middleware "https://github.com/haroon-rashed/quickcart/blob/main/middleware.ts"
  click DB "https://github.com/haroon-rashed/quickcart/blob/main/config/db.js"
  click InngestBus "https://github.com/haroon-rashed/quickcart/blob/main/config/inngest.js"
  click Static "https://github.com/haroon-rashed/quickcart/tree/main/assets/"
  click DataModels "https://github.com/haroon-rashed/quickcart/blob/main/models/User.js"
  click GlobalConfig "https://github.com/haroon-rashed/quickcart/blob/main/app/globals.css"

  %% Data Models Node for click
  DataModels["Data Models"]:::data
  API --> DataModels

  %% Styles
  classDef frontend fill:#ACE7EF,stroke:#333,stroke-width:1px
  classDef backend fill:#C1E1C1,stroke:#333,stroke-width:1px
  classDef data fill:#FFD580,stroke:#333,stroke-width:1px
  classDef static fill:#D3D3D3,stroke:#333,stroke-width:1px
  classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
