# bhavdiya/dynamic-mart architecture

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

- Interactive diagram: https://gitdiagram.com/bhavdiya/dynamic-mart
- Repository: https://github.com/bhavdiya/dynamic-mart

## Overview

##### Project type and purpose
- price-pilot-commerce is a front-end single-page e-commerce “demo” application.
- Built with Vite, React, TypeScript, Tailwind CSS, and shadcn-ui.
- It renders product listings, pricing dashboards, shopping cart flows and uses a local pricing engine and mock data.

##### File structure
- Top level:
- index.html, Vite + Tailwind + TS configs, package.json
- public/robots.txt (static assets)
- src/:
- main.tsx, App.tsx, index.css – entry point and global styles
- components/:
– pages-level (PricingDashboard.tsx, ShoppingCart.tsx, ProductCard.tsx)
– ui/ – shadcn-ui primitives (button, dialog, table, etc.)
- pages/ (Index.tsx, NotFound.tsx) – route targets
- services/pricingEngine.ts – core business logic (pricing calculations)
- data/mockProducts.ts – local data store
- hooks/ – custom React hooks (useMobile, useToast)
- lib/utils.ts, types/ – utility and type definitions
- No backend folder: entirely client-side.

##### README for insights
- Confirms tech stack and that it is a Vite + React demo.
- No mention of external APIs or runtime services—uses mock data.

##### Main components & interactions
a. Browser / Client
- Hosts the SPA
- Executes bundled JS/CSS
b. Vite Dev Server / Build Pipeline
- Transpiles TSX → JS, processes Tailwind CSS, bundles assets
- Outputs static files for deployment
c. React Application
- App Shell (App.tsx → Routes in pages/)
- UI Layer (shadcn-ui components)
- Feature Components (ProductCard, ShoppingCart, PricingDashboard)
d. Business Logic Layer
- pricingEngine.ts (calculates discounts, totals, promotions)
- utils.ts (helper functions)
e. Data Layer
- mockProducts.ts (in-memory product definitions)
- types/index.ts (domain models)
f. Custom Hooks
- useMobile.tsx (responsive logic)
- useToast.ts (notification system tied to UI primitives)
g. (Optional) Deployment / CDN
- Static host (Netlify / Vercel / S3+CloudFront) serving index.html + assets

##### Relationships & data flow
- User interacts in Browser → React Components
- Components call custom hooks (e.g., useMobile, useToast)
- Components fetch from Data Layer (mockProducts) or call Business Logic Layer (pricingEngine)
- pricingEngine returns calculated values → Components render updated UI
- All UI primitives come from shadcn-ui (imported under components/ui/)
- During dev: file changes → Vite dev server hot-reloads in Browser

##### Architectural patterns & design principles
- Component-based architecture (React)
- Separation of concerns:
- UI primitives vs. feature components vs. page routes
- Business logic in services/pricingEngine.ts
- Data storage in data/mockProducts.ts
- Single Source of Truth for data (mockProducts + React state)
- Hook abstraction for cross-cutting concerns (responsive design, toasts)

##### Technologies & frameworks
- Vite (dev server & bundler)
- React + TypeScript
- Tailwind CSS
- shadcn-ui (prebuilt component library)
- No external API—mock data

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Deployment Layer
    subgraph "Build & Deployment" 
        direction TB
        VITE["Vite Dev Server / Build"]:::build
        CONFIG["Config Files"]:::build
        STATIC_HOST["Static Host (Netlify/Vercel/S3)"]:::deploy
        VITE -->|"uses"| CONFIG
        VITE -->|"outputs static assets"| STATIC_HOST
    end

    %% Runtime Layer
    subgraph "Runtime (Browser / React App)"
        direction TB
        USER["User"]:::external
        BROWSER["Browser / Client"]:::external
        USER -->|"interacts"| BROWSER
        BROWSER -->|"loads SPA"| APP["App Shell"]:::app
        subgraph "React Application" 
            direction TB
            APP
            subgraph "Pages" 
                direction TB
                INDEX["Index.tsx"]:::page
                NOTFOUND["NotFound.tsx"]:::page
            end
            subgraph "Feature Components"
                direction TB
                DASH["PricingDashboard.tsx"]:::feature
                CART["ShoppingCart.tsx"]:::feature
                CARD["ProductCard.tsx"]:::feature
            end
            subgraph "UI Library (shadcn-ui)" 
                direction TB
                UI_PRIM["UI Primitives"]:::ui
            end
            subgraph "Business Logic / Services"
                direction TB
                PRICING["pricingEngine.ts"]:::service
                UTILS["utils.ts"]:::service
            end
            subgraph "Data Layer"
                direction TB
                MOCK["mockProducts.ts"]:::data
                TYPES["index.ts"]:::data
            end
            subgraph "Custom Hooks"
                direction TB
                MOBILE["use-mobile.tsx"]:::hook
                TOAST["use-toast.ts"]:::hook
            end
        end
        %% Runtime Connections
        APP -->|"routes to"| INDEX
        APP -->|"routes to"| NOTFOUND
        INDEX -->|"renders"| DASH
        INDEX -->|"renders"| CART
        DASH -->|"uses hook"| MOBILE
        DASH -->|"uses hook"| TOAST
        CART -->|"uses hook"| TOAST
        CARD -->|"displays data from"| MOCK
        DASH -->|"fetchProducts() from"| MOCK
        DASH -->|"calculatePrice() via"| PRICING
        CART -->|"calculatePrice() via"| PRICING
        PRICING -->|"helper functions"| UTILS
        APP -->|"imports UI"| UI_PRIM
        DASH -->|"imports UI"| UI_PRIM
        CART -->|"imports UI"| UI_PRIM
        CARD -->|"imports UI"| UI_PRIM
    end

    %% Vite Hot Reload
    subgraph "Development Flow"
        direction TB
        WATCH["File Changes"]:::build
        WATCH -->|"triggers"| VITE
        VITE -->|"hot reload"| BROWSER
    end

    %% Click Events
    click APP "https://github.com/bhavdiya/dynamic-mart/blob/main/src/App.tsx"
    click INDEX "https://github.com/bhavdiya/dynamic-mart/blob/main/src/pages/Index.tsx"
    click NOTFOUND "https://github.com/bhavdiya/dynamic-mart/blob/main/src/pages/NotFound.tsx"
    click DASH "https://github.com/bhavdiya/dynamic-mart/blob/main/src/components/PricingDashboard.tsx"
    click CART "https://github.com/bhavdiya/dynamic-mart/blob/main/src/components/ShoppingCart.tsx"
    click CARD "https://github.com/bhavdiya/dynamic-mart/blob/main/src/components/ProductCard.tsx"
    click UI_PRIM "https://github.com/bhavdiya/dynamic-mart/tree/main/src/components/ui/"
    click PRICING "https://github.com/bhavdiya/dynamic-mart/blob/main/src/services/pricingEngine.ts"
    click UTILS "https://github.com/bhavdiya/dynamic-mart/blob/main/src/lib/utils.ts"
    click MOCK "https://github.com/bhavdiya/dynamic-mart/blob/main/src/data/mockProducts.ts"
    click TYPES "https://github.com/bhavdiya/dynamic-mart/blob/main/src/types/index.ts"
    click MOBILE "https://github.com/bhavdiya/dynamic-mart/blob/main/src/hooks/use-mobile.tsx"
    click TOAST "https://github.com/bhavdiya/dynamic-mart/blob/main/src/hooks/use-toast.ts"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/vite.config.ts"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/tsconfig.json"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/tsconfig.app.json"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/tsconfig.node.json"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/tailwind.config.ts"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/postcss.config.js"
    click CONFIG "https://github.com/bhavdiya/dynamic-mart/blob/main/package.json"
    click VITE "https://github.com/bhavdiya/dynamic-mart/blob/main/vite.config.ts"

    %% Styles
    classDef build fill:#dddddd,stroke:#999,stroke-width:1px
    classDef deploy fill:#cccccc,stroke:#666,stroke-width:1px
    classDef external fill:#f9f9f9,stroke:#bbb,stroke-width:1px
    classDef app fill:#e3f2fd,stroke:#90caf9,stroke-width:1px
    classDef page fill:#bbdefb,stroke:#42a5f5,stroke-width:1px
    classDef feature fill:#90caf9,stroke:#1e88e5,stroke-width:1px
    classDef ui fill:#e1f5fe,stroke:#039be5,stroke-width:1px
    classDef service fill:#c8e6c9,stroke:#43a047,stroke-width:1px
    classDef data fill:#fff9c4,stroke:#fbc02d,stroke-width:1px
    classDef hook fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px
```
