# ryanzwe/runelite architecture

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

- Interactive diagram: https://gitdiagram.com/ryanzwe/runelite
- Repository: https://github.com/ryanzwe/runelite

## Overview

The RuneLite project is a modular, open‐source client for OldSchool RuneScape. It is structured as a multi‐module Maven project with clearly defined concerns, such as managing game cache files, providing HTTP APIs and services, the core client with a plugin architecture, API interfaces that expose client functionality, and mixins that patch or “inject” additional behavior into the underlying RuneScape client code.

##### Main Components
- Cache and Data Management:
– Modules: “cache”, “cache-client”, and “cache-updater”. These modules contain code for reading, writing, and managing cache files (which include game data like animation, textures, definitions, etc).
- HTTP APIs and Services:
– Modules: “http-api” provides a web API (the public endpoints for api.runelite.net) and “http-service” that implements the corresponding service layer.
- Core APIs and Mappings:
– Modules: “runelite-api” provides interfaces that plugins and other parts of the client rely on, abstracting away from the internal workings.
– “runescape-api” contains mappings and interfaces that correspond almost one-to-one with the actual game client data structures.
- The Game Client and Plugin Infrastructure:
– Module: “runelite-client” is the main game client. It contains the UI (overlays, menus, toolbars), the plugin system (plugins reside here in subpackages), and client integrative logic.
- Mixins and Behavioral Extensions:
– Module: “runelite-mixins” holds mixin classes that are injected into the original game client classes. This is the core technique for modifying behavior without altering the original code.
- Script Assembly and Ancillary Tools:
– “runelite-script-assembler-plugin” is used for assembling or processing scripts that may be injected into the client.

##### Relationships and Interactions
- The “runelite-client” is the hub that brings together most functionality. It uses interfaces from “runelite-api” (which in turn is a subset of “runescape-api”) to interact with the underlying game mechanics.
- Mixins from “runelite-mixins” are injected into the client at runtime to modify/improve behavior (for example, changing rendering or input handling). They work very closely with “runescape-api”, which defines the lower-level constructs.
- The “cache” modules provide utility libraries that the client or mixins might use to load game data and definitions.
- The HTTP-related modules (“http-api” and “http-service”) are separate but integrate with the core system to expose client data externally (for instance, to support the web API at api.runelite.net).
- The plugin system is a major design component; in the client, each plugin (organized by domain, e.g. “bank”, “cluescrolls”, “minimap”, etc.) interacts with the core via the “runelite-api” interfaces, receiving updates (via event bus), drawing overlays, and modifying behavior.

##### Architectural Patterns or Design Principles
- Modularization: The system is divided into separate Maven modules that isolate functionality. This enables independent development and testing.
- Dependency Inversion: The client code depends on abstraction (provided by “runelite-api”) rather than concrete implementations.
- Mixin or Aspect-Oriented Programming: The “runelite-mixins” module injects behavior into the game client—an approach that allows dynamic modification of internals without direct source edits.
- Plugin Architecture: Decoupling through the plugin framework lets developers extend client functionalities. Plugins register themselves with an event bus to subscribe to client state changes.
- Service-Oriented Architecture (for HTTP): The HTTP API and HTTP service modules provide a RESTful layer that exposes client data and functionality over the network.

##### Instructing the Principal Software Engineer
– Rectangles for major modules (e.g., runelite-client, runelite-api).
– Annotations for design patterns used (e.g., plugin architecture, mixins).
– Presentation/Interaction layer (client UI, overlays, plugins).
– Business logic layer (plugin event bus, core client logic).
– Data access layer (cache management, file reading/writing, HTTP service interacting with persistent storage).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Cache/Data Management"
        A["cache (Module)"]:::cacheStyle
        B["cache-client (Module)"]:::cacheStyle
        C["cache-updater (Module)"]:::cacheStyle
    end

    subgraph "Core APIs and Mappings"
        D["runelite-api (Module)"]:::apiStyle
        E["runescape-api (Module)"]:::apiStyle
    end

    subgraph "Mixins"
        F["runelite-mixins (Module)"]:::mixinStyle
    end

    subgraph "HTTP API/Service"
        G["http-api (Module)"]:::httpStyle
        H["http-service (Module)"]:::httpStyle
    end

    subgraph "Client/Plugin System"
        I["runelite-client (Module)"]:::clientStyle
    end

    subgraph "Ancillary Tools"
        J["runelite-script-assembler-plugin (Module)"]:::ancillaryStyle
    end

    %% Relationships
    A -->|"loads"| I
    B -->|"loads"| I
    C -->|"updates"| I

    D -->|"interfaces"| I
    E -->|"mappings"| I

    F -->|"injects"| I

    I -->|"provides_data"| H
    H -->|"serves_api"| G

    J -->|"script_process"| I

    %% Click Events
    click A "https://github.com/ryanzwe/runelite/tree/master//cache"
    click B "https://github.com/ryanzwe/runelite/tree/master//cache-client"
    click C "https://github.com/ryanzwe/runelite/tree/master//cache-updater"
    click D "https://github.com/ryanzwe/runelite/tree/master//runelite-api"
    click E "https://github.com/ryanzwe/runelite/tree/master//runescape-api"
    click F "https://github.com/ryanzwe/runelite/tree/master//runelite-mixins"
    click G "https://github.com/ryanzwe/runelite/tree/master//http-api"
    click H "https://github.com/ryanzwe/runelite/tree/master//http-service"
    click I "https://github.com/ryanzwe/runelite/tree/master//runelite-client"
    click J "https://github.com/ryanzwe/runelite/tree/master//runelite-script-assembler-plugin"

    %% Styles
    classDef cacheStyle fill:#FFCCCB,stroke:#000,stroke-width:2px;
    classDef httpStyle fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef apiStyle fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef clientStyle fill:#FFFFCC,stroke:#000,stroke-width:2px;
    classDef mixinStyle fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef ancillaryStyle fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
