# yashchhatrala25/dreamland_shop_using_react_typescript architecture

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

- Interactive diagram: https://gitdiagram.com/yashchhatrala25/dreamland_shop_using_react_typescript
- Repository: https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript

## Overview

##### Project type and purpose
- This is a single-page e-commerce frontend built with React + TypeScript.
- It consumes a dummyjson REST API to display products, categories, and supports searching, filtering, pagination, and product detail pages.

##### File structure
- Top-level:
- index.html – HTML entry point
- vite.config.ts – Vite build/dev server config
- package.json / package-lock.json – dependencies and scripts
- tsconfig*.json – TypeScript compiler configs
- src/
- main.tsx – React DOM mounting and root providers
- App.tsx – Root React component with router setup
- index.css – global styles
- components/ – all UI components and context:
– FilterContext.tsx – global filter state provider
– Sidebar.tsx – category & price filters
– MainContent.tsx – product grid & pagination
– BookCard.tsx – individual product card
– PopularBlogs.tsx, TopSellers.tsx – sidebar widgets
– ProductPage.tsx – detail view for one product

##### Key architectural insights from README
- Client-side routing via react-router-dom
- State management with React hooks & Context API
- External data source: dummyjson REST endpoints

a. Main components
- Browser/Client
- Static Host (Vite dev server or built files on Netlify)
- React App
– Root (index.html → main.tsx → App.tsx)
– Router layer
– UI components (Sidebar, MainContent, ProductPage, etc.)
– Context Provider (FilterContext)
- External API (dummyjson)
b. Relationships & data flow
1. Browser requests index.html / JS bundle from static host
2. Vite‐built bundle loads main.tsx → wraps <App> in <FilterContext.Provider>
3. <App> sets up <BrowserRouter>
4. Sidebar dispatches filter actions → updates context → triggers product fetch
5. MainContent uses current filters to call dummyjson API → updates UI
6. ProductPage fetches /products/:id on route change
7. PopularBlogs & TopSellers optionally fetch other endpoints or use demo data
c. Architectural patterns
- Component-based UI
- Single-page application (SPA)
- Context API for cross-cutting state (filters)
- Hook-based data fetching
- Client-side routing (react-router-dom)
d. Key technologies
- React + TypeScript
- Vite (build & dev server)
- react-router-dom (routing)
- dummyjson REST API

##### Essential elements
- Arrowheads to show request/response or data-update flows
- Callouts for any business logic (e.g. “Price range logic in Sidebar”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hosting & Build Layer
    subgraph "Hosting & Build"
        Browser("Browser / Client"):::external
        StaticHost("Static Host (Vite/Netlify)"):::hosting
        IndexHTML("index.html"):::hosting
        ViteConfig("vite.config.ts"):::hosting
        PackageJSON("package.json / package-lock.json"):::hosting
    end

    %% React Core Layer
    subgraph "React Core"
        MainTSX("src/main.tsx"):::core
        AppTSX("src/App.tsx"):::core
        IndexCSS("src/index.css"):::core
    end

    %% Context Layer
    subgraph "State Management"
        FilterContext("FilterContext Provider"):::core
    end

    %% UI Components Layer
    subgraph "UI Components"
        Sidebar("Sidebar Component"):::ui
        MainContent("MainContent Component"):::ui
        BookCard("BookCard Component"):::ui
        ProductPage("ProductPage Component"):::ui
        PopularBlogs("PopularBlogs Widget"):::ui
        TopSellers("TopSellers Widget"):::ui
    end

    %% External Services Layer
    subgraph "External Services"
        DummyJSON("dummyjson REST API"):::external
    end

    %% Connections
    Browser -->|"requests assets"| StaticHost
    StaticHost -->|"serves index.html & JS bundle"| Browser

    StaticHost --> IndexHTML
    StaticHost --> ViteConfig
    StaticHost --> PackageJSON

    Browser -->|loads React App| MainTSX
    MainTSX -->|mounts App| AppTSX
    MainTSX --> IndexCSS

    AppTSX -->|"wraps with"| FilterContext

    FilterContext -->|"provides state to"| Sidebar
    FilterContext -->|"provides state to"| MainContent

    Sidebar -->|"dispatch filter actions"| FilterContext
    MainContent -->|"fetch products"| DummyJSON
    ProductPage -->|"fetch product details"| DummyJSON
    PopularBlogs -->|"fetch blogs data"| DummyJSON
    TopSellers -->|"fetch sellers data"| DummyJSON

    %% Click Events
    click IndexHTML "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/index.html"
    click ViteConfig "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/vite.config.ts"
    click PackageJSON "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/package.json"
    click MainTSX "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/main.tsx"
    click AppTSX "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/App.tsx"
    click IndexCSS "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/index.css"
    click FilterContext "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/FilterContext.tsx"
    click Sidebar "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/Sidebar.tsx"
    click MainContent "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/MainContent.tsx"
    click BookCard "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/BookCard.tsx"
    click ProductPage "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/ProductPage.tsx"
    click PopularBlogs "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/PopularBlogs.tsx"
    click TopSellers "https://github.com/yashchhatrala25/dreamland_shop_using_react_typescript/blob/main/src/components/TopSellers.tsx"

    %% Styles
    classDef hosting fill:#BBDEFB,stroke:#333,stroke-width:1px
    classDef core fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef ui fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#E1BEE7,stroke:#333,stroke-width:1px
```
