# pausebreak/darts architecture

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

- Interactive diagram: https://gitdiagram.com/pausebreak/darts
- Repository: https://github.com/pausebreak/darts

## Overview

##### Main Components Layer
- Inside this container, create these major sections:

##### UI Components Layer (React)
- Root Component
- Main Game Components:
- App
- GameChooser
- Players
- GameInfo
- PostGame
- Game Variants:
- Cricket
- ScoreBoard
- TouchScoreBoard
- Use rounded rectangles for components

##### State Management Layer
- Connections to:
- Game Logic (/games directory)
- Sound System
- State Subscribers

##### Game Logic Layer
- Bulls
- Cricket
- CutThroat
- Oh1
- Tactical

##### Supporting Systems
- Sound System:
- Connection to browser's speechSynthesis
- Audio files integration
- Touch Input System
- State Machine

- Blue: React Components
- Green: State Management
- Yellow: Game Logic
- Purple: Supporting Systems
- Red: External Systems (Browser APIs)

Important Elements to Include:
- State updates from games to store
- UI component subscriptions to state
- User input flow
- Sound trigger flow

##### Special Notations
- Test coverage areas
- Subscriber patterns
- Touch input zones

##### External Dependencies
- Zustand
- Parcel
- Browser APIs (speechSynthesis)

Key Architectural Patterns to Highlight:
##### State Management
- Centralized Zustand store
- Subscriber pattern for updates
- Immutable state updates

##### Component Architecture
- Hierarchical component structure
- Game variant isolation
- Touch-optimized interface

##### Testing Boundaries
- Game logic test coverage
- Component test areas

Keep in mind the project's design criteria:
- Touch target areas
- UI element visibility zones
- Stable UI regions

- Component types
- Data flow patterns
- State management connections
- Testing coverage indicators

Remember to include notes about the future additions mentioned in the README:
- Technical cricket variant (planned)
- Stats system (planned)
- Visual design improvements (pending)

This will give other developers a clear understanding of both the current system and its planned evolution.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend["Frontend Application (Parcel Bundle)"]
        subgraph UI["UI Components Layer"]
            Root["Root Component"]:::react
            App["App"]:::react
            GameChooser["Game Chooser"]:::react
            Players["Players"]:::react
            GameInfo["Game Info"]:::react
            PostGame["Post Game"]:::react
            
            subgraph GameVariantsUI["Game Variants UI"]
                CricketUI["Cricket UI"]:::react
                ScoreBoard["Score Board"]:::react
                TouchScoreBoard["Touch Score Board"]:::react
            end
            
            Root --> App
            App --> GameChooser
            App --> Players
            App --> GameInfo
            App --> PostGame
            App --> GameVariantsUI
        end

        subgraph State["State Management Layer"]
            Store["Zustand Store"]:::state
            Types["Types Definition"]:::state
            StoreMock["Store Mock"]:::state
            Subscribers["State Subscribers"]:::state
        end

        subgraph Logic["Game Logic Layer"]
            Bulls["Bulls"]:::logic
            Cricket["Cricket"]:::logic
            CutThroat["Cut Throat"]:::logic
            Oh1["Oh1"]:::logic
            Tactical["Tactical"]:::logic
        end

        subgraph Support["Supporting Systems"]
            Sound["Sound System"]:::support
            TouchInput["Touch Input System"]:::support
            StateMachine["State Machine"]:::support
        end
    end

    subgraph External["External Systems"]
        SpeechAPI["Browser Speech API"]:::external
        AudioFiles["Audio Files"]:::external
    end

    %% Connections
    Store <--> Logic
    Store --> UI
    TouchInput --> Store
    Sound --> SpeechAPI
    Sound --> AudioFiles
    Subscribers --> Store
    StateMachine --> Store

    %% Click Events
    click Root "https://github.com/pausebreak/darts/blob/main/src/components/Root.tsx"
    click App "https://github.com/pausebreak/darts/blob/main/src/components/App.tsx"
    click GameChooser "https://github.com/pausebreak/darts/blob/main/src/components/GameChooser.tsx"
    click Players "https://github.com/pausebreak/darts/blob/main/src/components/Players.tsx"
    click GameInfo "https://github.com/pausebreak/darts/blob/main/src/components/GameInfo.tsx"
    click PostGame "https://github.com/pausebreak/darts/blob/main/src/components/PostGame.tsx"
    click CricketUI "https://github.com/pausebreak/darts/blob/main/src/components/games/Cricket.tsx"
    click ScoreBoard "https://github.com/pausebreak/darts/blob/main/src/components/games/ScoreBoard.tsx"
    click TouchScoreBoard "https://github.com/pausebreak/darts/blob/main/src/components/games/TouchScoreBoard.tsx"
    click Bulls "https://github.com/pausebreak/darts/blob/main/src/games/bulls.ts"
    click Cricket "https://github.com/pausebreak/darts/blob/main/src/games/cricket.ts"
    click CutThroat "https://github.com/pausebreak/darts/blob/main/src/games/cutThroat.ts"
    click Oh1 "https://github.com/pausebreak/darts/blob/main/src/games/oh1.ts"
    click Tactical "https://github.com/pausebreak/darts/blob/main/src/games/tactical.ts"
    click Sound "https://github.com/pausebreak/darts/blob/main/src/sound.ts"
    click TouchInput "https://github.com/pausebreak/darts/blob/main/src/components/TouchInput.tsx"
    click StateMachine "https://github.com/pausebreak/darts/blob/main/src/machine.ts"
    click Subscribers "https://github.com/pausebreak/darts/blob/main/src/subscribers.ts"
    click StoreMock "https://github.com/pausebreak/darts/blob/main/__mocks__/zustand.ts"
    click Types "https://github.com/pausebreak/darts/blob/main/src/types.ts"

    %% Styles
    classDef react fill:#61DAFB,stroke:#000000
    classDef state fill:#88D1F1,stroke:#000000
    classDef logic fill:#FFD700,stroke:#000000
    classDef support fill:#DDA0DD,stroke:#000000
    classDef external fill:#FF6B6B,stroke:#000000

    %% Legend
    subgraph Legend
        React["React Component"]:::react
        StateManagement["State Management"]:::state
        GameLogic["Game Logic"]:::logic
        SupportSystem["Support System"]:::support
        ExternalSystem["External System"]:::external
    end
```
