# sriramsohanbasa/reinforcement_learning architecture

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

- Interactive diagram: https://gitdiagram.com/sriramsohanbasa/reinforcement_learning
- Repository: https://github.com/sriramsohanbasa/reinforcement_learning

## Overview

##### Main Components
- Reinforcement Learning Algorithms: Separate modules or folders for A2C, Decision Transformers, Policy Gradient, DQN (found in Space Invader), PPO (Lunar_Lander_PPO), ML Agents, and diffusion examples.
- Training and Evaluation: Each experiment folder (such as Doom, Lunar_Lander_PPO, FrozenLake, etc.) exports logs, checkpoint files, video recordings, and notebooks. Represent this as the “Training & Evaluation Module.”
- Experiment Artifacts: This includes saved models, checkpoints, and training logs that are stored under directories like Decision_transformers/output, Space Invader/logs, and so on.
- Environment Interfaces: Although not built as separate services, many experiments are paired with simulation environments (e.g., Doom’s ViZDoom, Lunar Lander, FrozenLake, Space Invaders). This aspect of the design should clearly show the interaction between the algorithm implementations and the environment simulators.
- Auxiliary Components: There are support files like configuration files (e.g., config.json, args.yml), zip archives containing model weights, and notebooks that act as driver scripts. These can be highlighted as “Configuration & Data” components.

##### Relationships and Interactions
- Many submodules produce artifacts such as videos, checkpoints, and logs. Illustrate data flow from the algorithm modules to “Artifact Storage” components.
- Some modules (like Lunar_Lander_PPO) include integration with external monitoring tools (e.g., wandb). Label these interactions clearly.

##### Architectural Patterns and Design Principles
- Modularity: Each algorithm’s directory is effectively a self-contained experiment. Emphasize the modularity by grouping these components.
- Experiment Driven Approach: Although not a microservices architecture, the repository follows a pattern where multiple independent experiment modules share similar common functionalities (e.g., environment interfacing, logging). Indicate these shared elements.
- Data Flow in Training: Consider representing the “Training Pipeline” which starts with the algorithm (e.g., notebook or code) going through state evaluation on the environment and then archiving the results.

##### Relevant Technologies & Frameworks
- That the experiments are implemented in Jupyter Notebooks and Python scripts.
- For reinforcement learning algorithms, frameworks such as stable-baselines or custom PyTorch/TensorFlow code might be in use (as indicated by naming conventions and file types).
- External tools like wandb are present (for logging and monitoring training processes), and simulation frameworks like ViZDoom for Doom.

- Use clear, descriptive labels for each node/component. For example, “A2C Module,” “Decision Transformers Training,” “Space Invader DQN Experiment,” etc.

##### Detail Orientation
- Be as detailed as possible. Even though the repository is made of several independent experiment components, try to capture the essential sequence:
- Initialization/Configuration (config files, notebooks)
- RL Algorithm Execution (code modules in various directories)
- Environment Interaction (simulated environments like Doom, Lunar Lander, etc.)
- Training Artifacts and Feedback Loop (checkpoints, logs, videos, monitoring via wandb)
- Shared libraries or frameworks if inferred (e.g., PyTorch usage in Decision Transformers given “model.safetensors”, etc.).

## Diagram (Mermaid)

```mermaid
graph TD
    RL_Repo["Reinforcement Learning Repository"]:::repo

    subgraph "Configuration & Data"
        Config_Data["Configuration & Data"]:::config
    end

    RL_Repo -->|"configuration"| Config_Data

    %% Intermediate node for initialization
    Init["Algorithm Initialization"]:::algo
    Config_Data -->|"initialize"| Init

    subgraph "Algorithm Modules"
        A2C_Module["A2C Module"]:::algo
        Decision_Transformers["Decision Transformers Module"]:::algo
        Policy_Gradient["Policy Gradient Module"]:::algo
        DQN_SpaceInvader["DQN (Space Invader) Experiment"]:::algo
        Lunar_Lander_PPO["Lunar Lander PPO Module"]:::algo
        ML_Agents_Module["ML Agents Module"]:::algo
        Diffusion_Examples["Diffusion Examples"]:::algo
    end

    %% Connect initialization node to each algorithm module
    Init --> A2C_Module
    Init --> Decision_Transformers
    Init --> Policy_Gradient
    Init --> DQN_SpaceInvader
    Init --> Lunar_Lander_PPO
    Init --> ML_Agents_Module
    Init --> Diffusion_Examples

    subgraph "Environment Interfaces"
        Environment_Interaction["Environment Interaction"]:::env
        Doom_Env["Doom Environment Interface"]:::env
        FrozenLake_Env["FrozenLake Environment Interface"]:::env
    end

    Environment_Interaction --> Doom_Env
    Environment_Interaction --> FrozenLake_Env

    subgraph "Artifact Storage"
        Artifact_Storage["Artifact Storage\n(Checkpoints, Logs, Videos)"]:::artifact
    end

    %% Data flow from each algorithm module to Environment Interaction and Artifact Storage
    A2C_Module -->|"interacts"| Environment_Interaction
    A2C_Module -->|"artifacts"| Artifact_Storage

    Decision_Transformers -->|"interacts"| Environment_Interaction
    Decision_Transformers -->|"artifacts"| Artifact_Storage

    Policy_Gradient -->|"interacts"| Environment_Interaction
    Policy_Gradient -->|"artifacts"| Artifact_Storage

    DQN_SpaceInvader -->|"interacts"| Environment_Interaction
    DQN_SpaceInvader -->|"artifacts"| Artifact_Storage

    Lunar_Lander_PPO -->|"interacts"| Environment_Interaction
    Lunar_Lander_PPO -->|"artifacts"| Artifact_Storage

    ML_Agents_Module -->|"interacts"| Environment_Interaction
    ML_Agents_Module -->|"artifacts"| Artifact_Storage

    Diffusion_Examples -->|"interacts"| Environment_Interaction
    Diffusion_Examples -->|"artifacts"| Artifact_Storage

    %% Styles
    classDef repo fill:#E1F5FE,stroke:#0277BD,stroke-width:2px;
    classDef config fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px;
    classDef algo fill:#FCE4EC,stroke:#AD1457,stroke-width:2px;
    classDef env fill:#E3F2FD,stroke:#1565C0,stroke-width:2px;
    classDef artifact fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;

    %% Click Events
    click A2C_Module "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/A2C"
    click Decision_Transformers "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Decision_transformers"
    click Policy_Gradient "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Policy Gradient"
    click DQN_SpaceInvader "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Space Invader/hub/dqn-SpaceInvadersNoFrameskip-v4"
    click Lunar_Lander_PPO "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Lunar_Lander_PPO"
    click ML_Agents_Module "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/ML_Agents"
    click Diffusion_Examples "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Diffusion"
    click Doom_Env "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/Doom"
    click FrozenLake_Env "https://github.com/sriramsohanbasa/reinforcement_learning/tree/main/FrozenLake"
```
