# ailiveco/local-trainings architecture

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

- Interactive diagram: https://gitdiagram.com/ailiveco/local-trainings
- Repository: https://github.com/ailiveco/local-trainings

## Overview

##### Main Components

a) Local Training Environment
- PPO Agent (Stable-Baselines3)
- Gym Environment (Humanoid-v5)
- TensorBoard Logger
- Local Storage System

b) Cloud Infrastructure
- Remote Storage Server
- Pre-signed URL Service
- API Authentication Layer

##### Component Relationships

- Logging: PPO Agent → TensorBoard Logger
- Model Saving: PPO Agent → Local Storage
- Cloud Upload: Local Storage → Remote Storage Server
- Authentication: Local Training Environment ↔ API Authentication Layer

##### Specific Implementation Details

- Green for active training components (PPO Agent, Gym Environment)
- Blue for storage components (Local Storage, Remote Storage)
- Yellow for monitoring components (TensorBoard)
- Red for security components (API Authentication)

##### Key Processes

a) Training Loop:
- Initialize PPO → Load Latest Model (if exists) → Train → Save Checkpoint → Upload to Cloud

b) Model Management:
- Save Model → Get Presigned URL → Upload Model → Confirm Upload

##### Technical Specifications

Annotations showing:
- Python 3.7+ runtime
- Stable-Baselines3 framework
- PPO algorithm configuration
- Save interval (500,000 steps)
- Total timesteps (10M)

##### Session Management

Session directory structure:
**Sessions/**
- Agent_Name/
- Skill_Name/
- Tensorboard/
- Models/

##### The model versioning and recovery system

This will give other engineers a clear understanding of both the system's architecture and its operational flow.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Containers
    subgraph Local["Local Training Environment"]
        PPO["PPO Agent (SB3)"]:::training
        GYM["Gym Environment<br/>(Humanoid-v5)"]:::training
        TB["TensorBoard<br/>Logger"]:::monitoring
        LS["Local Storage<br/>System"]:::storage
        
        %% Training Loop
        PPO --> |"Actions"| GYM
        GYM --> |"States/Rewards"| PPO
        PPO --> |"Metrics"| TB
        PPO --> |"Save Checkpoints"| LS
    end

    subgraph Cloud["Cloud Infrastructure"]
        RSS["Remote Storage<br/>Server"]:::storage
        URL["Pre-signed URL<br/>Service"]:::service
        AUTH["API Authentication<br/>Layer"]:::security
    end

    %% Cross-System Connections
    LS --> |"Request Upload"| AUTH
    AUTH --> |"Validate"| URL
    URL --> |"Provide URL"| LS
    LS --> |"Upload Model"| RSS

    %% Session Directory Structure
    subgraph Sessions["Session Management"]
        direction TB
        AG["Agent_Name/"]
        SK["Skill_Name/"]
        MD["Models/"]
        TBD["Tensorboard/"]
        
        AG --> SK
        SK --> MD
        SK --> TBD
    end

    %% Technical Specifications
    subgraph Specs["Technical Specifications"]
        direction TB
        SP1["Python 3.7+"]
        SP2["Save Interval:<br/>500K steps"]
        SP3["Total Steps:<br/>10M"]
    end

    %% Click Events
    click PPO "https://github.com/ailiveco/local-trainings/blob/main/main.py"
    click Specs "https://github.com/ailiveco/local-trainings/blob/main/requirements.txt"
    click Sessions "https://github.com/ailiveco/local-trainings/blob/main/README.md"

    %% Styling
    classDef training fill:#90EE90,stroke:#333,stroke-width:2px
    classDef monitoring fill:#FFD700,stroke:#333,stroke-width:2px
    classDef storage fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef service fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Training Component"]:::training
        L2["Monitoring Component"]:::monitoring
        L3["Storage Component"]:::storage
        L4["Security Component"]:::security
        L5["Service Component"]:::service
    end
```
