# royaltyprogram/simlab_generator architecture

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

- Interactive diagram: https://gitdiagram.com/royaltyprogram/simlab_generator
- Repository: https://github.com/royaltyprogram/simlab_generator

## Overview

##### Main Components

a) Frontend Layer:
- Streamlit GUI (innovate_gui.py)
- User Input Components
- Visualization Components
- Configuration Interface

b) Core Processing Layer:
- Main Processing Engine (time_to_innovate.py)
- API Integration Layer (api_calls.py)

c) External Services:
- OpenAI API Services
- Anthropic API Services
- Qwen AI Models Integration

- [User Layer]
- ↓
**[Frontend Layer (Streamlit)] ←→ [Session Management]**
- ↓                          ↓
**[Core Processing Layer] ←→ [API Integration Layer]**
- ↓                          ↓
**[External AI Services Layer]    [Data Storage]**

##### Component Details

Frontend Layer (Blue):
- Components for:
- API key input
- Simulation prompt input
- Progress indicators
- Results display
- Interactive controls

Core Processing Layer (Green):
- Code Generation (Claude-3.5-sonnet)
- Final Review (Claude-3.5-sonnet)

API Integration Layer (Yellow):
- Connections to:
- OpenAI API
- Anthropic API
- Qwen AI Models

##### Data Flow Indicators

- User input → Frontend
- Frontend → Core Processing
- Core Processing → API Integration
- API Integration → External Services
- Results → Frontend

##### Additional Elements

- Version information for key dependencies
- System requirements
- Notes about scaling considerations

##### Technical Details

- Python 3.x requirement
- Streamlit v1.40.2
- OpenAI v1.56.0
- Required API keys and configurations
- Main file dependencies

This system design should effectively communicate both the high-level architecture and the detailed workflow of the SIMLAB_GENERATOR project, making it easy for other developers to understand and contribute to the system.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef api fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white
    classDef storage fill:#34495e,stroke:#2c3e50,color:white

    %% User Layer
    User((User))

    %% Frontend Layer
    subgraph Frontend
        GUI["Streamlit GUI"]
        InputComp["User Input Components"]
        VisComp["Visualization Components"]
        ConfigInt["Configuration Interface"]
    end

    %% Core Processing Layer
    subgraph CoreProcessing
        MainEngine["Main Processing Engine"]
        subgraph ProcessPhases
            Research["Research Phase<br/>(Qwen2.5-72B-Instruct)"]
            CodeGen["Code Generation<br/>(Claude-3.5-sonnet)"]
            CodeRef["Code Refinement<br/>(Qwen2.5-Coder-32B)"]
            FinalRev["Final Review<br/>(Claude-3.5-sonnet)"]
        end
    end

    %% API Integration Layer
    subgraph APIIntegration
        APILayer["API Integration Layer"]
    end

    %% External Services
    subgraph ExternalServices
        OpenAI["OpenAI API"]
        Anthropic["Anthropic API"]
        QwenAI["Qwen AI Models"]
    end

    %% Data Storage
    DB[(Session Storage)]

    %% Error Handling
    ErrorHandler["Error Handler"]:::error

    %% Relationships
    User --> GUI
    GUI --> InputComp
    GUI --> VisComp
    GUI --> ConfigInt
    
    InputComp --> MainEngine
    MainEngine --> Research
    Research --> CodeGen
    CodeGen --> CodeRef
    CodeRef --> FinalRev
    
    MainEngine --> APILayer
    APILayer --> OpenAI
    APILayer --> Anthropic
    APILayer --> QwenAI
    
    MainEngine --> ErrorHandler
    ErrorHandler --> GUI
    
    GUI --> DB
    MainEngine --> DB

    %% Component Mappings
    click GUI "https://github.com/Royaltyprogram/SimLab_Generator/blob/main/main/innovate_gui.py"
    click MainEngine "https://github.com/Royaltyprogram/SimLab_Generator/blob/main/main/time_to_innovate.py"
    click APILayer "https://github.com/Royaltyprogram/SimLab_Generator/blob/main/main/api_calls.py"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Core_L["Core Processing"]:::core
        API_L["API Integration"]:::api
        External_L["External Services"]:::external
        Error_L["Error Handling"]:::error
        Storage_L["Storage"]:::storage
    end

    %% Apply Classes
    class GUI,InputComp,VisComp,ConfigInt frontend
    class MainEngine,Research,CodeGen,CodeRef,FinalRev core
    class APILayer api
    class OpenAI,Anthropic,QwenAI external
    class DB storage
```
