# asyncarijit/truassignment architecture

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

- Interactive diagram: https://gitdiagram.com/asyncarijit/truassignment
- Repository: https://github.com/asyncarijit/truassignment

## Overview

##### Project type and purpose
- This is a single-page frontend application built with React and Vite.
- Purpose: allow users to search products (e.g., via barcode), apply filters, view product listings and details. It relies on an external products API/service.

##### File structure
- Top-level “public” and “index.html”: static assets and HTML entrypoint.
- “vite.config.js”: Vite dev/build configuration.
- “src/main.jsx”: application bootstrap (mounts React into the DOM).
- “src/App.jsx”: root component that defines routes/pages.
- “src/pages”: high-level routes: Home, ProductDetails.
- “src/components”: reusable UI components (SearchBar, BarcodeSearch, Filters, ProductCard, Skeleton).
- “src/hooks”: custom hooks (useFilters, useProducts) that encapsulate data fetching and business logic.
- “src/redux”: state management;
- store.js – configures Redux store
- slices/filterSlice.js – manages filter state
- slices/productSlice.js – manages products list & details
- “src/utils”: pure helper functions (extractMeta, productUtils).

##### README
- Confirms this is a minimal React+Vite template with HMR and ESLint, using either Babel or SWC plugin.
- No backend or specialized architecture is mentioned beyond the standard SPA.

##### Detailed checklist to capture essential elements
- [ ] Vite Dev/Build environment
- [ ] index.html → main.jsx → App.jsx (application bootstrap flow)
- [ ] Pages (Home, ProductDetails)
- [ ] Core Components (SearchBar, BarcodeSearch, Filters, ProductCard)
- [ ] Redux store and slices (filterSlice, productSlice)
- [ ] Custom Hooks (useFilters, useProducts)
- [ ] Utility modules (extractMeta, productUtils)
- [ ] External Products API
- [ ] Data flows and dependencies labeled and directional

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build/Dev Pipeline
    subgraph "Build/Dev Pipeline"
        direction TB
        VITE["Vite Dev/Build Environment"]:::build
        HTML["HTML Entry Point (index.html)"]:::build
    end

    %% Browser Runtime
    subgraph "Browser Runtime"
        direction TB

        %% Application Bootstrap Flow
        subgraph "Bootstrap"
            direction TB
            MAIN["src/main.jsx"]:::presentation
            APP["src/App.jsx"]:::presentation
        end

        %% UI Layer
        subgraph "UI Layer" 
            direction TB
            HOME["Home Page"]:::presentation
            PRODDETAIL["Product Details Page"]:::presentation
            SBAR["Search Bar"]:::presentation
            BCSEARCH["Barcode Search"]:::presentation
            FILTERP["Filters Panel"]:::presentation
            PCARD["Product Card"]:::presentation
            PCSKELETON["Product Card Skeleton"]:::presentation
        end

        %% State Management
        subgraph "State Management"
            direction TB
            STORE["Redux Store"]:::state
            FS["filterSlice"]:::state
            PS["productSlice"]:::state
        end

        %% Data Access & Utils
        subgraph "Data & Utils"
            direction TB
            UFILTER["useFilters Hook"]:::data
            UPROD["useProducts Hook"]:::data
            EXMETA["extractMeta Utility"]:::data
            PUTIL["productUtils Utility"]:::data
        end
    end

    %% External API
    EXTAPI["External Products API"]:::external

    %% Static Assets & Styles
    PUBLIC["public/"]:::build
    STYLE1["src/index.css"]:::build
    STYLE2["src/App.css"]:::build
    META1["package.json"]:::build
    META2["package-lock.json"]:::build
    ESLINT["eslint.config.js"]:::build
    README["README.md"]:::build

    %% Connections
    VITE -->|serves| HTML
    VITE -->|bundles| MAIN
    HTML -->|loads| MAIN
    MAIN -->|renders| APP
    APP -->|routes| HOME
    APP -->|routes| PRODDETAIL

    HOME -->|uses| SBAR
    HOME -->|uses| FILTERP
    HOME -->|uses| PCARD
    HOME -->|skeleton| PCSKELETON
    PRODDETAIL -->|uses| BCSEARCH
    PRODDETAIL -->|uses| PCARD

    SBAR -->|dispatch action| STORE
    FILTERP -->|dispatch action| STORE
    BCSEARCH -->|dispatch action| STORE

    STORE -->|contains| FS
    STORE -->|contains| PS

    FS -->|triggers| UFILTER
    PS -->|triggers| UPROD

    UFILTER -->|reads| FS
    UPROD -->|reads| PS
    UPROD -->|uses| EXMETA
    UPROD -->|uses| PUTIL

    UPROD -->|HTTP GET| EXTAPI
    EXTAPI -->|response| PS
    PS -->|updates| STORE

    STORE -->|state subscription| SBAR
    STORE -->|state subscription| HOME
    STORE -->|state subscription| PRODDETAIL
    STORE -->|state subscription| PCARD

    PUBLIC -->|assets| HTML
    STYLE1 -->|global styles| APP
    STYLE2 -->|component styles| APP

    META1 -->|project config| VITE
    META2 -->|lockfile| VITE
    ESLINT -->|lint rules| VITE
    README -->|documentation| VITE

    %% Click Events
    click VITE "https://github.com/asyncarijit/truassignment/blob/main/vite.config.js"
    click HTML "https://github.com/asyncarijit/truassignment/blob/main/index.html"
    click MAIN "https://github.com/asyncarijit/truassignment/blob/main/src/main.jsx"
    click APP "https://github.com/asyncarijit/truassignment/blob/main/src/App.jsx"
    click HOME "https://github.com/asyncarijit/truassignment/blob/main/src/pages/Home.jsx"
    click PRODDETAIL "https://github.com/asyncarijit/truassignment/blob/main/src/pages/ProductDetails.jsx"
    click SBAR "https://github.com/asyncarijit/truassignment/blob/main/src/components/SearchBar.jsx"
    click BCSEARCH "https://github.com/asyncarijit/truassignment/blob/main/src/components/BarcodeSearch.jsx"
    click FILTERP "https://github.com/asyncarijit/truassignment/blob/main/src/components/Filters.jsx"
    click PCARD "https://github.com/asyncarijit/truassignment/blob/main/src/components/ProductCard.jsx"
    click PCSKELETON "https://github.com/asyncarijit/truassignment/blob/main/src/components/ProductCardSkeleton.jsx"
    click STORE "https://github.com/asyncarijit/truassignment/blob/main/src/redux/store.js"
    click FS "https://github.com/asyncarijit/truassignment/blob/main/src/redux/slices/filterSlice.js"
    click PS "https://github.com/asyncarijit/truassignment/blob/main/src/redux/slices/productSlice.js"
    click UFILTER "https://github.com/asyncarijit/truassignment/blob/main/src/hooks/useFilters.js"
    click UPROD "https://github.com/asyncarijit/truassignment/blob/main/src/hooks/useProducts.js"
    click EXMETA "https://github.com/asyncarijit/truassignment/blob/main/src/utils/extractMeta.js"
    click PUTIL "https://github.com/asyncarijit/truassignment/blob/main/src/utils/productUtils.js"
    click PUBLIC "https://github.com/asyncarijit/truassignment/tree/main/public/"
    click STYLE1 "https://github.com/asyncarijit/truassignment/blob/main/src/index.css"
    click STYLE2 "https://github.com/asyncarijit/truassignment/blob/main/src/App.css"
    click META1 "https://github.com/asyncarijit/truassignment/blob/main/package.json"
    click META2 "https://github.com/asyncarijit/truassignment/blob/main/package-lock.json"
    click ESLINT "https://github.com/asyncarijit/truassignment/blob/main/eslint.config.js"
    click README "https://github.com/asyncarijit/truassignment/blob/main/README.md"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef state fill:#d4edda,stroke:#333,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef build fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef external fill:#f8d7da,stroke:#333,stroke-width:1px
```
