# svadhis/404wheel architecture

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

- Interactive diagram: https://gitdiagram.com/svadhis/404wheel
- Repository: https://github.com/svadhis/404wheel

## Overview

##### Project Type and Purpose
- This is a front-end single-page application built with React, TypeScript, and Vite.
- Its purpose is to render a dynamic UI (components like Wheel, Control, Advert, Register, Result) in the browser, with hot module replacement in development.

##### Key Components
a. Development & Build Environment
- Node.js & npm/Yarn – manages dependencies (package.json, package-lock.json)
- Vite Dev Server – serves index.html, provides HMR via @vitejs/plugin-react or plugin-react-swc
- ESLint & TypeScript Compiler – linting (eslint.config.js) and type-checking (tsconfig.*.json)
b. Static Assets
- public/assets – images, fonts, static JSON
- src/assets – module-imported assets
c. Core Application (Client)
- index.html → entry point
- src/main.tsx → bootstraps React into root element
- src/App.tsx + App.css → top-level layout & global styles
- React Components:
– Advert.tsx
– Control.tsx
– Register.tsx
– Wheel.tsx
– Result.tsx
- Utility Modules: constants.ts, utils.ts
d. Output
- dist/ (after build) – production bundle, static files

##### Relationships & Data Flow
- Browser loads index.html, requests the JS bundle from the Vite dev server (or static host in prod).
- main.tsx mounts the App component into the DOM.
- App renders child components and passes state/handlers via props.
- Components import constants and utils for business logic.
- User actions in Control/Register/Wheel flow up via callbacks to App, which updates state and triggers re-render.
- Result component displays outcomes; Advert may fetch or display static promotions.

##### Architectural Patterns & Design Principles
- Single-Page Application (SPA) pattern
- Unidirectional data flow (React props/state)
- Modular component structure (one file per component)
- Separation of concerns:
- Presentation (components + CSS)
- Logic (utils, constants)
- Build config (Vite, ESLint, TS config)

6. Assets (public/assets, src/assets) as resources loaded by components.
7. Data flow: User → Control/ Register → App state → Wheel → Result → UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Dev & Build Environment
    subgraph "Dev & Build Environment"
        Node["Node.js & npm/yarn"]:::buildtools
        Vite["Vite Dev Server"]:::buildtools
        ESLint["ESLint"]:::buildtools
        TSComp["TypeScript Compiler"]:::buildtools
        tailwind["tailwind.config.js"]:::config

        pjson["package.json"]:::config
        plock["package-lock.json"]:::config
        vitecfg["vite.config.ts"]:::config
        eslintcfg["eslint.config.js"]:::config
        tscfg["tsconfig.json"]:::config
        tscfgapp["tsconfig.app.json"]:::config
        tscfgnode["tsconfig.node.json"]:::config
    end

    %% Production Output
    subgraph "Production Bundle"
        dist["dist/"]:::output
    end

    %% Runtime in Browser
    subgraph "Browser (Runtime)" 
        index["index.html"]:::runtime
        App["React App"]:::runtime
        subgraph "Components"
            Advert["Advert"]:::component
            Control["Control"]:::component
            Register["Register"]:::component
            Wheel["Wheel"]:::component
            Result["Result"]:::component
        end
        Utils["constants.ts / utils.ts"]:::module
        AssetsPub["public/assets"]:::assets
        AssetsSrc["src/assets"]:::assets
    end

    User["User"]:::user

    %% Relationships
    Node & Vite & ESLint & TSComp & tailwind -->|builds| dist
    dist -->|serves bundle| Browser
    Vite <-->|HMR & bundle| Browser
    Browser -->|loads| index
    index -->|bootstraps via main.tsx| App
    App -->|renders| Advert
    App -->|renders| Control
    App -->|renders| Register
    App -->|renders| Wheel
    App -->|renders| Result
    Advert & Control & Register & Wheel & Result -->|use| Utils
    Advert & Control & Register & Wheel & Result -->|load| AssetsPub
    Advert & Control & Register & Wheel & Result -->|import| AssetsSrc
    User -->|interacts| Control
    User -->|interacts| Register
    User -->|interacts| Wheel
    Wheel -->|updates state| App
    App -->|updates UI| Result

    %% Click Events
    click pjson "https://github.com/svadhis/404wheel/blob/main/package.json"
    click plock "https://github.com/svadhis/404wheel/blob/main/package-lock.json"
    click vitecfg "https://github.com/svadhis/404wheel/blob/main/vite.config.ts"
    click eslintcfg "https://github.com/svadhis/404wheel/blob/main/eslint.config.js"
    click tscfg "https://github.com/svadhis/404wheel/blob/main/tsconfig.json"
    click tscfgapp "https://github.com/svadhis/404wheel/blob/main/tsconfig.app.json"
    click tscfgnode "https://github.com/svadhis/404wheel/blob/main/tsconfig.node.json"
    click tailwind "https://github.com/svadhis/404wheel/blob/main/tailwind.config.js"
    click AssetsPub "https://github.com/svadhis/404wheel/tree/main/public/assets"
    click AssetsSrc "https://github.com/svadhis/404wheel/tree/main/src/assets"
    click index "https://github.com/svadhis/404wheel/blob/main/index.html"
    click App "https://github.com/svadhis/404wheel/blob/main/src/main.tsx"
    click App "https://github.com/svadhis/404wheel/blob/main/src/App.tsx"
    click App "https://github.com/svadhis/404wheel/blob/main/src/App.css"
    click Advert "https://github.com/svadhis/404wheel/blob/main/src/Advert.tsx"
    click Control "https://github.com/svadhis/404wheel/blob/main/src/Control.tsx"
    click Register "https://github.com/svadhis/404wheel/blob/main/src/Register.tsx"
    click Wheel "https://github.com/svadhis/404wheel/blob/main/src/Wheel.tsx"
    click Result "https://github.com/svadhis/404wheel/blob/main/src/Result.tsx"
    click Utils "https://github.com/svadhis/404wheel/blob/main/src/constants.ts"
    click Utils "https://github.com/svadhis/404wheel/blob/main/src/utils.ts"

    %% Styles
    classDef buildtools fill:#cce5ff,stroke:#3399ff,color:#000
    classDef config fill:#e6e6e6,stroke:#999999,color:#000
    classDef output fill:#d1ffd6,stroke:#34a853,color:#000
    classDef runtime fill:#e0f7fa,stroke:#26a69a,color:#000
    classDef component fill:#fff3e0,stroke:#fb8c00,color:#000
    classDef module fill:#f3e5f5,stroke:#8e24aa,color:#000
    classDef assets fill:#ffe0b2,stroke:#fb8c00,color:#000
    classDef user fill:#fce4ec,stroke:#d81b60,color:#000
```
