# zedr/tinycols architecture

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

- Interactive diagram: https://gitdiagram.com/zedr/tinycols
- Repository: https://github.com/zedr/tinycols

## Overview

##### Main Components Identification

The system can be broken down into these primary components:

a) Core Game Engine
- Game Logic (/include/tinycols/game.h, /src/tinycols/game.c)
- Grid Management (/include/tinycols/grid.h, /src/tinycols/grid.c)
- Piece Management (/include/tinycols/piece.h, /src/tinycols/piece.c)

b) Graphics Interface
- Terminal UI (gfx.h, gfx.c)
- NCurses Integration

c) Game State Management
- Score System (/include/tinycols/score.h)
- Queue System (queue.h, queue.c)

**[User Input Layer]**
- ↕
**[Graphics Interface (NCurses)] ←→ [Game State Manager]**
- ↕                             ↕
**[Core Game Engine] ←→ [Piece Queue Manager]**
- ↙     ↓     ↘

##### Specific Implementation Details

Technical aspects in subsections:
- NCurses as the primary display interface
- Game loop structure
- Piece movement and rotation system
- Score tracking mechanism

##### Implementation Notes

**[Component Name]**
- Key Functions
- Dependencies
- File References

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#2374ab,color:white
    classDef interface fill:#48a9a6,color:white
    classDef state fill:#e4cc37,color:black
    classDef utility fill:#89909f,color:white
    classDef future fill:none,stroke-dasharray: 5 5

    %% User Input Layer
    UserInput["User Input Layer"]:::interface

    %% Graphics Interface Layer
    subgraph Graphics
        GFX["Graphics Interface (NCurses)"]:::interface
    end

    %% Game State Layer
    subgraph GameState
        StateManager["Game State Manager"]:::state
        Score["Score System"]:::state
    end

    %% Core Game Engine Layer
    subgraph CoreEngine
        GameLogic["Game Logic"]:::core
        GameUtils["Game Utils"]:::core
        Direction["Direction Handler"]:::core
    end

    %% Game Components Layer
    subgraph Components
        Grid["Grid Management"]:::core
        Piece["Piece Management"]:::core
        Color["Color System"]:::core
        Queue["Piece Queue Manager"]:::utility
    end

    %% Future Features
    Multiplayer["Multiplayer Mode"]:::future
    AI["AI System"]:::future

    %% Relationships
    UserInput --> GFX
    GFX <--> StateManager
    StateManager --> Score
    StateManager <--> GameLogic
    GameLogic --> GameUtils
    GameLogic --> Direction
    GameLogic <--> Grid
    GameLogic <--> Piece
    GameLogic <--> Color
    GameLogic <--> Queue

    %% Future Connections
    GameLogic -.-> Multiplayer
    GameLogic -.-> AI

    %% Click Events
    click GameLogic "https://github.com/zedr/tinycols/blob/main//include/tinycols/game.h"
    click GameUtils "https://github.com/zedr/tinycols/blob/main//include/tinycols/game_utils.h"
    click Grid "https://github.com/zedr/tinycols/blob/main//include/tinycols/grid.h"
    click Piece "https://github.com/zedr/tinycols/blob/main//include/tinycols/piece.h"
    click Color "https://github.com/zedr/tinycols/blob/main//include/tinycols/color.h"
    click GFX "https://github.com/zedr/tinycols/blob/main//include/gfx.h"
    click Score "https://github.com/zedr/tinycols/blob/main//include/tinycols/score.h"
    click Queue "https://github.com/zedr/tinycols/blob/main//include/queue.h"
    click Direction "https://github.com/zedr/tinycols/blob/main//include/tinycols/direction.h"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Interface Components"]:::interface
        L3["State Components"]:::state
        L4["Utility Components"]:::utility
        L5["Future Features"]:::future
    end
```
