# mkmckenna/solar-system-generator architecture

> Architecture diagram of the GitHub repository mkmckenna/solar-system-generator, 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/mkmckenna/solar-system-generator
- Repository: https://github.com/mkmckenna/solar-system-generator

## Overview

##### Main Components Identification

The system should be represented as a client-side 3D application with the following major components:

a. Core Application Layer
- Entry point (app.ts)
- Constants and Configuration
- Cursor Management

b. Entity System
- Base Entity Framework
- Solar System Components (Stars, Planets)
- Hitbox System
- Builder Pattern Implementation

c. Rendering System
- Shader Management
- Texture Management
- 3D Model Processing

d. UI System
- Interactive Elements
- Drag & Resize Controllers
- Information Displays

**[User Interface Layer]**
- ↕️
**[Core Application Layer]**
- ↕️
**[Entity Management Layer]**
- ↕️
**[Rendering Layer]**

##### Component Relationships

Key interactions:

a. Builder Pattern Flow:
**SolarSystemBuilder → StarBuilder → PlanetBuilder**
- ↓
- Entities
**(Star, Planet, SkyBox)**

b. Shader System:
**Vertex Shader ← → Fragment Shaders**
- ↓
- (Planet/Star Rendering)

##### Specific Implementation Details

a. Data Flow:
- How solar_system_properties.json and solar_system_names.json feed into the generation system
- Relationship between entities and their respective builders
- Demonstrate shader compilation and application flow

b. Key Technologies to Highlight:
- WebGL/Three.js (implied by the 3D graphics nature)
- TypeScript (evident from .ts files)
- Webpack (for bundling)

##### Architectural Patterns to Emphasize

- Builder Pattern (shown in entities/builders/)
- Component-Based Architecture (entities system)
- Event-Driven UI System (UI controllers)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        UI_Base["UI Element Base"]
        UI_Drag["Drag Controller"]
        UI_Resize["Resize Controller"]
        UI_Planet["Planet Info Display"]
        UI_Solar["Solar System Info Display"]
        
        UI_Base --> UI_Drag
        UI_Base --> UI_Resize
        UI_Base --> UI_Planet
        UI_Base --> UI_Solar
    end

    subgraph Core["Core Application Layer"]
        App["Application Entry"]
        Constants["Constants"]
        Cursor["Cursor Management"]
        
        App --> Constants
        App --> Cursor
    end

    subgraph Entity["Entity Management Layer"]
        direction TB
        Entity_Base["Base Entity"]
        Hitbox["Hitbox System"]
        
        subgraph Builders["Builder System"]
            SolarBuilder["Solar System Builder"]
            StarBuilder["Star Builder"]
            PlanetBuilder["Planet Builder"]
            
            SolarBuilder --> StarBuilder
            SolarBuilder --> PlanetBuilder
        end
        
        subgraph Entities["Entity Types"]
            SolarSystem["Solar System"]
            Star["Star"]
            Planet["Planet"]
            Skybox["Skybox"]
        end
        
        Entity_Base --> Hitbox
        Entity_Base --> Entities
        Builders --> Entities
    end

    subgraph Render["Rendering Layer"]
        direction TB
        VertexShader["Vertex Shader"]
        
        subgraph PlanetShaders["Planet Shaders"]
            PlanetAtmos["Atmosphere Fragment"]
            PlanetSurface["Surface Fragment"]
        end
        
        subgraph StarShaders["Star Shaders"]
            StarCorona["Corona Fragment"]
            StarSurface["Surface Fragment"]
        end
        
        VertexShader --> PlanetShaders
        VertexShader --> StarShaders
    end

    subgraph Data["Data Layer"]
        Properties["Solar System Properties"]
        Names["Solar System Names"]
        PropTypes["Properties Interface"]
    end

    Data --> Core
    Core --> Entity
    Entity --> Render
    Core --> UI

    %% Click Events
    click App "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app.ts"
    click Constants "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/constants.ts"
    click Cursor "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/cursor.ts"
    click Entity_Base "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/entity.ts"
    click Hitbox "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/hitbox.ts"
    click SolarSystem "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/solar_system.ts"
    click Planet "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/planet.ts"
    click Star "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/star.ts"
    click Skybox "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/skybox.ts"
    click SolarBuilder "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/builders/solar_system_builder.ts"
    click PlanetBuilder "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/builders/planet_builder.ts"
    click StarBuilder "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/entities/builders/star_builder.ts"
    click VertexShader "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/shaders/vertex_shader.glsl"
    click PlanetAtmos "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/shaders/planets/atmosphere_fragment_shader.glsl"
    click PlanetSurface "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/shaders/planets/surface_fragment_shader.glsl"
    click StarCorona "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/shaders/stars/corona_fragment_shader.glsl"
    click StarSurface "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/shaders/stars/surface_fragment_shader.glsl"
    click UI_Base "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/ui/ui_element.ts"
    click UI_Drag "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/ui/ui_element_drag_controller.ts"
    click UI_Resize "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/ui/ui_element_resize_controller.ts"
    click UI_Planet "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/ui/planet_info.ts"
    click UI_Solar "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/ui/solar_system_info.ts"
    click Properties "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/data/solar_system_properties.json"
    click Names "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/data/solar_system_names.json"
    click PropTypes "https://github.com/mkmckenna/solar-system-generator/blob/master/src/client/app/data/solar_system_properties.ts"

    classDef core fill:#a8d1f0
    classDef entity fill:#90EE90
    classDef render fill:#DDA0DD
    classDef ui fill:#FFA07A
    classDef data fill:#D3D3D3

    class App,Constants,Cursor core
    class Entity_Base,Hitbox,SolarSystem,Star,Planet,Skybox,SolarBuilder,StarBuilder,PlanetBuilder entity
    class VertexShader,PlanetAtmos,PlanetSurface,StarCorona,StarSurface render
    class UI_Base,UI_Drag,UI_Resize,UI_Planet,UI_Solar ui
    class Properties,Names,PropTypes data
```
