# itfrombit/osx_handmade architecture

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

- Interactive diagram: https://gitdiagram.com/itfrombit/osx_handmade
- Repository: https://github.com/itfrombit/osx_handmade

## Overview

##### Main Components

a) Platform Layer (macOS Specific)
- Core Platform Services
- Audio System (osx_handmade_audio.cpp)
- File System (osx_handmade_file.cpp)
- Input Handling (osx_handmade_hid.cpp)
- Memory Management (osx_handmade_memory.cpp)
- Threading (osx_handmade_thread.cpp)

b) Rendering System
- OpenGL Implementation (osx_handmade_opengl.cpp/mm)
- Renderer Interface (osx_handmade_renderer.h)

c) Game Layer
- Core Game Logic (osx_handmade_game.cpp)
- Asset Management (osx_asset_builder.cpp)

d) Development Tools
- Debug System (osx_handmade_debug.cpp)
- Hot Reload System (osx_handmade_dylib.cpp)

**┌─────────────────────────────────────────┐**
- Application Layer          │
- (Main Game Loop, Asset Management)     │
- ┤
- Platform Services Layer       │
- (Audio, Input, File System, Memory)    │
- ┤
- Rendering Layer             │
- (OpenGL Implementation, Renderer)      │
- ┤
- macOS System              │
- (Cocoa, CoreText, System Services)     │
- ┘

##### Key Relationships to Highlight

- Blue: Core game systems
- Green: Platform-specific implementations
- Orange: Development/Debug tools
- Gray: External system dependencies

##### Implementation Details

**[Game Core (libhandmade.dylib)] ←→ [Platform Layer]**
- ↓                           ↓
- [Asset System] ←→ [File System] → [macOS APIs]
- ↓                           ↓
**[Renderer (libhandmade_opengl.dylib)] → [OpenGL]**

##### Additional Elements

- A development tools section showing:
- HandmadeTabView
- HandmadeRendererTest
- Font generation tools
- Debug utilities

##### Notes

- Use standardized symbols for components
- Version information
- Notes about platform-specific implementations
- Document hot reload paths
- Asset pipeline flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef platform fill:#90EE90,stroke:#333,stroke-width:2px
    classDef game fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef render fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef tools fill:#FFD700,stroke:#333,stroke-width:2px
    classDef system fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Main Application Layer
    subgraph AppLayer
        GameCore["Game Core\n(libhandmade.dylib)"]:::game
        AssetMgmt["Asset Management"]:::game
    end

    %% Platform Services Layer
    subgraph PlatformLayer
        PlatformCore["Platform Core"]:::platform
        Audio["Audio System"]:::platform
        FileSystem["File System"]:::platform
        Input["Input Handling"]:::platform
        Memory["Memory Management"]:::platform
        Threading["Threading System"]:::platform
    end

    %% Rendering Layer
    subgraph RenderLayer
        RenderInterface["Renderer Interface"]:::render
        OpenGLImpl["OpenGL Implementation"]:::render
        FontSystem["Font System"]:::render
    end

    %% Development Tools Layer
    subgraph DevTools
        DebugSystem["Debug System"]:::tools
        HotReload["Hot Reload System"]:::tools
        DevUI["Development UI"]:::tools
        RendererTest["Renderer Test"]:::tools
    end

    %% System Layer
    subgraph SystemLayer
        MacOS["macOS System"]:::system
        OpenGL["OpenGL"]:::system
        CocoaAPI["Cocoa API"]:::system
    end

    %% Relationships
    GameCore --> AssetMgmt
    GameCore --> RenderInterface
    GameCore --> PlatformCore

    PlatformCore --> Audio
    PlatformCore --> FileSystem
    PlatformCore --> Input
    PlatformCore --> Memory
    PlatformCore --> Threading

    RenderInterface --> OpenGLImpl
    OpenGLImpl --> OpenGL
    OpenGLImpl --> FontSystem

    HotReload --> GameCore
    DebugSystem --> GameCore
    DevUI --> RendererTest
    RendererTest --> RenderInterface

    Audio --> MacOS
    FileSystem --> MacOS
    Input --> CocoaAPI
    CocoaAPI --> MacOS

    %% Click events for component mapping
    click Audio "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_audio.cpp"
    click FileSystem "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_file.cpp"
    click Input "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_hid.cpp"
    click Memory "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_memory.cpp"
    click Threading "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_thread.cpp"
    click OpenGLImpl "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_opengl.cpp"
    click RenderInterface "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_renderer.h"
    click GameCore "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_game.cpp"
    click AssetMgmt "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_asset_builder.cpp"
    click DebugSystem "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_debug.cpp"
    click HotReload "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade_dylib.cpp"
    click PlatformCore "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_handmade.h"
    click DevUI "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_tabview.mm"
    click RendererTest "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_renderer_test.mm"
    click FontSystem "https://github.com/itfrombit/osx_handmade/blob/master/code/osx_hhfont.cpp"

    %% Legend
    subgraph Legend
        L1["Game Components"]:::game
        L2["Platform Services"]:::platform
        L3["Rendering Components"]:::render
        L4["Development Tools"]:::tools
        L5["System Components"]:::system
    end
```
