# slmn-sh/typing-test architecture

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

- Interactive diagram: https://gitdiagram.com/slmn-sh/typing-test
- Repository: https://github.com/slmn-sh/typing-test

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React and TypeScript.
- It recreates a typing speed test (akin to Monkeytype) with configurable timers, themes, and word/sentence lists.
- It is purely client‐side, bundled via Create React App, tested locally, and deployed as static assets (e.g., GitHub Pages).

##### File structure
- Top‑level build & config:
- package.json, tsconfig.json, .prettierrc, .commitlintrc, Husky hooks, GitHub Actions workflow
- public/: static host files (index.html, manifest.json, robots.txt)
- src/: application source
- index.tsx, App.tsx – app entry point & root component
- components/ – all UI pieces (Header, Footer, CommandPallet, Result, Test)
- store/ – Flux pattern (store.ts, actions.ts, reducer.ts)
- helpers/ – pure functions for timer, test control, recording/reset
- stylesheets/ – SCSS modules and theme definitions
- wordlists/ – JSON arrays of words and sentences
- setupTests.ts – test harness

##### README for additional insights
- Describes run/build commands (npm start, npm run build)
- Explains how new themes (via SCSS variables) and wordlists (JSON files) plug into the Header component’s options.
- CI badge indicates use of GitHub Actions for linting/tests.

##### Don’t overcomplicate—break the system into these essential modules
- Entry & Bootstrapping (index.tsx → App.tsx)
- UI Layer (components/)
- Logic Layer (helpers/)
- State Layer (store/)
- Data Layer (wordlists/, themes.scss)
- Tooling (build & CI)
- Hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry & Bootstrapping
    subgraph "Entry & Bootstrapping"
        idx["index.tsx"]:::entry
        app["App.tsx"]:::entry
    end

    %% UI Layer
    subgraph "UI Layer"
        hdr["Header Component"]:::ui
        tst["Test Component"]:::ui
        res["Result Component"]:::ui
        cp["Command Palette Component"]:::ui
        ftr["Footer Component"]:::ui
    end

    %% Logic Layer
    subgraph "Logic Layer"
        startTimer["startTimer.ts"]:::logic
        recordTest["recordTest.ts"]:::logic
        resetTest["resetTest.ts"]:::logic
    end

    %% State Layer
    subgraph "State Layer"
        store["store.ts"]:::state
        actions["actions.ts"]:::state
        reducer["reducer.ts"]:::state
    end

    %% Data Layer
    subgraph "Data Layer"
        wordlists["Wordlists (JSON)"]:::data
        themes["themes.scss"]:::data
    end

    %% Build & Tooling
    subgraph "Build & Tooling"
        pkg["package.json"]:::build
        tsconf["tsconfig.json"]:::build
        prettierrc[".prettierrc"]:::build
        commitlint[".commitlintrc"]:::build
        husky["Husky Hooks"]:::build
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        gha["node.js.yml"]:::build
    end

    %% Hosting
    subgraph "Static Hosting"
        publicAssets["public/*"]:::build
    end

    %% Interactions
    User([User]) -->|interacts| idx
    idx -->|boots App| app

    app -->|renders| hdr
    app -->|renders| tst
    app -->|renders| res
    app -->|renders| cp
    app -->|renders| ftr

    hdr -->|dispatchAction| actions
    tst -->|dispatchAction| actions
    cp  -->|dispatchAction| actions

    actions --> reducer
    reducer --> store
    store -->|stateUpdate| hdr
    store -->|stateUpdate| tst
    store -->|stateUpdate| res
    store -->|stateUpdate| cp
    store -->|stateUpdate| ftr

    tst -->|startTimer| startTimer
    tst -->|recordTest| recordTest
    tst -->|resetTest| resetTest

    hdr -->|loadThemes| themes
    hdr -->|loadWordlists| wordlists

    pkg -->|build assets| publicAssets
    tsconf -->|build assets| publicAssets
    prettierrc -->|build assets| publicAssets
    commitlint -->|build assets| publicAssets
    husky -->|build assets| publicAssets

    gha -->|runs CI| pkg
    gha -->|runs CI| tsconf
    gha -->|runs CI| prettierrc
    gha -->|runs CI| commitlint
    gha -->|runs CI| husky

    publicAssets -->|hosted on| Hosting

    %% Click Events
    click idx "https://github.com/slmn-sh/typing-test/blob/main/src/index.tsx"
    click app "https://github.com/slmn-sh/typing-test/blob/main/src/App.tsx"
    click hdr "https://github.com/slmn-sh/typing-test/blob/main/src/components/Header.tsx"
    click tst "https://github.com/slmn-sh/typing-test/blob/main/src/components/Test.tsx"
    click res "https://github.com/slmn-sh/typing-test/blob/main/src/components/Result.tsx"
    click cp "https://github.com/slmn-sh/typing-test/blob/main/src/components/CommandPallet.tsx"
    click ftr "https://github.com/slmn-sh/typing-test/blob/main/src/components/Footer.tsx"
    click store "https://github.com/slmn-sh/typing-test/blob/main/src/store/store.ts"
    click actions "https://github.com/slmn-sh/typing-test/blob/main/src/store/actions.ts"
    click reducer "https://github.com/slmn-sh/typing-test/blob/main/src/store/reducer.ts"
    click startTimer "https://github.com/slmn-sh/typing-test/blob/main/src/helpers/startTimer.ts"
    click recordTest "https://github.com/slmn-sh/typing-test/blob/main/src/helpers/recordTest.ts"
    click resetTest "https://github.com/slmn-sh/typing-test/blob/main/src/helpers/resetTest.ts"
    click wordlists "https://github.com/slmn-sh/typing-test/tree/main/src/wordlists"
    click themes "https://github.com/slmn-sh/typing-test/blob/main/src/stylesheets/themes.scss"
    click pkg "https://github.com/slmn-sh/typing-test/blob/main/package.json"
    click tsconf "https://github.com/slmn-sh/typing-test/blob/main/tsconfig.json"
    click prettierrc "https://github.com/slmn-sh/typing-test/blob/main/.prettierrc"
    click commitlint "https://github.com/slmn-sh/typing-test/blob/main/.commitlintrc"
    click husky "https://github.com/slmn-sh/typing-test/tree/main/.husky/pre-commit"
    click gha "https://github.com/slmn-sh/typing-test/blob/main/.github/workflows/node.js.yml"
    click publicAssets "https://github.com/slmn-sh/typing-test/tree/main/public"

    %% Styles
    classDef entry fill:#F5F0FF,stroke:#6941C6,color:#6941C6
    classDef ui    fill:#E0F2FE,stroke:#0369A1,color:#0369A1
    classDef logic fill:#ECFDF5,stroke:#059669,color:#059669
    classDef state fill:#FFEDD5,stroke:#D97706,color:#B45309
    classDef data  fill:#FEF9C3,stroke:#CA8A04,color:#92400E
    classDef build fill:#F3F4F6,stroke:#6B7280,color:#374151
```
