# h4tch/moddoc architecture

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

- Interactive diagram: https://gitdiagram.com/h4tch/moddoc
- Repository: https://github.com/h4tch/moddoc

## Overview

##### Core Components

a) Parser Layer:
- TOML Parser component
- Custom TOML extension parser (as mentioned in the README)

b) Definition Modules:
- Component Definition Handler
- System Definition Handler
- Entity Definition Handler
- Metadata Handler
- Dependency Manager

c) Runtime Layer:
- Dynamic Shared Object Loading System (mentioned as a future consideration)
- Namespace Manager
- Symbol Export/Import System

- [Input Layer]
- → .dm files
- → TOML definitions

- [Processing Layer]
- → Parser Components
- → Definition Handlers
- → Validation System

- [Runtime Layer]
- → Dynamic Loading
- → Namespace Management
- → Symbol Resolution

##### Key Relationships to Highlight

a) Data Flow:
- How .dm files flow through the TOML parser
- How parsed definitions are processed by respective handlers
- Demonstrate dependency resolution paths

b) Component Interactions:
- How Components, Systems, and Entities interact
- Namespace isolation
- Symbol export/import paths

##### Implementation Details to Note

- Clear labels for TOML extension points

##### External Integration Points

- Integration with game engine components
- Lua script integration
- Dynamic shared object loading interfaces

Remember to include a small example workflow showing how a typical mod definition would flow through the system, from .dm file to runtime implementation.

This design should emphasize the declarative nature of the system while showing how it handles the complexity of mod management in game development.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        DM[".dm Files"]
        TOML["TOML Definitions"]
        GravityDM["Gravity.dm Example"]:::file
    end

    subgraph "Processing Layer"
        Parser["TOML Parser"]
        ExtParser["Custom TOML Extensions"]
        
        subgraph "Definition Handlers"
            CompDef["Component Definitions"]
            SysDef["System Definitions"]
            EntDef["Entity Definitions"]
            MetaDef["Metadata Handler"]
        end
        
        Validator["Validation System"]
        DepManager["Dependency Manager"]
    end

    subgraph "Runtime Layer"
        DSO["Dynamic Shared Objects"]:::planned
        NameSpace["Namespace Manager"]
        SymbolSys["Symbol Export/Import"]
        
        subgraph "Experimental Features"
            InstCreate["Named Instance Creation"]:::experimental
            QMLSyntax["QML-inspired Syntax"]:::experimental
            OptLogic["Optional Logic Implementation"]:::experimental
        end
    end

    subgraph "External Integration"
        GameEngine["Game Engine"]
        LuaScript["Lua Scripts"]
        SharedObj["Shared Objects"]:::planned
    end

    %% Relationships
    DM --> Parser
    TOML --> Parser
    GravityDM --> Parser
    Parser --> ExtParser
    ExtParser --> CompDef
    ExtParser --> SysDef
    ExtParser --> EntDef
    ExtParser --> MetaDef
    
    CompDef --> Validator
    SysDef --> Validator
    EntDef --> Validator
    MetaDef --> Validator
    
    Validator --> DepManager
    DepManager --> NameSpace
    NameSpace --> SymbolSys
    SymbolSys --> DSO
    
    NameSpace --> GameEngine
    SymbolSys --> LuaScript
    DSO --> SharedObj

    %% Click Events
    click GravityDM "https://github.com/H4tch/ModDoc/blob/master/examples/Gravity.dm"

    %% Styles
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef file fill:#b3e0ff,stroke:#333,stroke-width:1px
    classDef planned fill:#f0f0f0,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5
    classDef experimental fill:#ffe6cc,stroke:#333,stroke-width:1px
    
    %% Legend
    subgraph Legend
        L1["Regular Component"]
        L2["File Component"]:::file
        L3["Planned Feature"]:::planned
        L4["Experimental"]:::experimental
    end
```
