# teamdman/superfactorymanager architecture

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

- Interactive diagram: https://gitdiagram.com/teamdman/superfactorymanager
- Repository: https://github.com/teamdman/superfactorymanager

## Overview

##### Main Components

a. Core Systems:
- Program Execution Engine (ca.teamdman.sfm.common.program)
- AST (Abstract Syntax Tree) System (ca.teamdman.sfml.ast)
- Network Management System (ca.teamdman.sfm.common.cablenetwork)
- Resource Type System (ca.teamdman.sfm.common.resourcetype)

b. User Interface Components:
- In-game GUI Screens (ca.teamdman.sfm.client.gui.screen)
- VSCode Extension Integration (vscodeextension folder)
- JEI Integration (ca.teamdman.sfm.client.jei)

c. Block/Item Components:
- Factory Manager Block
- Cable Systems
- Disk Storage System

##### Relationships

**[User Interface Layer]**
- ↓
**[Program Management]**
- ↓
**[Execution Engine] ←→ [Resource Type System]**
- ↓
**[Cable Network] ←→ [Block Integration]**
- ↓
**[Minecraft Integration Layer]**

##### Specific Implementation Details

Key architectural patterns:
- Command pattern for program execution
- Observer pattern for network updates
- Factory pattern for resource type handling
- Visitor pattern for AST processing

##### Integration Points

Connections with:
- Minecraft game systems
- Mod compatibility layers (Mekanism, AE2, etc.)
- VSCode extension communication

##### Data Flow

Key flows:
**[User Input] → [Program Parser] → [AST] → [Execution Engine]**
**[Execution Engine] → [Resource Management] → [Block Operations]**

##### Key Subsystems

Detail these important subsystems:
- Program compilation pipeline
- Network scanning and updating
- Resource type resolution
- Block state management

##### The integration points with Minecraft and other mods

This will provide a clear understanding of how the mod processes user-written programs and translates them into in-game automation actions while maintaining compatibility with other mods and Minecraft itself.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef ui fill:#2ecc71,stroke:#27ae60,color:white
    classDef resource fill:#f1c40f,stroke:#f39c12,color:black
    classDef network fill:#e67e22,stroke:#d35400,color:white
    classDef integration fill:#9b59b6,stroke:#8e44ad,color:white
    classDef block fill:#e74c3c,stroke:#c0392b,color:white

    %% User Interface Layer
    subgraph UI
        GUI["In-Game GUI"]:::ui
        VSC["VSCode Extension"]:::ui
        JEI["JEI Integration"]:::ui
    end

    %% Program Management Layer
    subgraph ProgramManagement
        Parser["Program Parser"]:::core
        AST["AST System"]:::core
        ExecEngine["Execution Engine"]:::core
    end

    %% Resource Management Layer
    subgraph ResourceManagement
        ResType["Resource Type System"]:::resource
        ResResolver["Resource Resolution"]:::resource
    end

    %% Network Layer
    subgraph NetworkSystem
        NetMgr["Network Manager"]:::network
        CableSystem["Cable System"]:::network
    end

    %% Block Integration Layer
    subgraph Blocks
        Manager["Factory Manager"]:::block
        Cable["Cable Blocks"]:::block
        Press["Printing Press"]:::block
        LabelGun["Label Gun"]:::block
    end

    %% Integration Layer
    subgraph Integration
        Minecraft["Minecraft Core"]:::integration
        ModCompat["Mod Compatibility"]:::integration
    end

    %% Relationships
    UI --> Parser
    Parser --> AST
    AST --> ExecEngine
    ExecEngine <--> ResType
    ResType --> ResResolver
    ResResolver --> NetMgr
    NetMgr <--> CableSystem
    CableSystem --> Blocks
    Blocks --> Minecraft
    Blocks --> ModCompat

    %% Click Events
    click ExecEngine "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfm/common/program/"
    click AST "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfml/ast/"
    click NetMgr "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfm/common/cablenetwork/"
    click ResType "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfm/common/resourcetype/"
    click GUI "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfm/client/gui/screen/"
    click VSC "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/vscodeextension/super-factory-manager-language/"
    click JEI "https://github.com/TeamDman/superfactorymanager/tree/1.19.2/src/main/java/ca/teamdman/sfm/client/jei/"
    click Cable "https://github.com/TeamDman/superfactorymanager/blob/1.19.2/src/main/java/ca/teamdman/sfm/common/block/CableBlock.java"
    click Manager "https://github.com/TeamDman/superfactorymanager/blob/1.19.2/src/main/java/ca/teamdman/sfm/common/block/ManagerBlock.java"
    click Press "https://github.com/TeamDman/superfactorymanager/blob/1.19.2/src/main/java/ca/teamdman/sfm/common/block/PrintingPressBlock.java"
    click LabelGun "https://github.com/TeamDman/superfactorymanager/blob/1.19.2/src/main/java/ca/teamdman/sfm/common/item/LabelGunItem.java"
```
