# tushar-81/xivtech-assignment architecture

> Architecture diagram of the GitHub repository tushar-81/xivtech-assignment, 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/tushar-81/xivtech-assignment
- Repository: https://github.com/tushar-81/xivtech-assignment

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) for real-time cryptocurrency price tracking.
- It uses React + TypeScript on the front end, Redux Toolkit for state management, Tailwind CSS for styling, and Framer Motion for animations. There is no back-end server—price data is simulated client-side via `ConnectionSimulator`.

##### File structure
- Top-level “public/” holds your static entry point (`index.html`), manifest and robots settings.
- “src/” contains all front-end code:
- `src/index.tsx` bootstraps the React App.
- `src/app/store.ts` configures the Redux store.
- `src/features/cryptoSlice.ts` defines state, reducers, and actions for crypto data.
- `src/components/` houses reusable UI pieces (`Header`, `CryptoTable`, `ConnectionSimulator`).
- `src/utils/` contains test helpers and other utilities.
- `src/types/` defines shared TypeScript types.
- Config files (`tsconfig.json`, `tailwind.config.js`, `postcss.config.js`) and build scripts (`package.json`) underlie the toolchain (CRA, PostCSS, Tailwind).

##### Review README insights
- Real-time simulation every 1.5s driven by `ConnectionSimulator`.
- Responsive layout with table/card toggles, sorting/filtering, UI state persists in `localStorage`.
- Built/tested via Create React App’s Webpack pipeline, unit tests in `src/*.test.tsx`.

a. Main components to represent:
- Browser / User Device
- Static Asset Host (e.g. CDN or Web Server serving `index.html` + JS bundle + CSS)
- React Application
- Redux Store (configured in `store.ts`)
- ConnectionSimulator (simulated data producer)
- UI Components (Header, CryptoTable, etc.)
- Persistence Layer (`localStorage`)
- Utility Modules (e.g. test utils, TypeScript types—not critical to data flow but can be shown as ancillary)
b. Relationships & interactions:
- Browser requests static assets from host → loads React bundle.
- React init calls `store.ts`, loads persisted preferences from `localStorage`.
- `ConnectionSimulator` emits “priceUpdate” events every 1.5s → dispatches actions to `cryptoSlice`.
- Redux store updates state → subscribed UI components re-render via React.
- User sorting/filtering interactions dispatch actions → updates store → new UI state → preferences saved back to `localStorage`.
c. Architectural patterns / design principles:
- Flux / unidirectional data flow (React + Redux).
- Separation of concerns: Simulation & state logic in slices, presentation in components.
- Immutable state updates via Redux Toolkit.
d. Key technologies:
- React + React-DOM (JSX rendering)
- Redux Toolkit (store, slices, middleware)
- TypeScript (static typing)
- Tailwind CSS & PostCSS (utility-first styling)
- Framer Motion (animations)
- Create React App (build tooling, Webpack, Babel)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External / Hosting
    Browser["Browser / User Device"]:::external
    StaticHost["Static Asset Host"]:::external
    subgraph "Static Assets"
        StaticHost
    end

    %% Application Initialization
    ReactEntry["React App Entry Point\n(src/index.tsx)"]:::runtime
    MainApp["Main App Component\n(src/App.tsx)"]:::runtime

    %% State Management
    Store["Redux Store\n(src/app/store.ts)"]:::runtime
    CryptoSlice["Crypto Data Slice\n(src/features/cryptoSlice.ts)"]:::runtime

    %% Data Simulation
    Simulator["ConnectionSimulator\n(src/components/ConnectionSimulator.tsx)"]:::runtime

    %% UI Components
    subgraph "UI Components"
        Header["Header\n(src/components/Header.tsx)"]:::ui
        Table["CryptoTable\n(src/components/CryptoTable.tsx)"]:::ui
    end

    %% Persistence
    LocalStorage["localStorage"]:::persistence

    %% Ancillary Modules
    subgraph "Ancillary Modules"
        Types["TypeScript Types\n(src/types/crypto.ts)"]:::external
        Utils["Utilities\n(src/utils/test-utils.tsx)"]:::external
    end

    %% Configuration & Tests
    subgraph "Config & Tests"
        TailwindConfig["Styling Config\n(tailwind.config.js,\npostcss.config.js,\nsrc/index.css)"]:::external
        Tests["Application Tests\n(src/App.test.tsx, ... )"]:::external
    end

    %% Data Flow & Interactions
    Browser -->|"requests assets"| StaticHost
    StaticHost -->|"serves index.html & bundle"| Browser
    Browser -->|"loads bundle"| ReactEntry
    ReactEntry -->|"initializes App"| MainApp
    MainApp -->|"configureStore()"| Store
    Store -->|"includes cryptoSlice"| CryptoSlice
    Simulator -->|"dispatch priceUpdate"| Store
    Store -->|"state update"| Header
    Store -->|"state update"| Table
    Header -->|"dispatch userAction"| Store
    Table -->|"dispatch userAction"| Store
    Store -->|"read/write preferences"| LocalStorage

    %% Click Events
    click StaticHost "https://github.com/tushar-81/xivtech-assignment/blob/master/public/index.html"
    click ReactEntry "https://github.com/tushar-81/xivtech-assignment/blob/master/src/index.tsx"
    click MainApp "https://github.com/tushar-81/xivtech-assignment/blob/master/src/App.tsx"
    click Store "https://github.com/tushar-81/xivtech-assignment/blob/master/src/app/store.ts"
    click CryptoSlice "https://github.com/tushar-81/xivtech-assignment/blob/master/src/features/cryptoSlice.ts"
    click Simulator "https://github.com/tushar-81/xivtech-assignment/blob/master/src/components/ConnectionSimulator.tsx"
    click Header "https://github.com/tushar-81/xivtech-assignment/blob/master/src/components/Header.tsx"
    click Table "https://github.com/tushar-81/xivtech-assignment/blob/master/src/components/CryptoTable.tsx"
    click LocalStorage "https://github.com/tushar-81/xivtech-assignment/blob/master/src/app/store.ts"
    click Types "https://github.com/tushar-81/xivtech-assignment/blob/master/src/types/crypto.ts"
    click Utils "https://github.com/tushar-81/xivtech-assignment/blob/master/src/utils/test-utils.tsx"
    click TailwindConfig "https://github.com/tushar-81/xivtech-assignment/blob/master/tailwind.config.js"
    click Tests "https://github.com/tushar-81/xivtech-assignment/blob/master/src/App.test.tsx"

    %% Styles
    classDef runtime fill:#AED6F1,stroke:#21618C,color:#1B2631
    classDef ui fill:#ABEBC6,stroke:#1D8348,color:#1B2631
    classDef persistence fill:#F9E79F,stroke:#B9770E,color:#1B2631
    classDef external fill:#D5D8DC,stroke:#566573,color:#1B2631
```
