# kabooma/s1api architecture

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

- Interactive diagram: https://gitdiagram.com/kabooma/s1api
- Repository: https://github.com/kabooma/s1api

## Overview

##### Project Type and Purpose
- S1API is an open-source SDK / compatibility layer for Schedule One game modding.
- It abstracts Mono and Il2Cpp environments into a single managed API that modders consume.

##### Core Architectural Layers and Main Components

Row A (Integration Entry)
- [Col 1] S1APILoader
- [Col 2] Mod Developer (Consumer)
- [Col 3] Game Engine Assemblies (Mono / Il2Cpp)

Row B (Core & Abstraction)
- [Col 1] S1API Core (S1API.cs, S1API.csproj)
- [Col 2] Internal Abstraction Layer
– IGUIDReference, IRegisterable, ISaveable + Registerable/Saveable, EventHelper, GUIDReferenceConverter
- [Col 3] Build & CI Config
– .github/workflows, .releaserc.json, example.build.props, github.build.props

Row C (Domain Modules – grouped into three columns)
- [Col 1] Entities & Game Time
– Entities (IEntity, IHealth, NPC, Player, all NPC subfolders)
– GameTime (Day, GameDateTime, TimeManager)
- [Col 2] Content Managers
– Items (ItemDefinition, ItemInstance, ItemManager)
– Products (ProductDefinition, wrappers, ProductManager)
– Quests (Quest, QuestEntry, QuestManager, Constants)
– Property & Storage (PropertyManager, StorageInstance)
- [Col 3] Interactions & UI
– Dialogues, DeadDrops, Conditionals, PhoneCalls, PhoneApp, ConsoleHelper, Messaging, UIFactory, Logging

Row D (Persistence & Utilities)
- [Col 1] Saveables & Serialization
– SaveableField, Saveable abstractions
- [Col 2] Internal Utils & Patches
– Utils (RandomUtils, ReflectionUtils, ImageUtils, ArrayExtensions, ButtonListener, CrossType)
– Patches (HomeScreen, NPCPatches, QuestPatches, TimePatches, PhoneAppRegistry, PlayerPatches)
- [Col 3] Public / Documentation
– README.md, Public/README.md, CONTRIBUTING.md, CODING_STANDARDS.md

##### Relationships and Data Flows
- The S1APILoader (Row A, Col 1) loads the single-assembly S1API into the game process.
- Mod Developer (Row A, Col 2) references the S1API assembly compiled for Mono or Il2Cpp.
- S1API Core (Row B, Col 1) exposes APIs that call into Internal Abstraction (Row B, Col 2).
- Internal Abstraction uses Utils & Patches (Row D, Col 2) to bridge calls to Game Engine Assemblies (Row A, Col 3).
- Domain Modules (Row C) use Abstraction layer to register, save/load, and interact with game state.
- Persistence components (Row D, Col 1) handle serialization of game data for mods and restore via IRegisterable/ISaveable.
- Documentation and CI (Row B, Col 3 & Row D, Col 3) support developer onboarding and release automation.

##### Architectural Patterns & Principles
- Layered Architecture:
– Top: Loader & Consumers
– Middle: Core API → Abstraction → Patches/Utils
– Bottom: Domain Modules → Persistence
– External: Game Engine & Assemblies
- Plugin/Registration Model:
– IRegisterable and ISaveable central to dynamic module loading.
- Cross-Compatibility Abstraction:
– All calls into Mono or Il2Cpp are routed through the same internal patches and converters.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Row A: Integration Entry"
        direction LR
        RowA1["S1APILoader"]:::col1
        RowA2["Mod Developer"]:::external
        RowA3["Game Engine Assemblies\nMono / Il2Cpp"]:::external
    end

    subgraph "Row B: Core & Abstraction"
        direction LR
        RowB1["S1API Core"]:::col1
        RowB2["Internal Abstraction Layer\nIGUIDReference, IRegisterable, ISaveable,\nRegisterable/Saveable, EventHelper,\nGUIDReferenceConverter"]:::col2
        RowB3["Build & CI Config\n.github/workflows,\n.releaserc.json,\nexample.build.props,\ngithub.build.props"]:::col3
    end

    subgraph "Row C: Domain Modules"
        direction LR
        RowC1["Entities & Game Time\nEntities: IEntity, IHealth, NPC, Player,\n...NPCs folder\nGameTime: Day, GameDateTime, TimeManager"]:::col1
        RowC2["Content Managers\nItems, Products, Quests, Property & Storage"]:::col2
        RowC3["Interactions & UI\nDialogues, DeadDrops, Conditionals,\nPhoneCalls, PhoneApp, ConsoleHelper,\nMessaging, UIFactory, Logging"]:::col3
    end

    subgraph "Row D: Persistence & Utilities"
        direction LR
        RowD1["Saveables & Serialization\nSaveableField, Saveable abstractions"]:::col1
        RowD2["Internal Utils & Patches\nUtils, Patches"]:::col2
        RowD3["Public / Documentation\nREADME, Public/README,\nCONTRIBUTING, CODING_STANDARDS"]:::col3
    end

    %% Connections
    RowA1 --> RowB1
    RowA2 --> RowB1
    RowB1 --> RowB2
    RowB2 --> RowD2
    RowD2 --> RowA3
    RowC1 --> RowB2
    RowC2 --> RowB2
    RowC3 --> RowB2
    RowC1 --> RowD1
    RowC2 --> RowD1
    RowC3 --> RowD1
    RowB3 --> RowB1
    RowD3 -.-> RowB1

    %% Click events
    click RowA1 "https://github.com/kabooma/s1api/blob/stable/S1APILoader/S1APILoader.cs"
    click RowB1 "https://github.com/kabooma/s1api/blob/stable/S1API/S1API.cs"
    click RowB2 "https://github.com/kabooma/s1api/blob/stable/S1API/Internal/Abstraction/IGUIDReference.cs"
    click RowB3 "https://github.com/kabooma/s1api/blob/stable/.github/workflows/deploy-build.yml"
    click RowC1 "https://github.com/kabooma/s1api/blob/stable/S1API/Entities/Interfaces/IEntity.cs"
    click RowC2 "https://github.com/kabooma/s1api/blob/stable/S1API/Items/ItemDefinition.cs"
    click RowC3 "https://github.com/kabooma/s1api/blob/stable/S1API/Dialogues/DialogueChoiceListener.cs"
    click RowD1 "https://github.com/kabooma/s1api/blob/stable/S1API/Saveables/SaveableField.cs"
    click RowD2 "https://github.com/kabooma/s1api/blob/stable/S1API/Internal/Utils/RandomUtils.cs"
    click RowD3 "https://github.com/kabooma/s1api/blob/stable/README.md"

    %% Styles
    classDef col1 fill:#cce5ff,stroke:#004085
    classDef col2 fill:#d4edda,stroke:#155724
    classDef col3 fill:#fff3cd,stroke:#856404
    classDef external stroke-dasharray:5 5,fill:#e2e3e5,stroke:#6c757d
```
