# michaelkurowski/pure-types-snake-game architecture

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

- Interactive diagram: https://gitdiagram.com/michaelkurowski/pure-types-snake-game
- Repository: https://github.com/michaelkurowski/pure-types-snake-game

## Overview

Project Type: This is a specialized TypeScript project that implements a snake game using only type definitions, making it a unique type-level programming demonstration.

##### Type System Components
- Divide it into sub-components based on the utils directory structure:
- Arithmetic Operations (arithmetics.ts)
- Array Manipulations (arrays.ts)
- Game Board Logic (board.ts)
- Rendering System (rendering.ts)
- Type Conversions (typesConversions.ts)

##### Game State Flow
- Input Processing (WASD controls)
- Game State Types
- Board State Types
- Snake Position Types
- Food Position Types

- [Type System Engine]
- [Input Handler]
- [Game Logic]
- [Rendering System]

##### Component Relationships

Specific Instructions for Drawing:

##### Center Block (Type System Engine)
- Type evaluation flow direction (top to bottom)
- Type inference paths

##### Utility Modules (Left Side)
- Arithmetic and array manipulation types
- How they feed into the main game logic
- Type conversion utilities

##### Game Logic (Middle)
- Board state types
- Snake movement type calculations
- Food generation type logic

##### Rendering (Right Side)
- Type-level string manipulation
- Board visualization type transformations
- Output type formation

##### Input Processing (Top)
- WASD string input type parsing
- Direction type mapping
- To movement calculation types

Additional Considerations:

##### TypeScript-specific elements
- Generic type parameters
- Conditional types
- Type unions and intersections

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Type System Engine"
        TSE["Type System Core"]:::core
        click TSE "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/index.ts"
    end

    subgraph "Utility Types"
        direction TB
        ARITH["Arithmetic Operations"]:::util
        click ARITH "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/utils/arithmetics.ts"
        ARRAY["Array Manipulations"]:::util
        click ARRAY "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/utils/arrays.ts"
        CONV["Type Conversions"]:::util
        click CONV "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/utils/typesConversions.ts"
    end

    subgraph "Game Logic"
        direction TB
        BOARD["Game Board Logic"]:::game
        click BOARD "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/utils/board.ts"
        SNAKE["Snake Position Types"]:::game
        FOOD["Food Position Types"]:::game
        STATE["Game State Types"]:::game
    end

    subgraph "Input/Output"
        direction TB
        INPUT["Input Handler<br>(WASD)"]:::io
        RENDER["Rendering System"]:::io
        click RENDER "https://github.com/michaelKurowski/pure-types-snake-game/blob/main/utils/rendering.ts"
        OUTPUT["Board Visualization"]:::io
    end

    %% Connections
    INPUT --> TSE
    TSE --> BOARD
    TSE --> STATE

    ARITH --> BOARD
    ARRAY --> BOARD
    CONV --> BOARD
    CONV --> RENDER

    BOARD --> SNAKE
    BOARD --> FOOD
    SNAKE --> STATE
    FOOD --> STATE

    STATE --> RENDER
    RENDER --> OUTPUT

    %% Styles
    classDef core fill:#2d5c8f,stroke:#1a365d,color:white
    classDef util fill:#4a9c5d,stroke:#2d5c3f,color:white
    classDef game fill:#b8860b,stroke:#8b6508,color:white
    classDef io fill:#a44a4a,stroke:#8b3232,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Utility Types"]:::util
        L3["Game Logic"]:::game
        L4["Input/Output"]:::io
    end
```
