# jgefroh/core-light architecture

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

- Interactive diagram: https://gitdiagram.com/jgefroh/core-light
- Repository: https://github.com/jgefroh/core-light

## Overview

##### Main Components
- Bootstrap Layer
– main.js (entry point)
– game/title/start-game.js (Core initialization & system registration)
- Core Engine (core-js)
– Entity Manager (entity.js)
– Component Registry (component.js)
– System Scheduler (system.js)
– Tag Registry (tag.js)
– Core Loop (core.js)
- Generic Engine Systems (/game/engine)
– Rendering (canvas-renderer, webgl2-renderer, render-system)
– Input (input-system)
– Audio (audio-system)
– Collision (collision-system)
– Movement (movement-proposal & finalization systems)
– AI (ai-system)
– Lighting (light-system, shadow-system)
– Particles (particle-system)
– GUI (gui-system)
– Other subsystems: hitscan, attachments, timer, tracker
- Game Features (/game/features)
– AI feature implementations (goals, tactics, steps, state informer)
– Weapons (firing, reload, recoil, effects)
– FX (death-fx, impact-fx, footstep-fx)
– Map & Enemy generation
– Player control (movement, weapon, flashlight)
– Game logic (game-over, instructions, laser-aim, turn-towards-cursor)
- Configuration & Specifics (/game/specifics)
– Asset loader & manifest
– Collision/input configuration systems
– Debug systems
– Map warehouse
- Static Assets (/static/assets)
– Audio files
– Image/sprite data
- Utilities & Tracker
– Mouse-tracker component/system

##### Relationships & Data Flow
- main.js → start-game.js: instantiate Core, register engine & feature systems, load assets
- Core Loop (core-js) orchestrates:
– Each frame: run Input → AI → Movement → Collision → Gameplay Features → Rendering → Audio
- AssetLoaderSystem pulls from static/assets into in-memory resources used by renderer & audio-system
- Configuration systems run early to set up collision bounds, input mappings, and debug flags
- Feature systems subscribe to component/tag events provided by engine systems

##### Architectural Patterns
- ECS (Entity–Component–System) at heart
- Modular system registration (engine vs. feature vs. config vs. debug)
- Separation of concerns:
– Core engine is independent of game logic
– Feature implementations only add/remove components or react to tags
- Data-driven asset configuration

##### Technologies & Frameworks
- Pure JavaScript
- HTML5 Canvas & WebGL2 renderers
- Custom ECS framework (core-js)
- npm & webpack (webpack.config.js)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Bootstrap Layer
    subgraph "Bootstrap Layer"
        main["main.js"]:::bootstrap
        start["start-game.js"]:::bootstrap
    end

    main --> start

    click main "https://github.com/jgefroh/core-light/blob/main/main.js"
    click start "https://github.com/jgefroh/core-light/blob/main/game/title/start-game.js"

    %% Core Engine
    subgraph "Core Engine"
        entity["Entity Manager"]:::core
        component["Component Registry"]:::core
        systemSched["System Scheduler"]:::core
        tagReg["Tag Registry"]:::core
        coreLoop["Core Loop"]:::core
    end

    start --> coreLoop
    click entity "https://github.com/jgefroh/core-light/blob/main/core-js/src/entity.js"
    click component "https://github.com/jgefroh/core-light/blob/main/core-js/src/component.js"
    click systemSched "https://github.com/jgefroh/core-light/blob/main/core-js/src/system.js"
    click tagReg "https://github.com/jgefroh/core-light/blob/main/core-js/src/tag.js"
    click coreLoop "https://github.com/jgefroh/core-light/blob/main/core-js/src/core.js"

    %% Generic Engine Systems
    subgraph "Engine Systems"
        subgraph Rendering
            renderSys["Render System"]:::engine
            animSys["Animation System"]:::engine
            renderables["Renderables Render System"]:::engine
            canvasR["Canvas Renderer"]:::engine
            webglR["WebGL2 Renderer"]:::engine
        end
        inputSys["Input System"]:::engine
        audioSys["Audio System"]:::engine
        collisionSys["Collision System"]:::engine
        moveProp["Movement Proposal System"]:::engine
        moveFin["Movement Finalization System"]:::engine
        aiE["AI System"]:::engine
    end

    coreLoop --> inputSys
    inputSys --> aiE
    aiE --> moveProp
    moveProp --> moveFin
    moveFin --> collisionSys
    collisionSys --> renderSys
    renderSys --> audioSys

    click renderSys "https://github.com/jgefroh/core-light/blob/main/game/engine/renderer/render-system.js"
    click animSys "https://github.com/jgefroh/core-light/blob/main/game/engine/renderer/animation-system.js"
    click renderables "https://github.com/jgefroh/core-light/blob/main/game/engine/renderer/renderables-render-system.js"
    click canvasR "https://github.com/jgefroh/core-light/blob/main/game/engine/renderer/canvas-renderer.js"
    click webglR "https://github.com/jgefroh/core-light/blob/main/game/engine/renderer/webgl2-renderer.js"
    click inputSys "https://github.com/jgefroh/core-light/blob/main/game/engine/input/input-system.js"
    click audioSys "https://github.com/jgefroh/core-light/blob/main/game/engine/audio/audio-system.js"
    click collisionSys "https://github.com/jgefroh/core-light/blob/main/game/engine/collision/collision-system.js"
    click moveProp "https://github.com/jgefroh/core-light/blob/main/game/engine/movement/movement-proposal-system.js"
    click moveFin "https://github.com/jgefroh/core-light/blob/main/game/engine/movement/movement-finalization-system.js"
    click aiE "https://github.com/jgefroh/core-light/blob/main/game/engine/ai/ai-system.js"

    %% Game Features
    subgraph "Game Features"
        aiF["AI Feature Systems"]:::features
        weapons["Weapons Systems"]:::features
        fx["FX Systems"]:::features
        playerControl["Player Control"]:::features
        mapGen["Enemy/Map Generation"]:::features
        gameLogic["Game Logic Systems"]:::features
    end

    collisionSys --> aiF
    aiF --> weapons
    weapons --> fx
    fx --> playerControl
    playerControl --> mapGen
    mapGen --> gameLogic
    gameLogic --> renderSys

    click aiF "https://github.com/jgefroh/core-light/blob/main/game/features/ai/ai-configuration-system.js"
    click weapons "https://github.com/jgefroh/core-light/blob/main/game/features/weapons/weapon-firing-system.js"
    click fx "https://github.com/jgefroh/core-light/blob/main/game/features/death-fx/enemy-death-fx-system.js"
    click playerControl "https://github.com/jgefroh/core-light/blob/main/game/features/player-control/player-control-movement-system.js"
    click mapGen "https://github.com/jgefroh/core-light/blob/main/game/features/enemy-generator/enemy-generator-system.js"
    click gameLogic "https://github.com/jgefroh/core-light/blob/main/game/features/game-over/game-over-system.js"

    %% Configuration & Specifics
    subgraph "Configuration & Specifics"
        assetLoader["Asset Loader System"]:::config
        assetManifest["Asset Manifest"]:::config
        collisionCfg["Collision Config System"]:::config
        inputCfg["Input Config System"]:::config
        debugSys["Debug Systems"]:::config
        mapWarehouse["Map Warehouse"]:::config
    end

    start --> assetLoader
    assetLoader --> component
    collisionCfg --> collisionSys
    inputCfg --> inputSys
    debugSys --> aiE
    mapWarehouse --> mapGen

    click assetLoader "https://github.com/jgefroh/core-light/blob/main/game/specifics/configuration/assets/asset-loader-system.js"
    click assetManifest "https://github.com/jgefroh/core-light/blob/main/game/specifics/configuration/assets/asset-manifest.js"
    click collisionCfg "https://github.com/jgefroh/core-light/blob/main/game/specifics/configuration/collision-configuration-system.js"
    click inputCfg "https://github.com/jgefroh/core-light/blob/main/game/specifics/configuration/input-configuration-system.js"
    click debugSys "https://github.com/jgefroh/core-light/blob/main/game/specifics/debug/debug-ui-system.js"
    click mapWarehouse "https://github.com/jgefroh/core-light/blob/main/game/specifics/maps/map-warehouse.js"

    %% Static Assets
    subgraph "Static Assets"
        audioFiles["Audio Files"]:::assets
        imageFiles["Image/Sprite Data"]:::assets
    end

    audioFiles --> assetLoader
    imageFiles --> assetLoader

    %% Utilities & Tracker
    subgraph "Utilities & Tracker"
        utils["Utilities"]:::util
        mouseTrack["Mouse Tracker"]:::util
    end

    utils --> aiE
    mouseTrack --> inputSys

    click utils "https://github.com/jgefroh/core-light/blob/main/game/utilities/distance-util.js"
    click mouseTrack "https://github.com/jgefroh/core-light/blob/main/game/tracker/mouse-tracker-system.js"

    %% Styles
    classDef bootstrap fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#98FB98,stroke:#333,stroke-width:1px
    classDef engine fill:#FFA500,stroke:#333,stroke-width:1px
    classDef features fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef config fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef assets fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef util fill:#90EE90,stroke:#333,stroke-width:1px
```
