# dvdagames/gl1tch-pet architecture

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

- Interactive diagram: https://gitdiagram.com/dvdagames/gl1tch-pet
- Repository: https://github.com/dvdagames/gl1tch-pet

## Overview

##### Project Type and Purpose
- This is a small standalone desktop application (a “pet”) built with the Godot Game Engine.
- It currently only animates a sprite (“Shy Droid”) floating around, but is structured to eventually add interactive/helpful features.

##### File-Structure Analysis
- Top-level config:
- project.godot – main Godot project file
- .gitignore, .editorconfig, .gitattributes – repo and editor settings
- assets/
- sprites.tres – Godot resource file containing the pet sprite
- scenes/
- main_window.tscn – the root scene (game window container)
- pet.tscn – the floating pet scene (node tree defining the sprite and animations)
- scripts/
- main-window.gd – logic for the main window scene (e.g., loading the pet, input/events)
- pet.gd – logic for the pet’s behavior (floating, future interactions)

##### Key Architectural Insights from the README
- Uses Godot’s built-in scene system (scene graph of nodes).
- Written in GDScript (no separate backend or database yet).
- Intended to stay lightweight and desktop-focused.

##### Main Components
a. Godot Engine Core
- Scenes subsystem (scene graph & node management)
- Resource loader (assets like sprites.tres)
- Main loop (renders frames, processes physics, input, signals)
b. Scenes
- MainWindow Scene (root GUI/container)
- Pet Scene (child node group for the pet)
c. Script Components (GDScript Modules)
- main-window.gd (scene orchestration, event handling)
- pet.gd (behavior logic, animation control)
d. Assets
- sprites.tres (texture or sprite resource)

##### Relationships and Data Flow
- On startup, Godot Engine loads project.godot → initializes MainWindow Scene
- MainWindow script instantiates Pet Scene as a child node
- Pet.gd drives animations via Engine’s process(delta) callback
- Assets (sprites.tres) are fetched by the resource loader when the Pet scene is instanced
- Events or user inputs (future feature) would flow from Engine → MainWindow → Pet script

##### Architectural Patterns and Principles
- Scene-Graph Pattern: nested node trees defining UI and game objects
- Separation of Concerns:
- Scenes for structure
- Scripts for behavior
- Assets for resources
- Event-Driven Loop: Godot’s main loop calls _process() and signals for UI/logic

##### Final Recommendations
- Core loop: Engine → Scene instantiation → _process() in scripts → rendering.
- Every node/script/asset you see in the file tree is represented, so nothing is overlooked.
- Use descriptive labels and maintain consistent iconography throughout.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine Core
    subgraph "Godot Engine Core"
        Engine["Godot Engine"]:::engine
        SceneSys["Scenes Subsystem"]:::engine
        ResLoader["Resource Loader"]:::engine
        MainLoop["Main Loop"]:::engine
    end

    %% Scenes
    subgraph "Scenes"
        MainWindow["MainWindow.tscn"]:::scenes
        PetScene["Pet.tscn"]:::scenes
    end

    %% Scripts
    subgraph "Scripts"
        MWScript["main-window.gd"]:::scripts
        PetScript["pet.gd"]:::scripts
    end

    %% Assets
    sprites["sprites.tres"]:::assets

    %% Relationships
    Engine --> SceneSys
    Engine --> ResLoader
    Engine --> MainLoop
    Engine -->|"initializes"| MainWindow
    MainLoop -->|"process(delta)"| PetScript

    SceneSys --> MainWindow
    SceneSys --> PetScene

    MainWindow -->|"scene orchestration"| MWScript
    MWScript -->|"instantiates"| PetScene

    PetScene -->|"behavior logic"| PetScript
    PetScript -->|"loads resource"| ResLoader
    ResLoader -->|"fetches asset"| sprites

    %% Click Events
    click Engine "https://github.com/dvdagames/gl1tch-pet/blob/main/project.godot"
    click sprites "https://github.com/dvdagames/gl1tch-pet/blob/main/assets/sprites.tres"
    click MainWindow "https://github.com/dvdagames/gl1tch-pet/blob/main/scenes/main_window.tscn"
    click PetScene "https://github.com/dvdagames/gl1tch-pet/blob/main/scenes/pet.tscn"
    click MWScript "https://github.com/dvdagames/gl1tch-pet/blob/main/scripts/main-window.gd"
    click PetScript "https://github.com/dvdagames/gl1tch-pet/blob/main/scripts/pet.gd"

    %% Styles
    classDef engine fill:#f0f8ff,stroke:#0366d6,color:#0366d6;
    classDef scenes fill:#e6ffe6,stroke:#28a745,color:#28a745;
    classDef scripts fill:#fff5e6,stroke:#d73a49,color:#d73a49;
    classDef assets fill:#ffe6f2,stroke:#6f42c1,color:#6f42c1;
```
