# phazorknight/cogito architecture

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

- Interactive diagram: https://gitdiagram.com/phazorknight/cogito
- Repository: https://github.com/phazorknight/cogito

## Overview

##### Project type and purpose
- COGITO is a Godot 4 “Immersive Sim” template project, not a web app. It provides a modular, component-based framework (player controller, interaction system, inventory, NPCs, quests, UI, audio) that plugs into the Godot engine via add-ons.

##### High-level architecture analysis
- Top-level: Godot Engine ← project.godot
- -ons folder: each add-on (cogito, input_helper, quick_audio) is a self-contained plugin registered via plugin.cfg
- Inside “addons/cogito”: dozens of submodules (Components, SceneManagement, InventoryPD, QuestSystem, EasyMenus, DynamicFootstepSystem, etc.), each exposing Scenes (.tscn), Scripts (.gd), and Resources (.tres)
- README & docs point to a component‐based, modular design: systems are loosely coupled, accessible via global scripts (cogito_globals.gd) or scene manager

##### Main components
A. Godot Engine Core
- Resource pipeline (Assets → imported formats)
- Scene tree management (SceneManager, Scenes)
- Input dispatch (InputHelper add-on)
- Audio bus & playback (Godot audio + quick_audio)
B. COGITO Plugin
- Core entry point: plugin.cfg + cogito_plugin.gd
- Globals & settings: cogito_globals.gd, cogito_settings.gd
- SceneManagement module (loading, persistence)
- Player Controller module (first-person controller, DynamicFootstepSystem)
- Interaction System (Components subfolder)
- Inventory System (InventoryPD)
- NPC & Enemy System (CogitoNPC, Enemies)
- Quest System (QuestSystem)
- UI & Menus (EasyMenus + HUD Scenes)
- Theme & VFX
C. External integrations
- Dialogic / Dialogue Manager (plugins not under addons/cogito)
D. Demo Scenes
- Prefabs & DemoScenes illustrate how modules compose into levels

##### Relationships & data flows
- Engine → loads plugin → registers scene types & systems
- SceneManager → instantiates Scenes → root SceneTree
- InputHelper → captures input → forwards to PlayerController & EasyMenus
- PlayerController → moves camera & physics → triggers DynamicFootstepSystem
- InteractionSystem Components (attached to scene nodes) ← query PlayerController state & Attributes
- InventoryPD ↔ Scenes & UI
- NPCSystem ↔ NavigationAgent → interacts with Player via line-of-sight events
- QuestSystem → listens for events (Scene transitions, Inventory changes) → updates UI via ui_quest_hud
- Audio → quick_audio + Godot buses → play SFX (footsteps, interactions)
- VFX → instantiated by scripts (explosion, bullet decals)

##### Architectural patterns & principles
- Plugin-based modular architecture: each feature lives in its own folder/add-on with its own plugin.cfg or registration script
- Component-based design: behaviors are scripts (Components/*.gd) attached to scene nodes, encouraging composition over inheritance
- Scene-resource separation: .tscn for structure & layout, .gd for logic, .tres for data
- Global managers: cogito_globals, scene_manager, quest_manager coordinate cross‐cutting concerns
- Loose coupling via signals/events: modules communicate via Godot’s signal system (e.g., player_entered_zone, quest_completed)

## Diagram (Mermaid)

```mermaid
flowchart TB
    GodotEngine["Godot Engine Core\n(project.godot)"]:::engine
    subgraph "Add-ons"
        subgraph "COGITO Plugin"
            CogitoPlugin["COGITO Plugin Entry\n(plugin.cfg & cogito_plugin.gd)"]:::addon
            subgraph "Globals & Settings"
                Globals["cogito_globals.gd"]:::module
                Settings["cogito_settings.gd"]:::module
            end
            subgraph "Scene Management"
                SceneManager["SceneManager\n(cogito_scene_manager.gd)"]:::module
                LoadingScene["LoadingScene.tscn"]:::scene
            end
            subgraph "Player Controller"
                PlayerHUDMgr["player_hud_manager.gd"]:::module
                Footsteps["DynamicFootstepSystem"]:::module
            end
            subgraph "Interaction System"
                Interactions["Components"]:::module
            end
            subgraph "Inventory System"
                Inventory["InventoryPD"]:::module
            end
            subgraph "NPC & Enemy System"
                NPCs["CogitoNPC"]:::module
                Enemies["Enemies"]:::module
            end
            subgraph "Quest System"
                Quests["QuestSystem"]:::module
            end
            subgraph "UI & Menus"
                EasyMenus["EasyMenus"]:::module
                HUD["Player_HUD.tscn"]:::scene
            end
            subgraph "Theme & VFX"
                Theme["Theme"]:::module
                VFX["VFX Assets"]:::module
            end
            subgraph "Demo Scenes"
                Demo["DemoScenes"]:::module
            end
            subgraph "Global Scripts"
                Utils["Scripts"]:::module
            end
        end
        InputHelper["Input Dispatch\n(input_helper)"]:::addon
        QuickAudio["Audio Bus & Playback\n(quick_audio)"]:::addon
        DialogicExt["Dialogic Integration"]:::addon
    end

    GodotEngine --> CogitoPlugin
    GodotEngine --> InputHelper
    GodotEngine --> QuickAudio

    InputHelper --> PlayerHUDMgr
    InputHelper --> EasyMenus

    PlayerHUDMgr --> Footsteps
    Footsteps --> QuickAudio

    InputHelper --> Interactions
    Interactions --> PlayerHUDMgr

    CogitoPlugin --> Globals
    CogitoPlugin --> SceneManager
    SceneManager --> LoadingScene

    Inventory <--> HUD
    NPCs --> PlayerHUDMgr
    Quests --> HUD

    QuickAudio --> QuickAudio

    click GodotEngine "https://github.com/phazorknight/cogito/blob/main/project.godot"
    click InputHelper "https://github.com/phazorknight/cogito/tree/main/addons/input_helper"
    click QuickAudio "https://github.com/phazorknight/cogito/tree/main/addons/quick_audio"
    click CogitoPlugin "https://github.com/phazorknight/cogito/blob/main/addons/cogito/plugin.cfg"
    click CogitoPlugin "https://github.com/phazorknight/cogito/blob/main/addons/cogito/cogito_plugin.gd"
    click Globals "https://github.com/phazorknight/cogito/blob/main/addons/cogito/cogito_globals.gd"
    click Settings "https://github.com/phazorknight/cogito/blob/main/addons/cogito/cogito_settings.gd"
    click SceneManager "https://github.com/phazorknight/cogito/tree/main/addons/cogito/SceneManagement"
    click PlayerHUDMgr "https://github.com/phazorknight/cogito/blob/main/addons/cogito/Scripts/player_hud_manager.gd"
    click Footsteps "https://github.com/phazorknight/cogito/tree/main/addons/cogito/DynamicFootstepSystem"
    click Interactions "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Components"
    click Inventory "https://github.com/phazorknight/cogito/tree/main/addons/cogito/InventoryPD"
    click NPCs "https://github.com/phazorknight/cogito/tree/main/addons/cogito/CogitoNPC"
    click Enemies "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Enemies"
    click Quests "https://github.com/phazorknight/cogito/tree/main/addons/cogito/QuestSystem"
    click EasyMenus "https://github.com/phazorknight/cogito/tree/main/addons/cogito/EasyMenus"
    click HUD "https://github.com/phazorknight/cogito/blob/main/addons/cogito/PackedScenes/Player_HUD.tscn"
    click Theme "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Theme"
    click VFX "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Assets/VFX"
    click Demo "https://github.com/phazorknight/cogito/tree/main/addons/cogito/DemoScenes"
    click Utils "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Scripts"
    click DialogicExt "https://github.com/phazorknight/cogito/tree/main/addons/cogito/Components/Interactions/DialogicInteraction"

    classDef engine fill:#dddddd,stroke:#888888;
    classDef addon fill:#bbdffd,stroke:#3399ff;
    classDef module fill:#dfffbf,stroke:#33aa00;
    classDef scene stroke-dasharray:5 5,fill:#ffffff;
```
