# marct1me/pyqc architecture

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

- Interactive diagram: https://gitdiagram.com/marct1me/pyqc
- Repository: https://github.com/marct1me/pyqc

## Overview

1. **Top-level split: engine, game content, and user data**
   - The repository is organized into three clear boundaries:
     - `QuantumCore/` = the reusable engine/runtime layer.
     - `core/` = game-specific content and scripts.
     - `GameData/` = externalized player data, configuration, saves, and mods.
   - This separation is the main architectural feature to reflect in a diagram.

2. **Entry point and runtime bootstrap**
   - `main.pyw` is the launch entry for the packaged game.
   - It likely boots the engine, loads config, creates the rendering window/context, and then starts the main scene loop.
   - `Quantum game.lnk` is just a desktop shortcut artifact, not part of the architecture.

3. **Engine core responsibilities**
   - `QuantumCore/app.py`, `scene.py`, `model.py`, and `time.py` suggest the engine owns:
     - application lifecycle,
     - scene management,
     - 3D model abstraction,
     - frame timing/update cadence.
   - `QuantumCore/__init__.py` exposes the package boundary.

4. **Rendering subsystem**
   - `QuantumCore/graphic/` contains the low-level graphics pipeline:
     - `camera.py` for viewpoint/matrix state,
     - `light.py` for lighting,
     - `shader_program.py` for GLSL program management,
     - `vao.py`, `vbo.py`, `texture.py`, `mash.py` for GPU resource binding and mesh/texture handling.
   - The README indicates rendering is done with **ModernGL/OpenGL**, with GLSL shaders stored in `QuantumCore/data/shaders/`.

5. **Asset and shader pipeline**
   - Engine assets live under `QuantumCore/data/`:
     - `models/` for OBJ/MTL content and generated sidecars like `.bin` and `.json`,
     - `textures/`,
     - `shaders/`,
     - `messages/` for UI/message resources,
     - config files such as `config.py`, `graphic.config`, and `settings.config`.
   - The model directory structure implies the engine loads external model files, then caches or preprocesses them into binary/JSON helpers.

6. **UI and in-game interface layer**
   - UI exists in both engine and game layers:
     - `QuantumCore/UI.py`, `widgets.py`, and `graphic/interface.py` look like reusable UI primitives.
     - `core/UI/` contains game-specific interface definitions (`ingame_interface.py`, `.itrf` files).
   - This suggests a layered UI model: generic engine widgets plus game-specific screens and layouts.

7. **Message and screen subsystem**
   - `QuantumCore/messages/err_screen.py` and `loading_screen.py` indicate engine-level screens for startup and error handling.
   - These are likely used during bootstrap and asset loading before the main scene is active.

8. **Game-specific content layer**
   - `core/elements/entities.py` and `locations.py` define gameplay objects and world/scene content.
   - `core/skripts.py` likely contains gameplay logic or scenario scripting.
   - `core/models/`, `core/textures/`, and `core/sounds/` provide the game’s unique assets, distinct from the engine’s reusable assets.

9. **Persistence, configuration, and modding**
   - `GameData/config.json` and `GameData/settings.py` handle user/runtime settings outside the engine package.
   - `GameData/saves/` contains persisted game state files (`.sav`).
   - `GameData/mods/unitext/` is a mod/plugin namespace, implying extensibility through Python modules loaded at runtime.

10. **Runtime dependencies that shape the architecture**
   - The engine depends on **Pygame** for windowing/input and **ModernGL/OpenGL** for rendering.
   - **Numpy**, **PyGLM**, and **PyWavefront** support math and model loading.
   - **Loguru** suggests structured runtime logging.
   - The README also mentions **Bullet Physics** and **Cython**, which indicates the project is designed with future/optional physics and performance optimization in mind.

11. **Likely data flow through the system**
   - Launch starts in `main.pyw` → engine app/config initialization → asset loading from `QuantumCore/data` and `core/` → scene creation → per-frame update/render loop.
   - During runtime, gameplay state is driven by `entities/locations/scripts`, rendered through the graphics layer, and overlaid with UI/widgets/messages.
   - Saves, settings, and mods are kept outside the engine code so content can change without rebuilding the core package.

12. **What to emphasize in an architecture diagram**
   - Show a hard boundary between **engine runtime** and **game content**.
   - Show **graphics pipeline** as a separate subsystem fed by models/shaders/textures.
   - Show **UI/messages** as an overlay layer above scenes.
   - Show **GameData** as persistent external state used by the runtime, not compiled into the engine.

Main entry points: [`QuantumCore/scene.py`](https://github.com/marct1me/pyqc/blob/master/QuantumCore/scene.py) (Scene), [`QuantumCore/app.py`](https://github.com/marct1me/pyqc/blob/master/QuantumCore/app.py) (App), [`QuantumCore/graphic/interface.py`](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/interface.py) (Interface), [`QuantumCore/graphic/shader_program.py`](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/shader_program.py) (Shaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry"]
  node_main["main.pyw<br/>launcher<br/>[main.pyw]"]
end

subgraph group_engine["QuantumCore"]
  node_app["App<br/>runtime<br/>[app.py]"]
  node_scene["Scene<br/>world loop<br/>[scene.py]"]
  node_model["Model<br/>[model.py]"]
  node_time["Time<br/>frame timing<br/>[time.py]"]
  node_core_init["__init__<br/>package boundary<br/>[__init__.py]"]
end

subgraph group_graphics["Graphics"]
  node_camera["Camera<br/>view state<br/>[camera.py]"]
  node_light["Light<br/>[light.py]"]
  node_shader["Shaders<br/>program mgmt<br/>[shader_program.py]"]
  node_gpu["GPU buffers<br/>mesh pipeline<br/>[vao.py]"]
  node_graphics_iface["Interface<br/>render UI<br/>[interface.py]"]
end

subgraph group_ui["UI / Screens"]
  node_widgets["Widgets<br/>ui primitives<br/>[widgets.py]"]
  node_messages["Screens<br/>[loading_screen.py]"]
end

subgraph group_game["core"]
  node_game_ui["Ingame UI"]
  node_entities["Entities<br/>game objects<br/>[entities.py]"]
  node_locations["Locations<br/>world data<br/>[locations.py]"]
  node_scripts["Scripts<br/>game logic<br/>[skripts.py]"]
end

subgraph group_data["GameData"]
  node_mod["Mods<br/>plugin module<br/>[mod_data.py]"]
  node_config["Config<br/>settings<br/>[config.json]"]
  node_saves[("Saves<br/>persistent state<br/>[data.sav]")]
end

node_main -->|"launches"| node_app
node_app -->|"imports"| node_core_init
node_app -->|"reads"| node_config
node_app -->|"starts"| node_scene
node_scene -->|"ticks"| node_time
node_scene -->|"uses"| node_model
node_scene -->|"views"| node_camera
node_scene -->|"lights"| node_light
node_scene -->|"hosts"| node_entities
node_scene -->|"loads"| node_locations
node_scene -->|"executes"| node_scripts
node_scene -->|"overlays"| node_game_ui
node_game_ui -->|"builds on"| node_widgets
node_messages -->|"uses"| node_widgets
node_app -->|"shows"| node_messages
node_scene -->|"renders"| node_graphics_iface
node_graphics_iface -->|"binds"| node_shader
node_graphics_iface -->|"draws"| node_gpu
node_shader -.->|"drives"| node_gpu
node_app -->|"loads"| node_mod
node_app -->|"persists"| node_saves

click node_main "https://github.com/marct1me/pyqc/blob/master/main.pyw"
click node_app "https://github.com/marct1me/pyqc/blob/master/QuantumCore/app.py"
click node_scene "https://github.com/marct1me/pyqc/blob/master/QuantumCore/scene.py"
click node_model "https://github.com/marct1me/pyqc/blob/master/QuantumCore/model.py"
click node_time "https://github.com/marct1me/pyqc/blob/master/QuantumCore/time.py"
click node_core_init "https://github.com/marct1me/pyqc/blob/master/QuantumCore/__init__.py"
click node_camera "https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/camera.py"
click node_light "https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/light.py"
click node_shader "https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/shader_program.py"
click node_gpu "https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/vao.py"
click node_graphics_iface "https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/interface.py"
click node_widgets "https://github.com/marct1me/pyqc/blob/master/QuantumCore/widgets.py"
click node_messages "https://github.com/marct1me/pyqc/blob/master/QuantumCore/messages/loading_screen.py"
click node_game_ui "https://github.com/marct1me/pyqc/blob/master/core/UI/ingame_interface.py"
click node_entities "https://github.com/marct1me/pyqc/blob/master/core/elements/entities.py"
click node_locations "https://github.com/marct1me/pyqc/blob/master/core/elements/locations.py"
click node_scripts "https://github.com/marct1me/pyqc/blob/master/core/skripts.py"
click node_mod "https://github.com/marct1me/pyqc/blob/master/GameData/mods/unitext/mod_data.py"
click node_config "https://github.com/marct1me/pyqc/blob/master/GameData/config.json"
click node_saves "https://github.com/marct1me/pyqc/blob/master/GameData/saves/data.sav"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_app,node_scene,node_model,node_time,node_core_init toneAmber
class node_camera,node_light,node_shader,node_gpu,node_graphics_iface toneMint
class node_widgets,node_messages toneRose
class node_game_ui,node_entities,node_locations,node_scripts toneIndigo
class node_mod,node_config,node_saves toneTeal
```

## Components

### Entry

Startup and package boundary

- [main.pyw](https://github.com/marct1me/pyqc/blob/master/main.pyw): launcher · Packaged game entry point · `main.pyw`

### QuantumCore

Reusable engine and runtime

- [App](https://github.com/marct1me/pyqc/blob/master/QuantumCore/app.py): runtime · Application lifecycle and bootstrap · `QuantumCore/app.py`
- [Scene](https://github.com/marct1me/pyqc/blob/master/QuantumCore/scene.py): world loop · Scene management and runtime flow · `QuantumCore/scene.py`
- [Model](https://github.com/marct1me/pyqc/blob/master/QuantumCore/model.py): asset model · Engine-level model abstraction · `QuantumCore/model.py`
- [Time](https://github.com/marct1me/pyqc/blob/master/QuantumCore/time.py): frame timing · Update cadence and frame timing · `QuantumCore/time.py`
- [__init__](https://github.com/marct1me/pyqc/blob/master/QuantumCore/__init__.py): package boundary · Engine package export boundary · `QuantumCore/__init__.py`

### Graphics

Rendering pipeline and GPU resources

- [Camera](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/camera.py): view state · View and projection state · `QuantumCore/graphic/camera.py`
- [Light](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/light.py): lighting · Scene lighting state · `QuantumCore/graphic/light.py`
- [Shaders](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/shader_program.py): program mgmt · GLSL program compilation and binding · `QuantumCore/graphic/shader_program.py`
- [GPU buffers](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/vao.py): mesh pipeline · VAO/VBO, mesh, and texture bindings · `QuantumCore/graphic/vao.py`
- [Interface](https://github.com/marct1me/pyqc/blob/master/QuantumCore/graphic/interface.py): render UI · Renderable interface layer · `QuantumCore/graphic/interface.py`

### UI / Screens

Reusable widgets and engine screens

- [Widgets](https://github.com/marct1me/pyqc/blob/master/QuantumCore/widgets.py): ui primitives · Reusable UI widgets · `QuantumCore/widgets.py`
- [Screens](https://github.com/marct1me/pyqc/blob/master/QuantumCore/messages/loading_screen.py): system screens · Loading and error screens · `QuantumCore/messages/loading_screen.py`

### core

Game-specific content and logic

- [Ingame UI](https://github.com/marct1me/pyqc/blob/master/core/UI/ingame_interface.py): game ui · Game-specific interface definitions · `core/UI/ingame_interface.py`
- [Entities](https://github.com/marct1me/pyqc/blob/master/core/elements/entities.py): game objects · Gameplay objects and entity definitions · `core/elements/entities.py`
- [Locations](https://github.com/marct1me/pyqc/blob/master/core/elements/locations.py): world data · World and location content · `core/elements/locations.py`
- [Scripts](https://github.com/marct1me/pyqc/blob/master/core/skripts.py): game logic · Scenario and gameplay scripting · `core/skripts.py`

### GameData

External player data, settings, saves, and mods

- [Mods](https://github.com/marct1me/pyqc/blob/master/GameData/mods/unitext/mod_data.py): plugin module · Runtime-extensible unitext mod namespace · `GameData/mods/unitext/mod_data.py`
- [Config](https://github.com/marct1me/pyqc/blob/master/GameData/config.json): settings · External configuration and runtime settings · `GameData/config.json`
- [Saves](https://github.com/marct1me/pyqc/blob/master/GameData/saves/data.sav): persistent state · Stored save-game data · `GameData/saves/data.sav`

## Connections

- main.pyw → App: launches · Starts the engine runtime
- App → __init__: imports · Uses the engine package boundary
- App → Config: reads · Loads external runtime settings
- App → Scene: starts · Creates and runs the active scene
- Scene → Time: ticks · Drives frame/update cadence
- Scene → Model: uses · Consumes engine model abstraction
- Scene → Camera: views · Updates viewpoint for rendering
- Scene → Light: lights · Supplies lighting state to render passes
- Scene → Entities: hosts · Contains gameplay objects
- Scene → Locations: loads · Pulls world/location content
- Scene → Scripts: executes · Runs gameplay scripting
- Scene → Ingame UI: overlays · Displays game-specific interface
- Ingame UI → Widgets: builds on · Uses reusable UI primitives
- Screens → Widgets: uses · System screens share UI primitives
- App → Screens: shows · Uses loading and error screens during bootstrap
- Scene → Interface: renders · Feeds the renderable interface layer
- Interface → Shaders: binds · Uses shader programs for drawing
- Interface → GPU buffers: draws · Uses GPU buffers and textures
- Shaders → GPU buffers: drives · Shaders operate over GPU resources
- App → Mods: loads · Optional runtime plugin/content extension
- App → Saves: persists · Reads and writes save-state data
