# sirus20x6/stargen architecture

> Architecture diagram of the GitHub repository sirus20x6/stargen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sirus20x6/stargen
- Repository: https://github.com/sirus20x6/stargen

## Overview

##### Main Components Identification

The system should be divided into these primary components:

a) Core Generation Engine
- Accretion simulation (accrete.cpp, accrete.h)
- Planet formation (planets.cpp, planets.h)
- Environmental calculations (enviro.cpp, enviro.h)
- Star temperature modeling (star_temps.cpp, star_temps.h)

b) Data Management
- Element data handling (elements.cpp, elements.h)
- Radius calculations (radius_tables.cpp, solid_radius_helpers.cpp, gas_radius_helpers.cpp)
- Constants and structures (const.h, structs.h)

c) Output Generators
- Handling (display.cpp, display.h)
- Multiple format exporters (HTML, JSON, CSV, SSC)

d) Performance Monitoring
- Tracy integration for profiling
- Performance metrics (PerformanceMonitor.cpp)

##### Component Relationships

**[Input Parameters] → [Core Generation Engine]**
- ↓
**[Data Management] ←→ [Star System Generation]**
- ↓
**[Performance Monitor] → [Output Generators] → [Multiple Formats]**

##### Specific Implementation Details

Key architectural elements:
- JSON dependency for data serialization
- Tracy integration for performance profiling
- File I/O systems for various output formats
- Command-line interface for parameter input

##### Flow Directions

- Input parameters → Core Engine
- Core Engine ↔ Data Management (bidirectional)
- Core Engine → Output Generators
- Performance Monitor → All Components

##### External Dependencies

In a separate section:
- nlohmann/json for JSON handling
- Tracy profiler
- CMake build system

##### Subsystem Details

- Star system generation pipeline
- Planet formation process
- Data export mechanisms
- Performance monitoring integration

This design should reflect both the current state of the system and accommodate the planned modernization efforts mentioned in the README, such as removing global variables and adding multithreading support.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        IP[Input Parameters]
    end

    subgraph "Core Generation Engine"
        AS["Accretion Simulation"]:::core
        PF["Planet Formation"]:::core
        EC["Environmental Calculations"]:::core
        ST["Star Temperature Modeling"]:::core
    end

    subgraph "Data Management"
        EH["Element Data Handling"]:::data
        RC["Radius Calculations"]:::data
        CS["Constants and Structures"]:::data
    end

    subgraph "Output Generators"
        DH["Display Handling"]:::output
        subgraph "Export Formats"
            HTML["HTML Output"]:::output
            JSON["JSON Format"]:::output
            CSV["CSV Format"]:::output
            SSC["Solstation Format"]:::output
        end
    end

    subgraph "Performance Monitoring"
        PM["Performance Metrics"]:::perf
        TI["Tracy Integration"]:::perf
    end

    subgraph "External Dependencies"
        JL["JSON Library"]:::ext
        TP["Tracy Profiler"]:::ext
    end

    %% Relationships
    IP --> AS
    AS --> PF
    PF --> EC
    EC --> ST

    EH <--> AS
    RC <--> PF
    CS <--> EC

    ST --> DH
    DH --> HTML
    DH --> JSON
    DH --> CSV
    DH --> SSC

    PM --> AS
    PM --> PF
    PM --> EC
    PM --> ST
    TI --> PM

    JL --> DH
    TP --> TI

    %% Click Events
    click AS "https://github.com/sirus20x6/stargen/blob/master/accrete.cpp"
    click PF "https://github.com/sirus20x6/stargen/blob/master/planets.cpp"
    click EC "https://github.com/sirus20x6/stargen/blob/master/enviro.cpp"
    click ST "https://github.com/sirus20x6/stargen/blob/master/star_temps.cpp"
    click EH "https://github.com/sirus20x6/stargen/blob/master/elements.cpp"
    click RC "https://github.com/sirus20x6/stargen/blob/master/radius_tables.cpp"
    click CS "https://github.com/sirus20x6/stargen/blob/master/const.h"
    click DH "https://github.com/sirus20x6/stargen/blob/master/display.cpp"
    click HTML "https://github.com/sirus20x6/stargen/tree/master/html/"
    click SSC "https://github.com/sirus20x6/stargen/blob/master/solstation.cpp"
    click PM "https://github.com/sirus20x6/stargen/blob/master/PerformanceMonitor.cpp"
    click TI "https://github.com/sirus20x6/stargen/tree/master/_deps/tracy-src/"
    click JL "https://github.com/sirus20x6/stargen/tree/master/_deps/json-src/"
    click TP "https://github.com/sirus20x6/stargen/tree/master/_deps/tracy-src/"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef data fill:#2ecc71,stroke:#27ae60,color:white
    classDef output fill:#e67e22,stroke:#d35400,color:white
    classDef perf fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ext fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Data Management"]:::data
        L3["Output Components"]:::output
        L4["Performance"]:::perf
        L5["External"]:::ext
    end
```
