# devyndamonster/idlescape architecture

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

- Interactive diagram: https://gitdiagram.com/devyndamonster/idlescape
- Repository: https://github.com/devyndamonster/idlescape

## Overview

##### And Group the Main Components
- Entry Point & Bootstrapping:
- Index.html and src/main.tsx as the initial entry points that bootstrap the React application.
- Central App component (src/App.tsx) which ties together the UI and game state.

- UI Layer:
▸ Game UI Components (in src/components/game):
- Components like characterDialog.tsx, gameSideBar.tsx, scrollableMap.tsx, and world.tsx.
▸ General UI Components (in src/components/ui):
- Button.tsx, collapsible.tsx, dialog.tsx, input.tsx, label.tsx, progress.tsx, select.tsx, separator.tsx, sheet.tsx, sidebar.tsx, skeleton.tsx, table.tsx, and tooltip.tsx.
- These components represent the visual and interactive aspects of Idlescape.

- Business Logic & Game Mechanics:
- Logic files under src/game:
- GameLogic.ts – drives core game mechanics.
- ActorLogic.ts – likely managing game character behaviors.
- WorldUtils.ts – supporting functions for managing or querying the game world.
- GameStateRepository.ts at the top-level src, which probably handles game state persistence or management.

- Data Models and Enums:
- The “src/enums” folder contains definitions such as ActionType, BuildableType, Objective, ResourceType, and UserAction which provide constants to be used across the application.

- Supporting Libraries & Utilities:

##### Establish Relationships & Interactions
- UI components (both game-specific and general UI) with the GameStateRepository and underlying game logic – demonstrating data flow (for instance, user actions triggering changes via hooks and logic wiring).
- That GameLogic and ActorLogic access the Models and Enums to process game state transitions.

##### Architectural Patterns
- Component-based design via React: clearly show how UI components are grouped logically (game vs. generic UI).
- Separation of Concerns: separate business logic (game rules, actor behavior) from presentation (UI components).
- Data-driven state management: the presence of a GameStateRepository along with models and enums indicates a structured approach to managing game state and interactions.

##### Relevant Technologies & Frameworks
- Vite (indicated by vite.config.ts, tsconfig files) serves as the build tool.
- React with TypeScript is apparent from .tsx and .ts files.
- ESLint configuration suggests enforced coding standards.
- The project is deployed via GitHub Pages per the README, so you might want to note the deployment mechanism.

##### Final Elements
- Distinct sections for UI components (grouped by game and general UI elements), each with labeled components.
- A section for Game Logic including GameLogic, ActorLogic, and WorldUtils.
- A dedicated area for Models and Enums.
- Utility and Hook sections that support both UI and logic layers.
- Notate external dependencies such as Vite, React, and deployment via GitHub Pages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point Subgraph
    subgraph "Entry Point"
        E1("index.html"):::entry
        E2("main.tsx"):::entry
        E3("App.tsx"):::entry
    end

    E1 --> E2
    E2 --> E3

    %% UI Layer Subgraph
    subgraph "UI Layer"
        subgraph "Game UI Components"
            G1("Character Dialog"):::ui
            G2("Game SideBar"):::ui
            G3("Scrollable Map"):::ui
            G4("World View"):::ui
        end
        subgraph "General UI Components"
            U1("Button"):::ui
            U2("Collapsible"):::ui
            U3("Dialog"):::ui
            U4("Input"):::ui
            U5("Label"):::ui
            U6("Progress"):::ui
            U7("Select"):::ui
            U8("Separator"):::ui
            U9("Sheet"):::ui
            U10("Sidebar"):::ui
            U11("Skeleton"):::ui
            U12("Table"):::ui
            U13("Tooltip"):::ui
        end
    end

    %% Business Logic & Game Mechanics Subgraph
    subgraph "Business Logic & Game Mechanics"
        L1("GameLogic.ts"):::logic
        L2("ActorLogic.ts"):::logic
        L3("WorldUtils.ts"):::logic
        L4("GameStateRepository.ts"):::logic
    end

    %% Data Models & Enums Subgraph
    subgraph "Data Models & Enums"
        subgraph "Models"
            M1("Actor"):::data
            M2("ActorAction"):::data
            M3("GameData"):::data
            M4("GameState"):::data
            M5("InventoryItem"):::data
            M6("InventorySlot"):::data
            M7("Resource"):::data
            M8("Structure"):::data
            M9("WorldEntity"):::data
        end
        subgraph "Enums"
            EN1("ActionType"):::data
            EN2("BuildableType"):::data
            EN3("Objective"):::data
            EN4("ResourceType"):::data
            EN5("UserAction"):::data
        end
    end

    %% Supporting Libraries & Utilities Subgraph
    subgraph "Supporting Libraries & Utilities"
        UT1("Utility Functions"):::util
        UT2("Custom Hooks"):::util
    end

    %% External Technologies
    EX1("Vite"):::external
    EX2("React/TypeScript"):::external
    EX3("GitHub Pages"):::external

    %% Relationships
    E3 -->|"to_UI"| G1
    E3 -->|"to_UI"| U1
    E3 -->|"triggers"| L1
    E3 -->|"triggers"| L4

    G1 -->|"updates_from"| L4
    U1 -->|"updates_from"| L4

    G1 -->|"uses"| UT2
    U1 -->|"uses"| UT2

    UT1 -->|"supports"| L1
    UT1 -->|"supports"| L2

    L1 -->|"uses"| M1
    L1 -->|"uses"| EN1
    L2 -->|"uses"| M1
    L2 -->|"uses"| EN1

    L4 -->|"notifies"| G1
    L4 -->|"notifies"| U1

    EX2 -->|"powers"| E3
    EX1 -->|"builds"| E2
    EX3 -->|"deploys"| E3

    %% Styling Classes
    classDef entry fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef ui fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef logic fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef data fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef util fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;

    %% Click Events
    click E1 "https://github.com/devyndamonster/idlescape/blob/main//index.html"
    click E2 "https://github.com/devyndamonster/idlescape/blob/main//src/main.tsx"
    click E3 "https://github.com/devyndamonster/idlescape/blob/main//src/App.tsx"

    click G1 "https://github.com/devyndamonster/idlescape/blob/main//src/components/game/characterDialog.tsx"
    click G2 "https://github.com/devyndamonster/idlescape/blob/main//src/components/game/gameSideBar.tsx"
    click G3 "https://github.com/devyndamonster/idlescape/blob/main//src/components/game/scrollableMap.tsx"
    click G4 "https://github.com/devyndamonster/idlescape/blob/main//src/components/game/world.tsx"

    click U1 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/button.tsx"
    click U2 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/collapsible.tsx"
    click U3 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/dialog.tsx"
    click U4 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/input.tsx"
    click U5 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/label.tsx"
    click U6 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/progress.tsx"
    click U7 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/select.tsx"
    click U8 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/separator.tsx"
    click U9 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/sheet.tsx"
    click U10 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/sidebar.tsx"
    click U11 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/skeleton.tsx"
    click U12 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/table.tsx"
    click U13 "https://github.com/devyndamonster/idlescape/blob/main//src/components/ui/tooltip.tsx"

    click L1 "https://github.com/devyndamonster/idlescape/blob/main//src/game/GameLogic.ts"
    click L2 "https://github.com/devyndamonster/idlescape/blob/main//src/game/ActorLogic.ts"
    click L3 "https://github.com/devyndamonster/idlescape/blob/main//src/game/WorldUtils.ts"
    click L4 "https://github.com/devyndamonster/idlescape/blob/main//src/GameStateRepository.ts"

    click M1 "https://github.com/devyndamonster/idlescape/blob/main//src/models/Actor.ts"
    click M2 "https://github.com/devyndamonster/idlescape/blob/main//src/models/ActorAction.ts"
    click M3 "https://github.com/devyndamonster/idlescape/blob/main//src/models/GameData.ts"
    click M4 "https://github.com/devyndamonster/idlescape/blob/main//src/models/GameState.ts"
    click M5 "https://github.com/devyndamonster/idlescape/blob/main//src/models/InventoryItem.ts"
    click M6 "https://github.com/devyndamonster/idlescape/blob/main//src/models/InventorySlot.ts"
    click M7 "https://github.com/devyndamonster/idlescape/blob/main//src/models/Resource.ts"
    click M8 "https://github.com/devyndamonster/idlescape/blob/main//src/models/Structure.ts"
    click M9 "https://github.com/devyndamonster/idlescape/blob/main//src/models/WorldEntity.ts"

    click EN1 "https://github.com/devyndamonster/idlescape/blob/main//src/enums/ActionType.ts"
    click EN2 "https://github.com/devyndamonster/idlescape/blob/main//src/enums/BuildableType.ts"
    click EN3 "https://github.com/devyndamonster/idlescape/blob/main//src/enums/Objective.ts"
    click EN4 "https://github.com/devyndamonster/idlescape/blob/main//src/enums/ResourceType.ts"
    click EN5 "https://github.com/devyndamonster/idlescape/blob/main//src/enums/UserAction.ts"

    click UT1 "https://github.com/devyndamonster/idlescape/blob/main//src/lib/utils.ts"
    click UT2 "https://github.com/devyndamonster/idlescape/blob/main//src/hooks/use-mobile.ts"
```
