# xinzelee/pe-gpt architecture

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

- Interactive diagram: https://gitdiagram.com/xinzelee/pe-gpt
- Repository: https://github.com/xinzelee/pe-gpt

## Overview

##### Project Type and Purpose
- PE-GPT is a specialized full-stack application focused on power electronics (PE) design. It integrates a multimodal large language model (LLM) with a retrieval augmented generation (RAG) mechanism, custom PE knowledge bases, a model zoo featuring physics-informed neural networks (specifically for DAB converter modeling), simulation integration (with Plecs), and metaheuristic optimization.
- The README emphasizes its role in assisting diverse power electronics design tasks, combining LLM agents with simulation and optimization tools.

##### Analyzing the File Structure
- Top-Level Files/Folders:
- main.py: the entry point for launching the graphical user interface.
- requirements.txt and requirements_specific.txt: dependencies.
- LICENSE and README.md: project documentation and legal info.
- Core Directory Breakdown (core):
- gui/: Contains the graphical user interface components (gui.py, design_stages.py) that facilitate user interaction.
- knowledge/: Manages the domain-specific knowledge including KB (databases, introduction, prompts, train_data). This is key to the RAG functionality.
- llm/: Holds the LLM modules (llm.py, custom_responses.py) which interface with OpenAI models according to the instructions for deployment.
- model_zoo/: Contains pre-defined models (JSON and ONNX files, PANN related code) along with training scripts, representing the neural network elements tailored for PE simulation and design.
- optim/: Holds objective functions, optimizers and metrics which are likely used for metaheuristic algorithm integration.
- simulation/: Houses simulation files (including Plecs models and XML definitions in devices). It also includes scripts to load/synchronize simulations.
- utils/: Utility functions (e.g., for plotting, specific PANNe (PE Neural Network) utilities).
- Additional Directories:
- tutorial/: Provides a tutorial notebook that demonstrates a sample usage of PE-GPT.

##### Extracting Insights from the README
- It highlights various blocks such as Retrieval Augmented Generation, LLM agents, Model Zoo for PE-specific neural networks, metaheuristic optimization, simulation verification, and an interactive GUI.
- Deployment instructions hint at integration with external simulation software (Plecs) and interaction with external APIs (OpenAI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "PE-GPT Framework"
        %% GUI Layer
        subgraph "GUI Layer"
            GUI["Graphical User Interface"]:::frontend
            GUI_main["main.py"]:::file
            GUI_file["core/gui/gui.py"]:::file
            GUI_design["core/gui/design_stages.py"]:::file
        end

        %% Core Processing Modules
        subgraph "Core Processing"
            LLM["LLM Module (core/llm)"]:::core
            Knowledge["PE Knowledge (core/knowledge)"]:::database
            ModelZoo["Model Zoo (core/model_zoo)"]:::core
            Optimization["Optimization (core/optim)"]:::core
            Simulation["Simulation & Verification (core/simulation)"]:::simulation
            Utilities["Utilities & Support (core/utils)"]:::utility
        end

        %% External Services
        subgraph "External Services"
            OpenAI["OpenAI_API"]:::external
            Plecs["Plecs_Simulation"]:::external
        end
    end

    %% Data Flow Arrows
    GUI -->|"user_input"| LLM
    LLM -->|"data_request"| Knowledge
    LLM -->|"model_interaction"| ModelZoo
    ModelZoo -->|"provide_models"| Optimization
    Optimization -->|"simulation_request"| Simulation
    Simulation -->|"feedback"| LLM
    Simulation -->|"validation"| Optimization
    LLM -->|"external_call"| OpenAI
    Simulation -->|"simulation_run"| Plecs

    %% Styles
    classDef frontend fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
    classDef file fill:#f5cba7,stroke:#af7ac5,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef database fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef simulation fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef utility fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef external fill:#eee,stroke:#555,stroke-width:2px,stroke-dasharray: 5 5;

    %% Click Events
    click GUI_main "https://github.com/xinzelee/pe-gpt/blob/main/main.py"
    click GUI_file "https://github.com/xinzelee/pe-gpt/blob/main/core/gui/gui.py"
    click GUI_design "https://github.com/xinzelee/pe-gpt/blob/main/core/gui/design_stages.py"
    click Knowledge "https://github.com/xinzelee/pe-gpt/tree/main/core/knowledge"
    click LLM "https://github.com/xinzelee/pe-gpt/tree/main/core/llm"
    click ModelZoo "https://github.com/xinzelee/pe-gpt/tree/main/core/model_zoo"
    click Optimization "https://github.com/xinzelee/pe-gpt/tree/main/core/optim"
    click Simulation "https://github.com/xinzelee/pe-gpt/tree/main/core/simulation"
    click Utilities "https://github.com/xinzelee/pe-gpt/tree/main/core/utils"
```
