# pxpatel/wordle architecture

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

- Interactive diagram: https://gitdiagram.com/pxpatel/wordle
- Repository: https://github.com/pxpatel/wordle

## Overview

##### Project type and purpose
- No dedicated backend or API; it’s purely client-side, using localStorage for persistence and Tailwind CSS for styling.

##### File structure
- Top-level config and metadata:
- package.json, package-lock.json (npm dependencies)
- .eslintrc.json, prettier.config.cjs, tailwind.config.js (lint & style)
- public/ (static assets: index.html, manifest.json, robots.txt)
- Source code in src/:
- index.js → React root, injects App into public/index.html
- App.js + App.css → overall layout & tailwind import
- hooks/ → custom React hooks (dark mode, autofocus, localStorage state, saved game state)
- util/ → pure logic modules (base game logic, constants, React context for game state)

##### Extract additional insights from README
- It’s a blank Create React App template with standard scripts (start, build, test, eject).
- No mention of backend endpoints or microservices.
- Intends to be further customized/extended by the developer.

##### Main components
a. User’s Browser / Client
b. Static Asset Server (hosting the built bundle + public assets)
c. Create React App Build Process (Webpack/Babel → bundle.js + CSS)
d. React Application run‐time components:
- EntryPoint (index.html, index.js)
- App Container (App.js + Tailwind CSS)
- State Management:
- React Context (gameContext)
- Custom Hooks (useLocalStorage, useSavedGameState, useDarkMode, useAutoFocus)
- Utility Modules (base logic, constants)
e. Persistence/Browser APIs: LocalStorage, Document Title, Dark Mode flag
f. Developer Tooling / Workflow (ESLint, Prettier, Tailwind config, Codespaces devcontainer)

##### Relationships & interactions
- Browser requests index.html → served by Static Server
- index.js bootstraps React into the DOM
- App renders UI components; components dispatch actions into Context/hooks → util logic → update state
- Hooks update/persist to localStorage and trigger re-renders
- Tailwind CSS classes applied at build time; PostCSS in CRA optimizes styles
- npm scripts (start → dev server, build → optimized bundle) feed into Static Server

##### Key architectural patterns & design principles
- Component-based UI (React)
- Unidirectional data flow via Context + Hooks
- Separation of concerns:
- Presentation (components)
- State management (hooks & context)
- Business logic (util modules)
- Configuration (ESLint, Prettier, Tailwind)
- Client-only architecture with local persistence

- All major components: Browser, Static Server, Build Process, React runtime, Hooks/Context, Util modules, LocalStorage

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    subgraph "Developer Environment"
        DC["DevContainer (.devcontainer/devcontainer.json)"]:::config
        ESL["ESLint (.eslintrc.json)"]:::config
        PTR["Prettier (prettier.config.cjs)"]:::config
        TWC["Tailwind Config (tailwind.config.js)"]:::config
        PKG["package.json (npm scripts)"]:::config
    end

    %% Build Process
    subgraph "Build Process"
        SRC["Source Code (src/)"]:::code
        BLD["Webpack/Babel"]:::build
        BND["Bundle (bundle.js + CSS)"]:::build
    end

    %% Asset Hosting
    subgraph "Asset Hosting"
        PA["Public Assets (public/)"]:::infra
        SS["Static Asset Server"]:::infra
    end

    %% Browser
    BR["User Browser"]:::external

    %% Runtime
    subgraph "Application Runtime"
        IE["index.html"]:::runtime
        IR["Bootstrap (src/index.js)"]:::runtime
        AP["App Container (src/App.js + src/App.css)"]:::runtime

        subgraph "UI Components"
            NB["NavBar"]:::runtime
            GM["Game"]:::runtime
            RW["Row"]:::runtime
            BX["Box"]:::runtime
            KB["Keyboard"]:::runtime
            MD["Modal"]:::runtime
        end

        subgraph "State Management"
            GC["Game Context (src/util/gameContext.js)"]:::runtime
            DM["useDarkMode"]:::runtime
            AF["useAutoFocus"]:::runtime
            LS["useLocalStorage"]:::runtime
            SG["useSavedGameState"]:::runtime
        end

        subgraph "Business Logic & Constants"
            BL["base.js"]:::runtime
            CT["constants.js"]:::runtime
        end

        LSAPI["localStorage API"]:::external
    end

    %% Workflow Connections
    DC --> PKG
    ESL --> PKG
    PTR --> PKG
    TWC --> PKG

    PKG --> SRC
    SRC --> BLD
    BLD --> BND
    BND --> SS
    PA --> SS
    SS --> BR

    BR --> IE
    IE --> IR
    IR --> AP

    AP --> NB
    AP --> GM
    AP --> RW
    AP --> BX
    AP --> KB
    AP --> MD

    GM --> RW
    RW --> BX

    NB --> GC
    GM --> GC
    RW --> GC
    BX --> GC
    KB --> GC
    MD --> GC

    GC --> BL
    GC --> CT

    NB --> DM
    GM --> AF
    GC --> LS
    GM --> SG

    LS --> LSAPI
    SG --> LSAPI

    %% Click Events
    click IE "https://github.com/pxpatel/wordle/blob/main/public/index.html"
    click IR "https://github.com/pxpatel/wordle/blob/main/src/index.js"
    click AP "https://github.com/pxpatel/wordle/blob/main/src/App.js"
    click AP "https://github.com/pxpatel/wordle/blob/main/src/App.css"
    click NB "https://github.com/pxpatel/wordle/blob/main/src/components/NavBar.jsx"
    click GM "https://github.com/pxpatel/wordle/blob/main/src/components/Game.jsx"
    click RW "https://github.com/pxpatel/wordle/blob/main/src/components/Row.jsx"
    click BX "https://github.com/pxpatel/wordle/blob/main/src/components/Box.jsx"
    click KB "https://github.com/pxpatel/wordle/blob/main/src/components/Keyboard.jsx"
    click MD "https://github.com/pxpatel/wordle/blob/main/src/components/Modal.jsx"
    click GC "https://github.com/pxpatel/wordle/blob/main/src/util/gameContext.js"
    click DM "https://github.com/pxpatel/wordle/blob/main/src/hooks/useDarkMode.js"
    click AF "https://github.com/pxpatel/wordle/blob/main/src/hooks/useAutoFocus.js"
    click LS "https://github.com/pxpatel/wordle/blob/main/src/hooks/useLocalStorage.js"
    click SG "https://github.com/pxpatel/wordle/blob/main/src/hooks/useSavedGameState.js"
    click BL "https://github.com/pxpatel/wordle/blob/main/src/util/base.js"
    click CT "https://github.com/pxpatel/wordle/blob/main/src/util/constants.js"
    click TWC "https://github.com/pxpatel/wordle/blob/main/tailwind.config.js"
    click SRC "https://github.com/pxpatel/wordle/tree/main/src/"
    click PA "https://github.com/pxpatel/wordle/tree/main/public/"
    click DC "https://github.com/pxpatel/wordle/blob/main/.devcontainer/devcontainer.json"
    click ESL "https://github.com/pxpatel/wordle/blob/main/.eslintrc.json"
    click PTR "https://github.com/pxpatel/wordle/blob/main/prettier.config.cjs"
    click PKG "https://github.com/pxpatel/wordle/blob/main/package.json"

    %% Styles
    classDef config fill:#dfffd6,stroke:#8fbc8f,stroke-width:1px
    classDef code fill:#f0f0f0,stroke:#cccccc,stroke-width:1px
    classDef build fill:#ffe4b3,stroke:#d2a679,stroke-width:1px
    classDef infra fill:#e0f0ff,stroke:#7fbfff,stroke-width:1px
    classDef runtime fill:#cce5ff,stroke:#6699cc,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#aaaaaa,stroke-width:1px
```
