# nightfuze/pytictactoe architecture

> Architecture diagram of the GitHub repository nightfuze/pytictactoe, 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/nightfuze/pytictactoe
- Repository: https://github.com/nightfuze/pytictactoe

## Overview

##### Main Components

a) User Interface Layer:
- Sub-components:
- Game Board (10x10 grid)
- Authentication Forms
- Game Controls
- Timer Display
- Move Counter

b) Game Logic Layer:
- A rectangle below the UI layer labeled "Game Logic"
- Sub-components:
- Game State Manager
- Win Condition Checker (5-in-a-row)
- Player Turn Manager
- AI Logic (for computer opponent)

c) Data Management Layer:
- Sub-components:
- User Authentication Manager
- Game State Storage
- User Data Storage (JSON)

##### Technical Details

Annotations showing:
- Python 3.8+ requirement
- Tkinter as UI framework
- JSON file storage
- SHA-256 hashing for passwords

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        GUI["GUI Layer (Tkinter)"]
        GameBoard["Game Board (10x10)"]:::ui
        AuthForms["Authentication Forms"]:::ui
        GameControls["Game Controls"]:::ui
        Timer["Timer Display"]:::ui
        MoveCounter["Move Counter"]:::ui
        
        GUI --> GameBoard
        GUI --> AuthForms
        GUI --> GameControls
        GUI --> Timer
        GUI --> MoveCounter
    end

    subgraph Logic["Game Logic Layer"]
        GameState["Game State Manager"]:::logic
        WinChecker["Win Condition Checker"]:::logic
        TurnManager["Player Turn Manager"]:::logic
        AI["AI Logic"]:::logic
        
        GameState --> WinChecker
        GameState --> TurnManager
        TurnManager --> AI
    end

    subgraph Data["Data Management Layer"]
        AuthManager["User Authentication Manager"]:::data
        StateStorage["Game State Storage"]:::data
        UserStorage["User Data Storage (JSON)"]:::data
        
        AuthManager --> UserStorage
        StateStorage --> UserStorage
    end

    subgraph GameModes["Game Modes"]
        PvP["Player vs Player"]:::mode
        PvC["Player vs Computer"]:::mode
    end

    subgraph Security["Security Components"]
        Hash["Password Hashing (SHA-256)"]:::security
    end

    UI --> Logic
    Logic --> UI
    Logic --> Data
    Data --> Logic
    UI --> |Authentication|Data
    AuthForms --> Hash
    Hash --> AuthManager
    GameState --> GameModes

    %% Click Events
    click GUI "https://github.com/nightfuze/pyTicTacToe/blob/master/main.py"
    click GameState "https://github.com/nightfuze/pyTicTacToe/blob/master/main.py"
    click AuthManager "https://github.com/nightfuze/pyTicTacToe/blob/master/main.py"
    click Hash "https://github.com/nightfuze/pyTicTacToe/blob/master/main.py"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef mode fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Logic Components"]:::logic
        L3["Data Components"]:::data
        L4["Security Components"]:::security
        L5["Game Modes"]:::mode
    end
```
