# love2d/love architecture

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

- Interactive diagram: https://gitdiagram.com/love2d/love
- Repository: https://github.com/love2d/love

## Overview

##### Project type and purpose
- This is a cross-platform game engine/framework ("LÖVE") written in C++ with Lua bindings.
- It targets Windows, macOS, Linux, Android, and iOS to let developers write 2D games in Lua.

##### File structure
- Top-level: build scripts (CMakeLists.txt, extra/cmake), platform folders (xcode, unix, Windows resources), source root (src/), and test suite (testing/).
- src/common: the engine’s core runtime, data structures, platform abstractions.
- src/libraries: in-tree copies of third-party dependencies (SDL2, OpenGL loaders, physics engines, image/codecs, audio, networking, Vulkan, Metal, etc.).
- src/modules: feature modules exposed to Lua (audio, graphics, physics, input, file I/O, networking, threading, etc.), each with C++ implementation + Lua wrappers.
- platform/*: OS-specific entry points, installers, resource files.
- testing/: integration tests invoking the engine as a normal LÖVE project.

##### README for additional insights
- Engine uses SDL3 for windowing, input, audio.
- Supports multiple rendering back-ends: OpenGL, Vulkan, Metal.
- Exposes all engine functionality via Lua C API wrappers.
- Uses CMake to generate platform builds and integrates Apple frameworks for iOS/macOS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & CI Layer
    subgraph "Build & CI"
        BS["Build System"]:::build
        BS_extra["CMake Scripts"]:::build
        BS_ci["CI Workflows"]:::build
    end

    %% Platform Abstraction Layer
    subgraph "Platform Abstraction" 
        PlatCommon["Common Platform Code"]:::platform
        PlatUnix["Unix Packaging"]:::platform
        PlatXcode["Xcode Projects"]:::platform
        PlatNSIS["Windows Installer"]:::platform
        PlatRC["Windows Resources"]:::platform
    end

    %% Engine Internals
    subgraph "Engine Internals"
        CE["Core Engine"]:::engine
        subgraph "Feature Modules"
            Audio["Audio Module"]:::engine
            Graphics["Graphics Module"]:::engine
            Physics["Physics Module"]:::engine
            Image["Image Module"]:::engine
            Sound["Sound Module"]:::engine
            Math["Math Module"]:::engine
            DataMod["Data Module"]:::engine
            FS["Filesystem Module"]:::engine
            Event["Event Module"]:::engine
            Font["Font Module"]:::engine
            Joystick["Joystick Module"]:::engine
            Keyboard["Keyboard Module"]:::engine
            Mouse["Mouse Module"]:::engine
            System["System Module"]:::engine
            Thread["Thread Module"]:::engine
            Timer["Timer Module"]:::engine
            Touch["Touch Module"]:::engine
            Video["Video Module"]:::engine
            Window["Window Module"]:::engine
            Sensor["Sensor Module"]:::engine
            LuaMod["Lua Core Module"]:::engine
        end
    end

    %% Third-Party Dependencies
    Lib["Third-Party Libraries"]:::thirdparty

    %% Scripting Layer
    Lua["Lua Interpreter & Wrappers"]:::scripting

    %% Binary Outputs
    Bin["Binary Outputs"]:::build

    %% User and Test Code
    User["User Lua Code"]:::user
    Test["Test Suite"]:::user

    %% Connections
    BS -->|compiles| CE
    BS -->|compiles| Audio
    BS -->|compiles| Graphics
    BS -->|compiles| Physics
    BS -->|compiles| Image
    BS -->|compiles| Sound
    BS -->|compiles| Math
    BS -->|compiles| DataMod
    BS -->|compiles| FS
    BS -->|compiles| Event
    BS -->|compiles| Font
    BS -->|compiles| Joystick
    BS -->|compiles| Keyboard
    BS -->|compiles| Mouse
    BS -->|compiles| System
    BS -->|compiles| Thread
    BS -->|compiles| Timer
    BS -->|compiles| Touch
    BS -->|compiles| Video
    BS -->|compiles| Window
    BS -->|compiles| Sensor
    BS -->|compiles| LuaMod
    BS -->|vendors| Lib
    BS -->|packages| PlatCommon
    BS -->|packages| PlatUnix
    BS -->|packages| PlatXcode
    BS -->|packages| PlatNSIS
    BS -->|packages| PlatRC
    BS -->|produces| Bin

    CE <--> PlatCommon
    CE --> Lib
    Audio --> CE
    Graphics --> CE
    Physics --> CE
    Image --> CE
    Sound --> CE
    Math --> CE
    DataMod --> CE
    FS --> CE
    Event --> CE
    Font --> CE
    Joystick --> CE
    Keyboard --> CE
    Mouse --> CE
    System --> CE
    Thread --> CE
    Timer --> CE
    Touch --> CE
    Video --> CE
    Window --> CE
    Sensor --> CE
    LuaMod --> CE

    Audio --> Lib
    Graphics --> Lib
    Physics --> Lib
    Image --> Lib
    Sound --> Lib
    Math --> Lib
    DataMod --> Lib
    FS --> Lib
    Event --> Lib
    Font --> Lib
    Joystick --> Lib
    Keyboard --> Lib
    Mouse --> Lib
    System --> Lib
    Thread --> Lib
    Timer --> Lib
    Touch --> Lib
    Video --> Lib
    Window --> Lib
    Sensor --> Lib

    Lua --> Audio
    Lua --> Graphics
    Lua --> Physics
    Lua --> Image
    Lua --> Sound
    Lua --> Math
    Lua --> DataMod
    Lua --> FS
    Lua --> Event
    Lua --> Font
    Lua --> Joystick
    Lua --> Keyboard
    Lua --> Mouse
    Lua --> System
    Lua --> Thread
    Lua --> Timer
    Lua --> Touch
    Lua --> Video
    Lua --> Window
    Lua --> Sensor
    Lua --> LuaMod

    User -->|runs in| Lua
    Test -->|invokes| Bin
    Bin -->|executes| Lua

    %% Click Events
    click BS "https://github.com/love2d/love/blob/main/CMakeLists.txt"
    click BS_extra "https://github.com/love2d/love/tree/main/extra/cmake/"
    click BS_ci "https://github.com/love2d/love/blob/main/.github/workflows/main.yml"
    click CE "https://github.com/love2d/love/tree/main/src/common/"
    click CE "https://github.com/love2d/love/blob/main/src/love.cpp"
    click Lib "https://github.com/love2d/love/tree/main/src/libraries/"
    click Audio "https://github.com/love2d/love/tree/main/src/modules/audio/"
    click Graphics "https://github.com/love2d/love/tree/main/src/modules/graphics/"
    click Physics "https://github.com/love2d/love/tree/main/src/modules/physics/"
    click Image "https://github.com/love2d/love/tree/main/src/modules/image/"
    click Sound "https://github.com/love2d/love/tree/main/src/modules/sound/"
    click Math "https://github.com/love2d/love/tree/main/src/modules/math/"
    click DataMod "https://github.com/love2d/love/tree/main/src/modules/data/"
    click FS "https://github.com/love2d/love/tree/main/src/modules/filesystem/"
    click Event "https://github.com/love2d/love/tree/main/src/modules/event/"
    click Font "https://github.com/love2d/love/tree/main/src/modules/font/"
    click Joystick "https://github.com/love2d/love/tree/main/src/modules/joystick/"
    click Keyboard "https://github.com/love2d/love/tree/main/src/modules/keyboard/"
    click Mouse "https://github.com/love2d/love/tree/main/src/modules/mouse/"
    click System "https://github.com/love2d/love/tree/main/src/modules/system/"
    click Thread "https://github.com/love2d/love/tree/main/src/modules/thread/"
    click Timer "https://github.com/love2d/love/tree/main/src/modules/timer/"
    click Touch "https://github.com/love2d/love/tree/main/src/modules/touch/"
    click Video "https://github.com/love2d/love/tree/main/src/modules/video/"
    click Window "https://github.com/love2d/love/tree/main/src/modules/window/"
    click Sensor "https://github.com/love2d/love/tree/main/src/modules/sensor/"
    click Lua "https://github.com/love2d/love/tree/main/src/modules/love/"
    click PlatCommon "https://github.com/love2d/love/tree/main/src/common/"
    click PlatUnix "https://github.com/love2d/love/tree/main/platform/unix/"
    click PlatXcode "https://github.com/love2d/love/tree/main/platform/xcode/"
    click PlatNSIS "https://github.com/love2d/love/tree/main/extra/nsis/"
    click PlatRC "https://github.com/love2d/love/blob/main/extra/windows/love.rc"
    click Test "https://github.com/love2d/love/tree/main/testing/"

    %% Styles
    classDef build fill:#d3d3d3,stroke:#888,stroke-width:2px
    classDef engine fill:#add8e6,stroke:#555,stroke-width:2px
    classDef thirdparty fill:#90ee90,stroke:#555,stroke-width:2px
    classDef scripting fill:#ffa500,stroke:#555,stroke-width:2px
    classDef user fill:#ffff99,stroke:#555,stroke-width:2px
    classDef platform fill:#dda0dd,stroke:#555,stroke-width:2px
```
