# mrde4olt/sdage architecture

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

- Interactive diagram: https://gitdiagram.com/mrde4olt/sdage
- Repository: https://github.com/mrde4olt/sdage

## Overview

1. **High-level shape**
   - This is a small game project organized around a **core game loop**, **scene-based UI**, and a separate **domain layer** for gameplay rules/state.
   - The repository is split more like a classic game architecture than a web/app architecture.

2. **Entry point and app bootstrap**
   - `main.py` is the likely startup entry point.
   - `settings.py` and `data/config.py` appear to hold runtime/game configuration such as window, timing, and gameplay constants.

3. **Core runtime**
   - `core/game.py` is the central orchestrator: it likely owns the main loop, scene transitions, and top-level update/render flow.
   - `core/gamestate.py` probably defines the active mode/state of the game and current scene context.
   - `core/timer.py` provides time-based mechanics used by gameplay or UI transitions.
   - `core/events.py` looks like the internal event channel used to decouple gameplay, UI, and audio.

4. **Domain layer: gameplay rules and state**
   - The `domain/` package contains the actual game mechanics and world state:
     - `anxiety.py`
     - `boss.py`
     - `doors.py`
     - `office_state.py`
     - `report.py`
     - `work.py`
     - `day_session.py`
   - These modules likely model the player’s day/session flow, task progression, pressure/anxiety systems, and office-specific constraints.
   - This layer should be treated as the game’s “truth” layer, separate from presentation.

5. **Scene-based presentation layer**
   - `ui/scenes/` contains the major screens/modes:
     - `menu_scene.py`
     - `office_scene.py`
     - `work_monitor_scene.py`
     - `relax_monitor_scene.py`
     - `report_monitor_scene.py`
     - `game_over_scene.py`
     - `win_scene.py`
   - This strongly suggests the game flows through a **scene/state machine**: menu → gameplay scenes → end states.
   - Scenes likely handle input, draw the screen, and call into domain objects to advance gameplay.

6. **Overlay and reusable widgets**
   - `ui/overlay.py` is probably a shared HUD or cross-scene overlay used during gameplay.
   - `ui/widgets/` contains reusable UI controls:
     - `button.py`
     - `progress_bar.py`
   - These are presentation primitives used by scenes rather than containing game rules.

7. **Audio subsystem**
   - `audio/audio_manager.py` centralizes sound playback.
   - `audio/sound_events.py` likely maps gameplay or core events to sound effects/music cues.
   - This indicates audio is event-driven rather than tightly coupled to scenes.

8. **Data and tuning**
   - `data/balance.py` and `data/config.py` separate tunable numbers from code.
   - `data/balance.py` likely contains gameplay pacing and difficulty values.
   - This makes balancing and iteration independent from the domain logic.

9. **Assets**
   - `assets/fonts/` and `assets/images/` store visual resources.
   - `audio/` is both a code package and likely the source for sound assets elsewhere in the repo.
   - The project appears to be file-asset driven, with scenes and widgets loading local resources.

10. **Probable data flow**
   - Input enters through the active scene.
   - The scene updates domain state objects in `domain/`.
   - Domain changes emit core events or state changes through `core/events.py`.
   - `audio/audio_manager.py` reacts to sound events.
   - UI scenes/widgets render the current state back to the player.
   - `core/game.py` coordinates this loop and decides when to switch scenes.

11. **Key boundaries for an architecture diagram**
   - **Bootstrap/runtime boundary:** `main.py`, `settings.py`, `core/game.py`
   - **Game rules boundary:** `domain/*`
   - **UI/presentation boundary:** `ui/scenes/*`, `ui/widgets/*`, `ui/overlay.py`
   - **Support services:** `audio/*`, `core/events.py`, `core/timer.py`
   - **Static content/configuration:** `assets/*`, `data/*`

12. **Likely architectural style**
   - The repo uses a **layered, event-driven game architecture** with a **scene/state machine** at the top.
   - The important relationship is: **core loop drives scenes; scenes manipulate domain state; events bridge to audio and UI effects**.

Main entry points: [`core/game.py`](https://github.com/mrde4olt/sdage/blob/main/core/game.py) (Game loop), [`domain/day_session.py`](https://github.com/mrde4olt/sdage/blob/main/domain/day_session.py) (Day session), [`ui/scenes/office_scene.py`](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/office_scene.py) (Office), [`audio/audio_manager.py`](https://github.com/mrde4olt/sdage/blob/main/audio/audio_manager.py) (Audio manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap & runtime"]
  node_main_py(("Main<br/>entrypoint<br/>[main.py]"))
  node_settings_py["Settings<br/>runtime config<br/>[settings.py]"]
end

subgraph group_core["Core systems"]
  node_game_py["Game loop<br/>orchestrator<br/>[game.py]"]
  node_gamestate_py["Game state<br/>state model<br/>[gamestate.py]"]
  node_timer_py["Timer<br/>time service<br/>[timer.py]"]
  node_events_py["Events<br/>event bus<br/>[events.py]"]
  node_assets_py["Asset loader<br/>resource access<br/>[assets.py]"]
end

subgraph group_domain["Game domain"]
  node_anxiety_py["Anxiety<br/>domain rule<br/>[anxiety.py]"]
  node_boss_py["Boss<br/>domain rule<br/>[boss.py]"]
  node_doors_py["Doors<br/>domain rule<br/>[doors.py]"]
  node_office_state_py["Office state<br/>world state<br/>[office_state.py]"]
  node_report_py["Report<br/>domain flow<br/>[report.py]"]
  node_work_py["Work<br/>domain flow<br/>[work.py]"]
  node_day_session_py{{"Day session<br/>session flow<br/>[day_session.py]"}}
end

subgraph group_ui["UI layer"]
  node_menu_scene_py["Menu<br/>scene<br/>[menu_scene.py]"]
  node_office_scene_py["Office<br/>scene<br/>[office_scene.py]"]
  node_work_monitor_scene_py["Work monitor<br/>scene"]
  node_relax_monitor_scene_py["Relax monitor<br/>scene"]
  node_report_monitor_scene_py["Report monitor<br/>scene"]
  node_game_over_scene_py["Game over<br/>scene<br/>[game_over_scene.py]"]
  node_win_scene_py["Win<br/>scene<br/>[win_scene.py]"]
  node_overlay_py["Overlay<br/>hud<br/>[overlay.py]"]
  node_button_py["Button<br/>widget<br/>[button.py]"]
  node_progress_bar_py["Progress bar<br/>widget<br/>[progress_bar.py]"]
end

subgraph group_audio["Audio"]
  node_audio_manager_py["Audio manager<br/>[audio_manager.py]"]
  node_sound_events_py["Sound events<br/>mapping<br/>[sound_events.py]"]
end

subgraph group_data["Data & tuning"]
  node_config_py["Config<br/>[config.py]"]
  node_balance_py["Balance<br/>tuning<br/>[balance.py]"]
end

subgraph group_assets["Assets"]
  node_fonts_dir["Fonts<br/>asset set"]
  node_images_dir["Images<br/>asset set"]
end

node_main_py -->|"loads"| node_settings_py
node_main_py -->|"starts"| node_game_py
node_game_py -->|"tracks"| node_gamestate_py
node_game_py -->|"routes"| node_events_py
node_game_py -->|"ticks"| node_timer_py
node_game_py -->|"opens"| node_menu_scene_py
node_game_py -->|"switches"| node_office_scene_py
node_game_py -->|"switches"| node_game_over_scene_py
node_game_py -->|"switches"| node_win_scene_py
node_game_py -->|"uses"| node_audio_manager_py
node_game_py -->|"loads"| node_assets_py
node_office_scene_py -->|"reads"| node_office_state_py
node_office_scene_py -->|"advances"| node_day_session_py
node_office_scene_py -->|"shows"| node_overlay_py
node_office_scene_py -->|"uses"| node_button_py
node_office_scene_py -->|"uses"| node_progress_bar_py
node_work_monitor_scene_py -->|"reads"| node_work_py
node_relax_monitor_scene_py -->|"reads"| node_anxiety_py
node_report_monitor_scene_py -->|"reads"| node_report_py
node_menu_scene_py -->|"uses"| node_button_py
node_day_session_py -->|"coordinates"| node_work_py
node_day_session_py -->|"coordinates"| node_report_py
node_day_session_py -->|"updates"| node_anxiety_py
node_day_session_py -->|"checks"| node_boss_py
node_day_session_py -->|"checks"| node_doors_py
node_day_session_py -->|"emits"| node_events_py
node_audio_manager_py -->|"maps"| node_sound_events_py
node_sound_events_py -->|"subscribes"| node_events_py
node_assets_py -->|"loads"| node_fonts_dir
node_assets_py -->|"loads"| node_images_dir
node_settings_py -->|"pulls"| node_config_py
node_config_py -->|"includes"| node_balance_py
node_office_scene_py -->|"triggers"| node_audio_manager_py
node_report_monitor_scene_py -->|"triggers"| node_audio_manager_py
node_game_over_scene_py -->|"triggers"| node_audio_manager_py

click node_main_py "https://github.com/mrde4olt/sdage/blob/main/main.py"
click node_settings_py "https://github.com/mrde4olt/sdage/blob/main/settings.py"
click node_game_py "https://github.com/mrde4olt/sdage/blob/main/core/game.py"
click node_gamestate_py "https://github.com/mrde4olt/sdage/blob/main/core/gamestate.py"
click node_timer_py "https://github.com/mrde4olt/sdage/blob/main/core/timer.py"
click node_events_py "https://github.com/mrde4olt/sdage/blob/main/core/events.py"
click node_assets_py "https://github.com/mrde4olt/sdage/blob/main/core/assets.py"
click node_anxiety_py "https://github.com/mrde4olt/sdage/blob/main/domain/anxiety.py"
click node_boss_py "https://github.com/mrde4olt/sdage/blob/main/domain/boss.py"
click node_doors_py "https://github.com/mrde4olt/sdage/blob/main/domain/doors.py"
click node_office_state_py "https://github.com/mrde4olt/sdage/blob/main/domain/office_state.py"
click node_report_py "https://github.com/mrde4olt/sdage/blob/main/domain/report.py"
click node_work_py "https://github.com/mrde4olt/sdage/blob/main/domain/work.py"
click node_day_session_py "https://github.com/mrde4olt/sdage/blob/main/domain/day_session.py"
click node_menu_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/menu_scene.py"
click node_office_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/office_scene.py"
click node_work_monitor_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/work_monitor_scene.py"
click node_relax_monitor_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/relax_monitor_scene.py"
click node_report_monitor_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/report_monitor_scene.py"
click node_game_over_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/game_over_scene.py"
click node_win_scene_py "https://github.com/mrde4olt/sdage/blob/main/ui/scenes/win_scene.py"
click node_overlay_py "https://github.com/mrde4olt/sdage/blob/main/ui/overlay.py"
click node_button_py "https://github.com/mrde4olt/sdage/blob/main/ui/widgets/button.py"
click node_progress_bar_py "https://github.com/mrde4olt/sdage/blob/main/ui/widgets/progress_bar.py"
click node_audio_manager_py "https://github.com/mrde4olt/sdage/blob/main/audio/audio_manager.py"
click node_sound_events_py "https://github.com/mrde4olt/sdage/blob/main/audio/sound_events.py"
click node_config_py "https://github.com/mrde4olt/sdage/blob/main/data/config.py"
click node_balance_py "https://github.com/mrde4olt/sdage/blob/main/data/balance.py"
click node_fonts_dir "https://github.com/mrde4olt/sdage/tree/main/assets/fonts"
click node_images_dir "https://github.com/mrde4olt/sdage/tree/main/assets/images"

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_py,node_settings_py,node_fonts_dir,node_images_dir toneBlue
class node_game_py,node_gamestate_py,node_timer_py,node_events_py,node_assets_py toneAmber
class node_anxiety_py,node_boss_py,node_doors_py,node_office_state_py,node_report_py,node_work_py,node_day_session_py toneMint
class node_menu_scene_py,node_office_scene_py,node_work_monitor_scene_py,node_relax_monitor_scene_py,node_report_monitor_scene_py,node_game_over_scene_py,node_win_scene_py,node_overlay_py,node_button_py,node_progress_bar_py toneRose
class node_audio_manager_py,node_sound_events_py toneIndigo
class node_config_py,node_balance_py toneTeal
```

## Components

### Bootstrap & runtime

Application entry, global settings, and game loop orchestration.

- [Main](https://github.com/mrde4olt/sdage/blob/main/main.py): entrypoint · Process entry point that starts the game. · `main.py`
- [Settings](https://github.com/mrde4olt/sdage/blob/main/settings.py): runtime config · Global application settings and runtime defaults. · `settings.py`

### Core systems

Runtime coordination, state, timing, events, and asset loading.

- [Game loop](https://github.com/mrde4olt/sdage/blob/main/core/game.py): orchestrator · Owns the main loop and scene switching. · `core/game.py`
- [Game state](https://github.com/mrde4olt/sdage/blob/main/core/gamestate.py): state model · Tracks active mode and current state context. · `core/gamestate.py`
- [Timer](https://github.com/mrde4olt/sdage/blob/main/core/timer.py): time service · Time-based mechanics and scheduling support. · `core/timer.py`
- [Events](https://github.com/mrde4olt/sdage/blob/main/core/events.py): event bus · Internal events used to decouple systems. · `core/events.py`
- [Asset loader](https://github.com/mrde4olt/sdage/blob/main/core/assets.py): resource access · Central asset access and loading helpers. · `core/assets.py`

### Game domain

Gameplay rules and persistent in-world state.

- [Anxiety](https://github.com/mrde4olt/sdage/blob/main/domain/anxiety.py): domain rule · Pressure or stress-related gameplay state. · `domain/anxiety.py`
- [Boss](https://github.com/mrde4olt/sdage/blob/main/domain/boss.py): domain rule · Boss behavior or supervision constraints. · `domain/boss.py`
- [Doors](https://github.com/mrde4olt/sdage/blob/main/domain/doors.py): domain rule · Door-related gameplay constraints and state. · `domain/doors.py`
- [Office state](https://github.com/mrde4olt/sdage/blob/main/domain/office_state.py): world state · Current office situation and available interactions. · `domain/office_state.py`
- [Report](https://github.com/mrde4olt/sdage/blob/main/domain/report.py): domain flow · Reporting or end-of-day progression state. · `domain/report.py`
- [Work](https://github.com/mrde4olt/sdage/blob/main/domain/work.py): domain flow · Work progression and task-related state. · `domain/work.py`
- [Day session](https://github.com/mrde4olt/sdage/blob/main/domain/day_session.py): session flow · Coordinates the flow of a play session or day. · `domain/day_session.py`

### UI layer

Scenes, overlays, and reusable widgets.

- [Menu](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/menu_scene.py): scene · Start screen and main navigation. · `ui/scenes/menu_scene.py`
- [Office](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/office_scene.py): scene · Primary gameplay scene and interaction hub. · `ui/scenes/office_scene.py`
- [Work monitor](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/work_monitor_scene.py): scene · UI for work-related status and progress. · `ui/scenes/work_monitor_scene.py`
- [Relax monitor](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/relax_monitor_scene.py): scene · UI for recovery or low-pressure state. · `ui/scenes/relax_monitor_scene.py`
- [Report monitor](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/report_monitor_scene.py): scene · UI for reporting or progress review. · `ui/scenes/report_monitor_scene.py`
- [Game over](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/game_over_scene.py): scene · Failure/end state screen. · `ui/scenes/game_over_scene.py`
- [Win](https://github.com/mrde4olt/sdage/blob/main/ui/scenes/win_scene.py): scene · Success/end state screen. · `ui/scenes/win_scene.py`
- [Overlay](https://github.com/mrde4olt/sdage/blob/main/ui/overlay.py): hud · Shared HUD or cross-scene overlay. · `ui/overlay.py`
- [Button](https://github.com/mrde4olt/sdage/blob/main/ui/widgets/button.py): widget · Reusable clickable control. · `ui/widgets/button.py`
- [Progress bar](https://github.com/mrde4olt/sdage/blob/main/ui/widgets/progress_bar.py): widget · Reusable progress indicator. · `ui/widgets/progress_bar.py`

### Audio

Sound playback and sound-event mapping.

- [Audio manager](https://github.com/mrde4olt/sdage/blob/main/audio/audio_manager.py): service · Central sound playback and mixing control. · `audio/audio_manager.py`
- [Sound events](https://github.com/mrde4olt/sdage/blob/main/audio/sound_events.py): mapping · Maps game events to audio cues. · `audio/sound_events.py`

### Data & tuning

Runtime configuration and gameplay balance values.

- [Config](https://github.com/mrde4olt/sdage/blob/main/data/config.py): game config · Gameplay and runtime configuration constants. · `data/config.py`
- [Balance](https://github.com/mrde4olt/sdage/blob/main/data/balance.py): tuning · Pacing, difficulty, and tuning values. · `data/balance.py`

### Assets

Static art and font resources.

- [Fonts](https://github.com/mrde4olt/sdage/tree/main/assets/fonts): asset set · Font resources used by the UI. · `assets/fonts`
- [Images](https://github.com/mrde4olt/sdage/tree/main/assets/images): asset set · Image resources used by scenes and widgets. · `assets/images`

## Connections

- Main → Settings: loads · Bootstraps the app with global settings.
- Main → Game loop: starts · Creates and runs the main game loop.
- Game loop → Game state: tracks · Maintains the active game state.
- Game loop → Events: routes · Dispatches internal events between systems.
- Game loop → Timer: ticks · Advances time-dependent mechanics.
- Game loop → Menu: opens · Starts in the menu scene or transitions into it.
- Game loop → Office: switches · Transitions between active scenes.
- Game loop → Game over: switches · Transitions to failure state scenes.
- Game loop → Win: switches · Transitions to success state scenes.
- Game loop → Audio manager: uses · Coordinates audio playback during runtime.
- Game loop → Asset loader: loads · Loads shared resources used by scenes.
- Office → Office state: reads · Renders and updates office gameplay state.
- Office → Day session: advances · Drives the current session flow.
- Office → Overlay: shows · Uses the shared HUD during gameplay.
- Office → Button: uses · Builds interactive controls.
- Office → Progress bar: uses · Displays progress and status.
- Work monitor → Work: reads · Shows work progression state.
- Relax monitor → Anxiety: reads · Reflects reduced or changing pressure state.
- Report monitor → Report: reads · Shows report or review state.
- Menu → Button: uses · Builds menu actions.
- Day session → Work: coordinates · Sequences work-related progression.
- Day session → Report: coordinates · Moves into reporting or end-of-day flow.
- Day session → Anxiety: updates · Adjusts pressure or stress over time.
- Day session → Boss: checks · Applies boss-related constraints or triggers.
- Day session → Doors: checks · Applies door or access constraints.
- Day session → Events: emits · Publishes gameplay events for decoupled consumers.
- Audio manager → Sound events: maps · Translates events into audio cues.
- Sound events → Events: subscribes · Consumes core events to trigger sounds.
- Asset loader → Fonts: loads · Provides font resources to the UI.
- Asset loader → Images: loads · Provides image resources to the UI.
- Settings → Config: pulls · Uses configuration values for runtime setup.
- Config → Balance: includes · Separates tunable balance values from app config.
- Office → Audio manager: triggers · Requests audio feedback from gameplay actions.
- Report monitor → Audio manager: triggers · Can trigger audio during report flow.
- Game over → Audio manager: triggers · Can trigger end-state audio cues.
