# mightypirates/tis-3d architecture

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

- Interactive diagram: https://gitdiagram.com/mightypirates/tis-3d
- Repository: https://github.com/mightypirates/tis-3d

## Overview

##### Main Components
a) API Layer (top)
b) Implementation Layer (middle)
c) Platform-Specific Layer (bottom)

- Data Flow
- Module → Casing → Controller
- Serial Interface → External Blocks
- Infrared Communication
- Execution Flow
- ASM Code → Compiler → Machine
- Machine → Module Execution

##### Additional Details
- Notes for key architectural patterns:
- Module system extensibility
- Cross-platform compatibility
- ASM execution environment

##### Specific Implementation Notes
- Execution module's compilation and runtime pipeline
- Modular nature of the casing block
- Demonstrate how different modules interact through ports
- Serial protocol system for external communication

- The modular architecture allowing for easy extension
- The separation between API and implementation
- The platform-agnostic core with platform-specific adaptations
- The communication pathways between components
- The execution environment for ASM code

This will create a comprehensive visualization of TIS-3D's architecture while maintaining clarity about how the different components interact and how the system can be extended through its API.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef api fill:#a8d1f0,stroke:#2980b9
    classDef core fill:#a8e6cf,stroke:#1b4332
    classDef platform fill:#ffd3b6,stroke:#ff7f50
    classDef module fill:#98fb98,stroke:#228b22
    classDef execution fill:#dda0dd,stroke:#8b008b
    classDef network fill:#f0e68c,stroke:#bdb76b

    %% API Layer
    subgraph API
        ModuleAPI["Module API"]:::api
        MachineAPI["Machine API"]:::api
        SerialAPI["Serial API"]:::api
        InfraredAPI["Infrared API"]:::api
    end

    %% Implementation Layer
    subgraph Core
        Casing["Casing Block Entity"]:::core
        Controller["Controller Block Entity"]:::core
        Computer["Computer Block Entity"]:::core
    end

    subgraph Modules
        ExecModule["Execution Module"]:::module
        DisplayModule["Display Module"]:::module
        RedstoneModule["Redstone Module"]:::module
        AudioModule["Audio Module"]:::module
    end

    subgraph ExecutionEngine
        Machine["Machine Implementation"]:::execution
        Compiler["Compiler"]:::execution
        Instructions["Instruction Set"]:::execution
    end

    subgraph Network
        MessageHandlers["Message Handlers"]:::network
        StateSynch["State Synchronization"]:::network
    end

    %% Platform Layer
    subgraph Platforms
        Fabric["Fabric Implementation"]:::platform
        Forge["Forge Implementation"]:::platform
        NeoForge["NeoForge Implementation"]:::platform
    end

    %% Relationships
    ModuleAPI --> Modules
    MachineAPI --> Core
    SerialAPI --> Core
    InfraredAPI --> Core

    Modules --> Casing
    Casing --> Controller
    Controller --> Computer

    ExecModule --> Machine
    Machine --> Compiler
    Compiler --> Instructions

    Core --> MessageHandlers
    MessageHandlers --> StateSynch

    Core --> Platforms
    Modules --> Platforms

    %% Click Events
    click ModuleAPI "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/api/module/"
    click MachineAPI "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/api/machine/"
    click SerialAPI "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/api/serial/"
    click InfraredAPI "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/api/infrared/"
    click Casing "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/block/entity/CasingBlockEntity.java"
    click Controller "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/block/entity/ControllerBlockEntity.java"
    click Computer "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/block/entity/ComputerBlockEntity.java"
    click ExecModule "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/module/ExecutionModule.java"
    click DisplayModule "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/module/DisplayModule.java"
    click RedstoneModule "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/module/RedstoneModule.java"
    click Machine "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/module/execution/MachineImpl.java"
    click Compiler "https://github.com/MightyPirates/TIS-3D/blob/1.20.4/common/src/main/java/li/cil/tis3d/common/module/execution/compiler/Compiler.java"
    click Instructions "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/common/module/execution/instruction/"
    click MessageHandlers "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/common/network/message/"
    click Network "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/common/src/main/java/li/cil/tis3d/common/network/"
    click Fabric "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/fabric/src/main/java/li/cil/tis3d/"
    click Forge "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/forge/src/main/java/li/cil/tis3d/"
    click NeoForge "https://github.com/MightyPirates/TIS-3D/tree/1.20.4/neoforge/src/main/java/li/cil/tis3d/"

    %% Legend
    subgraph Legend
        API_Legend["API Components"]:::api
        Core_Legend["Core Components"]:::core
        Module_Legend["Module Components"]:::module
        Execution_Legend["Execution Components"]:::execution
        Network_Legend["Network Components"]:::network
        Platform_Legend["Platform Components"]:::platform
    end
```
