# rthurmed/ceifador architecture

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

- Interactive diagram: https://gitdiagram.com/rthurmed/ceifador
- Repository: https://github.com/rthurmed/ceifador

## Overview

##### Project type and purpose
- This is a Godot‐based 2D action/shooter game (“Ceifador”) built with Godot v3.5.2.
- Purpose: the player moves, shoots magic bullets, drains enemy souls to gain energy, advances through stages and boss battles.

##### File structure
- Top level:
- project.godot – main Godot project file.
- assets/ – all art/sfx/music/fonts/animations.
- modules/ – reusable Godot modules (Debugging, Juice animations, Pause, StateMachine).
- src/ – all game scenes (.tscn) and scripts (.gd) organized by feature.
- src/ subfolders:
- common/ – generic gameplay elements (Bullet, Gun, Health).
- enemy/ – enemy scenes, boss folder, pattern folder.
- player/ – player scene, bullet, steal‐area.
- stages/ – Stage base class + individual levels and boss battles.
- util/ – utility scripts (AutoPathFollow, RandomPitchAudio, Util).
- Modules implement cross‐cutting concerns (state machine, camera juice effects, pause, debugging).

##### Architectural patterns and technologies
- Godot scene‐node system: each .tscn is a prefab with a root node and attached GDScript.
- Composition over inheritance: scenes assemble nodes (Player, Enemies, UI).
- State Machine module for enemy & game state transitions.
- “Juice” module for camera/shake/blink effects.
- Signal‐based communication between nodes (e.g. Player emits “shot,” Stage listens, UI updates).

##### Main components and interactions
a. Core runtime components:
- Game Manager / Main scene – orchestrates transitions (Intro → Stages → Outro).
- Stage Manager – instantiates StageX.tscn, spawns enemies, listens for stage complete.
- Player – handles input, movement, shooting, energy count.
- Enemy – various types plus boss, each with AI patterns via StateMachine.
- Projectiles – PlayerBullet, EnemyBullet as separate scenes.
- Collectibles – soul drops, health jars (DropHP, Drop).
- Audio Manager – plays music (Soundtrack.tscn) and SFX with RandomPitchAudio.
- Modules – DebugNode for debug overlay, Juice for camera feedback, Pause controls.

b. Data flows and relationships:
- Input → Player script → Movement, shooting → spawn PlayerBullet → physics collisions
- PlayerBullet → collides with Enemy → Enemy state machine → “die” → spawn Drop → emits “soul collected” → Player energy++ → UI updates
- Stage Manager listens for all enemies dead → next Stage or BossBattle scene.
- Pause module intercepts input to freeze game time.
- Juice module listens for events (hit, death) → triggers camera shake/blink.
- Audio Manager plays music loop, SFX on signals (shoot, hit, death).

c. Architectural patterns:
- Scene‐node composition (Godot standard)
- Modular plugins (modules/) for reusable functionality
- State machine for behavior isolation
- Event/signal‐driven communication

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer
    Godot["Godot v3.5.2 Engine"]:::engine

    %% Core Scenes
    subgraph "Core Scenes"
        Intro["Intro Scene"]:::core
        Main["Main Scene"]:::core
        Outro["Outro Scene"]:::core
        BackgroundParallax["Background Parallax"]:::core
        Soundtrack["Soundtrack Player"]:::core
    end

    %% Gameplay Layer
    subgraph "Gameplay"
        Player["Player"]:::gameplay
        PlayerBullet["Player Bullet"]:::gameplay
        Enemy["Enemy Base"]:::gameplay
        EnemyBullet["Enemy Bullet"]:::gameplay
        DropSoul["Soul Drop (Drop)"]:::gameplay
        DropHP["Health Jar Drop"]:::gameplay
        StageManager["Stage Manager"]:::gameplay
        subgraph "Stages"
            StageX["Stage1…n Scenes"]:::gameplay
            TestStages["TestStage1…4, TestEnemies"]:::gameplay
        end
        BossManager["Boss Battle Manager"]:::gameplay
        subgraph "Boss Battles"
            BossBattle1["BossBattleLVL1…3"]:::gameplay
        end
    end

    %% UI & Input Layer
    subgraph "UI & Input"
        InputHandler["Input Handler"]:::ui
        HUD["HUD / Energy Bar"]:::ui
        Retry["Retry Icon"]:::ui
        PauseOverlay["Pause Overlay"]:::ui
    end

    %% Audio Layer
    subgraph "Audio"
        SoundtrackPlayer["Music Player"]:::audio
        SFXController["RandomPitchAudio SFX"]:::audio
    end

    %% Modules Layer
    subgraph "Modules"
        StateMachineModule["StateMachine Module"]:::module
        JuiceModule["Juice Module"]:::module
        PauseModule["Pause Module"]:::module
        DebugModule["Debugging Module"]:::module
    end

    %% Assets
    Assets["Assets (Sprites, Audio, Fonts)"]:::assets

    %% Connections
    Godot --> CoreScenes
    CoreScenes --> Godot

    Godot --> Gameplay
    Godot --> UI_Input
    Godot --> Audio
    Godot --> Modules
    Godot --> Assets

    InputHandler -->|"input"| Player
    Player -->|"shoot"| PlayerBullet
    PlayerBullet -->|"hit"| Enemy
    Enemy -->|"die"| DropSoul
    DropSoul -->|"collect_soul"| Player
    Enemy -->|"shoot"| EnemyBullet
    EnemyBullet -.->|"hit"| Player
    Player -->|"pause_signal"| PauseModule
    Player -->|"event"| JuiceModule
    Enemy -->|"event"| JuiceModule
    Player -->|"sfx_shoot"| SFXController
    Enemy -->|"sfx_hit_death"| SFXController

    Main -->|"start_stage"| StageManager
    StageManager -->|"load_stage"| StageX
    StageManager -->|"load_test"| TestStages
    StageManager -->|"start_boss"| BossManager
    BossManager --> BossBattle1
    StageX -->|"complete"| StageManager

    Main -->|"show_HUD"| HUD
    Main --> Retry
    Main --> PauseOverlay
    Main --> BackgroundParallax
    Main --> SoundtrackPlayer

    %% Click Events
    click Main "https://github.com/rthurmed/ceifador/blob/main/src/Main.tscn"
    click Main "https://github.com/rthurmed/ceifador/blob/main/src/Main.gd"
    click Intro "https://github.com/rthurmed/ceifador/blob/main/src/Intro.tscn"
    click Intro "https://github.com/rthurmed/ceifador/blob/main/src/Intro.gd"
    click Outro "https://github.com/rthurmed/ceifador/blob/main/src/Outro.tscn"
    click Outro "https://github.com/rthurmed/ceifador/blob/main/src/Outro.gd"
    click BackgroundParallax "https://github.com/rthurmed/ceifador/blob/main/src/BackgroundParallax.tscn"
    click BackgroundParallax "https://github.com/rthurmed/ceifador/blob/main/src/BackgroundParallax.gd"
    click Soundtrack "https://github.com/rthurmed/ceifador/blob/main/src/Soundtrack.tscn"
    click StageManager "https://github.com/rthurmed/ceifador/blob/main/src/stages/Stage.gd"
    click StageX "https://github.com/rthurmed/ceifador/blob/main/src/stages/Stage1.tscn"
    click StageX "https://github.com/rthurmed/ceifador/blob/main/src/stages/Stage9.tscn"
    click TestStages "https://github.com/rthurmed/ceifador/blob/main/src/stages/TestStage1.tscn"
    click TestStages "https://github.com/rthurmed/ceifador/blob/main/src/stages/TestStage4.tscn"
    click TestStages "https://github.com/rthurmed/ceifador/blob/main/src/stages/TestEnemies.tscn"
    click BossManager "https://github.com/rthurmed/ceifador/blob/main/src/stages/boss/BossBattle.gd"
    click BossBattle1 "https://github.com/rthurmed/ceifador/blob/main/src/stages/boss/BossBattleLVL1.tscn"
    click BossBattle1 "https://github.com/rthurmed/ceifador/blob/main/src/stages/boss/BossBattleLVL3.tscn"
    click Player "https://github.com/rthurmed/ceifador/blob/main/src/player/Player.tscn"
    click Player "https://github.com/rthurmed/ceifador/blob/main/src/player/Player.gd"
    click PlayerBullet "https://github.com/rthurmed/ceifador/blob/main/src/player/PlayerBullet.tscn"
    click PlayerStealArea "https://github.com/rthurmed/ceifador/blob/main/src/player/StealArea.gd"
    click Enemy "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Enemy.tscn"
    click Enemy "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Enemy.gd"
    click EnemyBullet "https://github.com/rthurmed/ceifador/blob/main/src/enemy/EnemyBullet.tscn"
    click DropSoul "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Drop.gd"
    click DropHP "https://github.com/rthurmed/ceifador/blob/main/src/enemy/DropHP.tscn"
    click Heavy "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Heavy.tscn"
    click Mage "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Mage.tscn"
    click Possessed "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Possessed.tscn"
    click Tier1 "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Tier1.tscn"
    click RotatingPattern "https://github.com/rthurmed/ceifador/blob/main/src/enemy/pattern/Rotating.tscn"
    click RotatingPattern "https://github.com/rthurmed/ceifador/blob/main/src/enemy/Rotating.gd"
    click WraithLVL1 "https://github.com/rthurmed/ceifador/blob/main/src/enemy/boss/WraithLVL1.tscn"
    click WraithLVL3 "https://github.com/rthurmed/ceifador/blob/main/src/enemy/boss/WraithLVL3.tscn"
    click LifeBar "https://github.com/rthurmed/ceifador/blob/main/src/enemy/boss/LifeBar.gd"
    click BulletLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Bullet.tscn"
    click BulletLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Bullet.gd"
    click GunLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Gun.tscn"
    click GunLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Gun.gd"
    click HealthLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Health.tscn"
    click HealthLogic "https://github.com/rthurmed/ceifador/blob/main/src/common/Health.gd"
    click Retry "https://github.com/rthurmed/ceifador/blob/main/src/ui/RetryIcon.tscn"
    click UI_Retries "https://github.com/rthurmed/ceifador/blob/main/src/UI-Retries.gd"
    click AutoPath "https://github.com/rthurmed/ceifador/blob/main/src/util/AutoPathFollow.tscn"
    click AutoPath "https://github.com/rthurmed/ceifador/blob/main/src/util/AutoPathFollow.gd"
    click RandomPitchAudio "https://github.com/rthurmed/ceifador/blob/main/src/util/RandomPitchAudio.tscn"
    click RandomPitchAudio "https://github.com/rthurmed/ceifador/blob/main/src/util/RandomPitchAudio.gd"
    click Util "https://github.com/rthurmed/ceifador/blob/main/src/util/Util.gd"
    click JuiceModule "https://github.com/rthurmed/ceifador/tree/main/modules/Juice/"
    click StateMachineModule "https://github.com/rthurmed/ceifador/blob/main/modules/StateMachine/StateMachine.tscn"
    click StateMachineModule "https://github.com/rthurmed/ceifador/blob/main/modules/StateMachine/StateMachine.gd"
    click StateMachineModule "https://github.com/rthurmed/ceifador/blob/main/modules/StateMachine/State.gd"
    click PauseModule "https://github.com/rthurmed/ceifador/blob/main/modules/Pause/Pause.tscn"
    click PauseModule "https://github.com/rthurmed/ceifador/blob/main/modules/Pause/Pause.gd"
    click DebugModule "https://github.com/rthurmed/ceifador/blob/main/modules/Debugging/DebugNode.tscn"
    click DebugModule "https://github.com/rthurmed/ceifador/blob/main/modules/Debugging/DebugNode.gd"
    click Assets "https://github.com/rthurmed/ceifador/tree/main/assets/"

    %% Styles
    classDef engine fill:#222222,color:#fff,stroke:#555,stroke-width:2px
    classDef core fill:#a2d2ff,stroke:#0476d0,color:#000
    classDef gameplay fill:#caf0f8,stroke:#00b4d8,color:#000
    classDef ui fill:#d8f3dc,stroke:#2d6a4f,color:#000
    classDef audio fill:#ffd6a5,stroke:#fb8500,color:#000
    classDef module fill:#e0e0e0,stroke:#999,color:#000
    classDef assets fill:#fff3b0,stroke:#d4a373,color:#000
```
