# harsh-p30/tbpc architecture

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

- Interactive diagram: https://gitdiagram.com/harsh-p30/tbpc
- Repository: https://github.com/harsh-p30/tbpc

## Overview

##### Project type and purpose
- This is a single-page e-commerce storefront built entirely as a React/TypeScript frontend.
- It uses Vite for bundling/dev server, Tailwind CSS for styling, shadcn-ui for reusable UI primitives, and local data modules (e.g. productsData.js) or external APIs for product information.

##### File structure
- Top level: package.json, Vite/Tailwind/TypeScript configs → build & dev tooling
- public/ → static assets (robots.txt, index.html template)
- src/
- main.tsx → application entrypoint (mounts React `<App/>`)
- lib/ → shared utility functions
- hooks/ → custom React hooks (useMobile, useFilteredProducts, useToast, etc.)
- components/ → UI component library and domain-specific components
– ui/ → primitive components (button, modal, form, etc.) from shadcn-ui
– products/ → product-focused components & filtering logic
– layout & generic (Navbar, Footer, Hero, etc.)
- pages/ → route targets (Index, Products, Cart, ProductDetail, CategoryDetail, About, Contact, NotFound)
- No backend or API server code is present here—it’s purely a frontend application.

##### Key insights from README
- Confirms tech stack: Vite, TypeScript, React, shadcn-ui, Tailwind CSS
- Standard npm scripts for local dev (`npm run dev`) and build
- Deployed as static assets (no server-side rendering indicated)

##### Main components
A. Developer & SCM layer
- Developer workstation (IDE, git client) → Git repository
- CI/CD pipeline (optional) triggered on push
B. Build & Deployment layer
- Vite (dev server for localhost; build tool for production)
- Output: static JS/CSS assets + index.html
- Hosting/CDN (e.g. Netlify, Vercel, S3 + CloudFront)
C. Runtime layer (Browser)
- index.html → mounts React App
- App shell & Router (react-router-dom)
- Pages (src/pages/*)
- Components (src/components/*)
- Hooks & Utils (src/hooks, src/lib)
- UI primitives (shadcn-ui) + Tailwind CSS runtime
D. Data sources
- Local JSON/modules (productsData.js)
- Or external REST/GraphQL endpoints (if configured)

##### Relationships & interactions
- Developer → Git push → CI/CD → Vite build → Deploy → Hosting / CDN
- Browser requests index.html + static assets → React App starts
- User action → React Router → Page component
- Page component → uses custom hooks (e.g. useFilteredProducts) → util modules or API calls → returns data
- Data flows into Presentational Components (ProductCard, Carousel, Filters, etc.)
- UI primitives & Tailwind render visual elements

##### Architectural patterns & design principles
- Component-based architecture (atomic UI + domain components)
- Unidirectional data flow (React state/hooks → props → UI)
- Layered separation: Pages (routes) → Components (UI) → Hooks/Utils (logic) → Data
- Utility-first styling (Tailwind) + design system (shadcn-ui)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & SCM layer
    subgraph "Developer & SCM"
        direction TB
        Developer["Developer Workstation (IDE, Git Client)"]:::infra
        GitRepo["Git Repository"]:::infra
        CICD["CI/CD Pipeline"]:::infra
    end

    Developer -->|push code| GitRepo
    GitRepo -->|trigger| CICD

    %% Build & Deployment layer
    subgraph "Build & Deployment"
        direction TB
        subgraph "Configuration Files"
            direction TB
            ViteConfig["vite.config.ts"]:::build
            TailwindConfig["tailwind.config.ts"]:::build
            TsConfig["tsconfig.json"]:::build
            PackageJson["package.json"]:::build
            PostCSS["postcss.config.js"]:::build
        end
        ViteDev["Vite Dev Server"]:::build
        ViteBuild["Vite Build Tool"]:::build
        subgraph "Public Static Assets"
            direction TB
            PublicIndex["public/index.html"]:::build
            Robots["public/robots.txt"]:::build
        end
        StaticOutput["Static JS/CSS Assets"]:::build
        Hosting["Hosting / CDN (Netlify, Vercel, S3+CF)"]:::infra
    end

    CICD -->|runs build| ViteBuild
    ViteBuild --> StaticOutput
    ViteBuild --> PublicIndex
    StaticOutput --> Hosting
    PublicIndex --> Hosting

    %% Runtime layer
    subgraph "Runtime (Browser)"
        direction TB
        Browser["Web Browser"]:::runtime
        Hosting -->|serve assets| Browser
        IndexHTML["index.html"]:::runtime
        Browser --> IndexHTML
        subgraph "React Application"
            direction TB
            Main["src/main.tsx"]:::code
            AppShell["src/App.tsx"]:::code
            Main --> AppShell
            subgraph "Routing Layer"
                direction TB
                Router["react-router-dom"]:::code
                PagesLayer["src/pages: Route Components"]:::code
            end
            subgraph "Component Layer"
                direction TB
                UIPrimitives["src/components/ui: shadcn-ui Primitives"]:::code
                DomainComponents["src/components: Layout & Domain UI"]:::code
            end
            subgraph "Logic Layer"
                direction TB
                Hooks["src/hooks: Custom React Hooks"]:::code
                Utils["src/lib: Utility Functions"]:::code
            end
            subgraph "Styling Engine"
                direction TB
                Tailwind["Tailwind CSS"]:::runtime
            end
            subgraph "Data Sources"
                direction TB
                LocalData["src/components/products/productsData.js"]:::data
                ExternalAPI["External REST/GraphQL API"]:::data
            end

            AppShell --> Router
            Router --> PagesLayer
            PagesLayer --> Hooks
            Hooks --> Utils
            Hooks -->|fetch| LocalData
            Hooks -->|fetch| ExternalAPI
            PagesLayer --> DomainComponents
            DomainComponents --> UIPrimitives
            UIPrimitives --> Tailwind
        end
    end

    %% Click Events
    click ViteConfig "https://github.com/harsh-p30/tbpc/blob/main/vite.config.ts"
    click TailwindConfig "https://github.com/harsh-p30/tbpc/blob/main/tailwind.config.ts"
    click TsConfig "https://github.com/harsh-p30/tbpc/blob/main/tsconfig.json"
    click PackageJson "https://github.com/harsh-p30/tbpc/blob/main/package.json"
    click PostCSS "https://github.com/harsh-p30/tbpc/blob/main/postcss.config.js"
    click PublicIndex "https://github.com/harsh-p30/tbpc/blob/main/public/index.html"
    click Robots "https://github.com/harsh-p30/tbpc/blob/main/public/robots.txt"
    click Main "https://github.com/harsh-p30/tbpc/blob/main/src/main.tsx"
    click AppShell "https://github.com/harsh-p30/tbpc/blob/main/src/App.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Index.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Products.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/ProductDetail.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/CategoryDetail.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Categories.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Cart.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/About.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Contact.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/NewArrivals.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/Sale.tsx"
    click PagesLayer "https://github.com/harsh-p30/tbpc/blob/main/src/pages/NotFound.tsx"
    click UIPrimitives "https://github.com/harsh-p30/tbpc/blob/main/src/components/ui/button.tsx"
    click UIPrimitives "https://github.com/harsh-p30/tbpc/blob/main/src/components/ui/modal/dialog.tsx"
    click UIPrimitives "https://github.com/harsh-p30/tbpc/blob/main/src/components/ui/toast.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/Hero.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/Navbar.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/Footer.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/FeaturedProducts.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/Newsletter.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/Categories.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/ProductCard.tsx"
    click DomainComponents "https://github.com/harsh-p30/tbpc/blob/main/src/components/ProductCardWrapper.tsx"
    click Hooks "https://github.com/harsh-p30/tbpc/blob/main/src/hooks/use-mobile.tsx"
    click Hooks "https://github.com/harsh-p30/tbpc/blob/main/src/hooks/use-toast.ts"
    click Hooks "https://github.com/harsh-p30/tbpc/blob/main/src/hooks/useProductFiltering.ts"
    click Utils "https://github.com/harsh-p30/tbpc/blob/main/src/lib/utils.ts"
    click LocalData "https://github.com/harsh-p30/tbpc/blob/main/src/components/products/productsData.js"

    %% Styles
    classDef infra fill:#E3F2FD,stroke:#2196F3,color:#0D47A1
    classDef build fill:#E8F5E9,stroke:#4CAF50,color:#1B5E20
    classDef runtime fill:#FFF8E1,stroke:#FFC107,color:#E65100
    classDef code fill:#ECEFF1,stroke:#607D8B,color:#263238
    classDef data fill:#F3E5F5,stroke:#9C27B0,color:#4A148C
```
