# inbestigator/godact architecture

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

- Interactive diagram: https://gitdiagram.com/inbestigator/godact
- Repository: https://github.com/inbestigator/godact

## Overview

Based on our analysis of the file tree and README, this project is a conversion tool—specifically, a library that lets you write React components and have them converted into Godot scenes along with transpiling TypeScript/JavaScript code into GDScript. It leverages a React-like syntax for declaring Godot nodes (e.g., Node2D, Sprite2D, CollisionShape2D, etc.) and provides various categories (visual, physics, controls, etc.) as well as examples to illustrate its use.

##### Main Components
- Client/Developer Code (React Components): Representing the high-level UI and game scene definitions. This is where the user writes their game logic and scene composition using React’s component syntax.
- Conversion Engine: The core logic contained in the “lib” directory. This includes:
- Node Definitions and Their Renderers (e.g., files in lib/core/nodes/* and nodes within categories such as physics, visual, controls). This part maps React components to Godot nodes.
- Internal Utilities such as the container, reconciler, renderer, and helper files under lib/internal.
- Transpiler: The module in lib/internal (e.g., ts2gd.ts) that converts TypeScript/JavaScript logic into GDScript code.
- Examples: Demonstrative projects (found under the examples directory) that provide practical scenarios of converting React components (such as a logo or platformer game) into corresponding Godot scenes.
- Test Suite: The tests directory, ensuring correctness of transformations and node behaviors.

##### Relationships and Interactions
- The input layers come from the React components written by the user. These components call the conversion functions such as createGodactScene.
- The Conversion Engine processes the component tree, mapping each node (based on its type/category) to a corresponding Godot node. It uses the files in lib/core/nodes and lib/core/resources.
- The Transpiler branch (ts2gd.ts) then takes the converted scene or behavior logic and outputs valid GDScript code.
- The examples serve both as validation and as usage models for how the components are intended to interact.
- Continuous Integration is maintained via the GitHub workflows (in .github/workflows), ensuring that tests and publishing steps are executed correctly.

##### Architectural Patterns/Design Principles
- Component-Based Design: The project is built around individual “node” components that have independent logic and properties. The separation by directory (controls, physics, visual) reflects this modularity.
- Declarative UI Programming: Using React-like syntax to declaratively define Godot scenes.
- Transpilation Pipeline: A clear transformation chain from React components to Godot scene definitions and from TypeScript/JavaScript to GDScript.
- Extensibility: The node registry table in the README and the organized node directories show that new nodes can be added or extended upon request.

##### Relevant Technologies, Frameworks, and Libraries
- Deno (deno.json indicates that this is likely built on Deno, providing the runtime for TypeScript).
- TypeScript/React (as the input and component definition language).
- Godot (the target runtime, with nodes, scenes, and GDScript).
- GitHub Actions and related configuration files for CI/CD.
- Internal helper libraries such as ts2gd for transpilation and the internal reconciler and renderer logic.

##### Final Details
- Clarity and thoroughness – each directory (or group) should be distinctly represented so that someone reviewing the architecture can track how a React component is transformed into a Godot scene.
- To capture both compile-time and runtime stages, showing how the TypeScript/React code becomes the final GDScript and scene definitions.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    ReactInput["React Components (User Code)"]:::user

    %% Conversion Engine Subgraph
    subgraph "Conversion Engine"
        NodeDefinitions["Node Definitions"]:::engine
        ResourceManagement["Resource Management"]:::engine
        InternalUtilities["Internal Utilities"]:::engine
        NodeDefinitions --> ResourceManagement
        ResourceManagement --> InternalUtilities
    end

    %% Main Pipeline
    ReactInput -->|"processes"| NodeDefinitions
    InternalUtilities -->|"passes conversion to"| Transpiler["Transpiler (ts2gd)"]:::transpiler
    Transpiler -->|"generates"| Output["Godot Scenes & GDScript Output"]:::output

    %% Examples Subgraph
    subgraph "Examples"
        LogoExample["Logo Example"]:::examples
        PlatformerExample["Platformer Example"]:::examples
        LogoExample --> PlatformerExample
    end
    ReactInput ---|"demo usage"| LogoExample

    %% Test Suite and Deployment/CI
    TestSuite["Test Suite"]:::test
    CI["Deployment/CI"]:::deploy
    Output ---|"validated by"| TestSuite
    TestSuite ---|"triggers"| CI

    %% Click Events
    click NodeDefinitions "https://github.com/inbestigator/godact/tree/main/lib/core/nodes"
    click ResourceManagement "https://github.com/inbestigator/godact/tree/main/lib/core/resources"
    click InternalUtilities "https://github.com/inbestigator/godact/tree/main/lib/internal"
    click Transpiler "https://github.com/inbestigator/godact/blob/main/lib/internal/ts2gd.ts"
    click LogoExample "https://github.com/inbestigator/godact/tree/main/examples/logo"
    click PlatformerExample "https://github.com/inbestigator/godact/tree/main/examples/platformer"
    click TestSuite "https://github.com/inbestigator/godact/tree/main/tests"
    click CI "https://github.com/inbestigator/godact/tree/main/.github/workflows"
    
    %% Styles
    classDef user fill:#bbf,stroke:#333,stroke-width:2px;
    classDef engine fill:#afa,stroke:#333,stroke-width:2px;
    classDef transpiler fill:#ffb,stroke:#333,stroke-width:2px;
    classDef output fill:#fea,stroke:#333,stroke-width:2px;
    classDef examples fill:#cff,stroke:#333,stroke-width:2px;
    classDef test fill:#fbb,stroke:#333,stroke-width:2px;
    classDef deploy fill:#d9b,stroke:#333,stroke-width:2px;
```
