# nonkloq/mazeharvest architecture

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

- Interactive diagram: https://gitdiagram.com/nonkloq/mazeharvest
- Repository: https://github.com/nonkloq/mazeharvest

## Overview

##### Component Relationships

A. Primary Flow:
- Environment Layer → Algorithm Layer → Utilities Layer

B. Detailed Component Interactions:
1. Environment Components:
- Board ↔ Environment Objects
- Resource Manager → Board
- Environment → Gymnasium Interface

2. Algorithm Components:
- PPO: Brain → PPO Core → Training Loop
- RDQN: QNet → RDQN Core → Replay Buffer
- Shared utilities between algorithms

##### Implementation Details

- Class hierarchies
- Component dependencies
- Data flow between modules

##### Technical Stack Indicators

- PyTorch
- Gymnasium
- Python
- Testing frameworks

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef env fill:#d0e1f9,stroke:#333
    classDef algo fill:#d4edda,stroke:#333
    classDef util fill:#fff3cd,stroke:#333
    classDef interface fill:#f8d7da,stroke:#333

    subgraph Environment
        MazeEnv["MazeHarvest Environment"]:::env
        Board["Board Component"]:::env
        EnvObjs["Environment Objects"]:::env
        ResMan["Resource Manager"]:::env
        GymInterface["Gymnasium Interface"]:::interface

        MazeEnv --> Board
        MazeEnv --> EnvObjs
        MazeEnv --> ResMan
        Board <--> EnvObjs
        ResMan --> Board
        MazeEnv --> GymInterface
    end

    subgraph Algorithms
        subgraph PPO
            PPOBrain["PPO Brain"]:::algo
            PPOCore["PPO Core"]:::algo
            PPOTrain["PPO Training Loop"]:::algo

            PPOBrain --> PPOCore
            PPOCore --> PPOTrain
        end

        subgraph RDQN
            RDQNNet["RDQN QNet"]:::algo
            RDQNCore["RDQN Core"]:::algo
            ReplayBuf["Replay Buffer"]:::algo

            RDQNNet --> RDQNCore
            RDQNCore <--> ReplayBuf
        end
    end

    subgraph Utilities
        TrainUtils["Training Utilities"]:::util
        EnvInteract["Environment Interaction"]:::util
        RecordSys["Recording System"]:::util
        Scheduler["Scheduler Components"]:::util

        TrainUtils --> EnvInteract
        TrainUtils --> RecordSys
        TrainUtils --> Scheduler
    end

    %% Cross-component relationships
    MazeEnv --> PPO
    MazeEnv --> RDQN
    PPO --> TrainUtils
    RDQN --> TrainUtils

    %% Click events for component mapping
    click MazeEnv "https://github.com/nonkloq/mazeharvest/blob/main/homegym/homegym/mazeharvest.py"
    click Board "https://github.com/nonkloq/mazeharvest/blob/main/homegym/homegym/board.py"
    click EnvObjs "https://github.com/nonkloq/mazeharvest/blob/main/homegym/homegym/envobjs.py"
    click ResMan "https://github.com/nonkloq/mazeharvest/blob/main/homegym/homegym/_rman.py"
    click PPOBrain "https://github.com/nonkloq/mazeharvest/blob/main/experiments/algos/ppo/brain.py"
    click PPOCore "https://github.com/nonkloq/mazeharvest/blob/main/experiments/algos/ppo/ppo.py"
    click RDQNNet "https://github.com/nonkloq/mazeharvest/blob/main/experiments/algos/rdqn/qnet.py"
    click RDQNCore "https://github.com/nonkloq/mazeharvest/blob/main/experiments/algos/rdqn/rdqn.py"
    click ReplayBuf "https://github.com/nonkloq/mazeharvest/blob/main/experiments/algos/rdqn/replaybuffer.py"
    click TrainUtils "https://github.com/nonkloq/mazeharvest/tree/main/experiments/eutils/"
    click RecordSys "https://github.com/nonkloq/mazeharvest/blob/main/experiments/eutils/record.py"
    click Scheduler "https://github.com/nonkloq/mazeharvest/blob/main/experiments/eutils/schedulers.py"
    click EnvInteract "https://github.com/nonkloq/mazeharvest/blob/main/experiments/eutils/play_env.py"

    %% Legend
    subgraph Legend
        L1["Environment Components"]:::env
        L2["Algorithm Components"]:::algo
        L3["Utility Components"]:::util
        L4["External Interfaces"]:::interface
    end
```
