# afterdie/octops architecture

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

- Interactive diagram: https://gitdiagram.com/afterdie/octops
- Repository: https://github.com/afterdie/octops

## Overview

Based on our analysis of the file tree and README, Octops is an open‐source, point-and-click game built in Python 3.11 with the Kivy framework. It uses .kv files for view/layout design (in the screenLayout folder) and Python modules (in the screens folder) for game logic and screen behavior. The project is compiled using Nuitka, as evidenced by the extensive “build” directories for both Linux and Windows distributions, so the build process is another important architectural aspect.

##### Main Components
- Entry Point and App Initialization: Use octops.py as the central application file that initializes the main Kivy App and the ScreenManager.
- Presentation Layer:
– The “screenLayout” directory holds the .kv files that define the look and layout (e.g., main_screen.kv, map_screen.kv, etc.).
– The “assets” directory contains images, audio files, and other resources.
- Game Logic (Domain Layer):
– The “screens” directory contains Python classes that implement the behavior for each game screen (doors, main, map, siteA, siteB, spawn, etc.).
- Build and Deployment Components:
– The “build” directory (with separate Linux and Windows sub-folders) holds scripts, compilation outputs (using Nuitka), and distribution packages (Octops.exe).
- External Dependencies and Tools:
– Kivy, Nuitka, and other libraries (such as PIL and requests) are integrated and shown as external building blocks.

##### Relationships and Interactions
- octops.py initializes the Kivy application and the ScreenManager, connecting to different screen components.
- The ScreenManager orchestrates transitions between different screen classes that reside in the “screens” folder.
- Each screen’s presentation is defined by loading its corresponding .kv file (from screenLayout) which in turn uses the media assets from the “assets” folder.
- The build system (via SCons and build scripts provided for Linux and Windows) compiles and packages the project to produce executable distributions.

##### Architectural Patterns and Design Principles
- Model-View Separation: The .kv files (view) are separated from the Python logic (controller), ensuring a clean separation of presentation and behavior.
- Modularity: Each screen is self-contained in its own Python module, and assets are grouped by purpose, which supports easy extensibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: Application Entry and Screen Manager
    Entry["Application Entry (octops.py)"]:::entry
    SM["Screen Manager"]:::control
    Entry --> SM

    %% External Dependency: Kivy Framework (for UI)
    Kivy["Kivy Framework"]:::external
    SM -->|"uses"| Kivy

    %% Middle Layer: Screen Modules (Game Logic)
    subgraph "Screen Modules"
        SMain["Screen: Main"]:::screen
        SMap["Screen: Map"]:::screen
        SDoors["Screen: Doors"]:::screen
        SSiteA["Screen: SiteA"]:::screen
        SSiteB["Screen: SiteB"]:::screen
        SSpawn["Screen: Spawn"]:::screen
    end
    SM --> SMain
    SMain --> SMap
    SMap --> SDoors
    SDoors --> SSiteA
    SSiteA --> SSiteB
    SSiteB --> SSpawn

    %% Each Screen loads its KV layout
    KVLayouts["KV Layouts (.kv files)"]:::layout
    SMain -->|"loads"| KVLayouts
    SMap -->|"loads"| KVLayouts
    SDoors -->|"loads"| KVLayouts
    SSiteA -->|"loads"| KVLayouts
    SSiteB -->|"loads"| KVLayouts
    SSpawn -->|"loads"| KVLayouts

    %% KV Layouts depends on Media Assets
    Assets["Media Assets (images, audio)"]:::asset
    KVLayouts -->|"uses"| Assets

    %% Side Block: Build and Deployment Pipeline
    BuildScripts["Build Scripts"]:::build
    BS1["Build: octops.py"]:::build
    BS2["Build: linux-build.sh"]:::build
    BS3["Build: windows-build.bat"]:::build
    Distribution["Build System & Distribution"]:::build
    LinuxBuild["Linux Build"]:::build
    WindowsBuild["Windows Build"]:::build
    %% Build pipeline vertical flow
    Entry -->|"builds via"| BuildScripts
    BuildScripts --> BS1
    BS1 --> BS2
    BS2 --> BS3
    BS3 --> Distribution
    Distribution --> LinuxBuild
    Distribution --> WindowsBuild

    %% External Dependency for Build: Nuitka Compiler
    Nuitka["Nuitka Compiler"]:::external
    BuildScripts -->|"compiles with"| Nuitka

    %% Click Events
    click Entry "https://github.com/afterdie/octops/blob/Participant/octops.py"
    click KVLayouts "https://github.com/afterdie/octops/tree/Participant/screenLayout"
    click Assets "https://github.com/afterdie/octops/tree/Participant/assets"
    click SMain "https://github.com/afterdie/octops/blob/Participant/screens/main.py"
    click SMap "https://github.com/afterdie/octops/blob/Participant/screens/map.py"
    click SDoors "https://github.com/afterdie/octops/blob/Participant/screens/doors.py"
    click SSiteA "https://github.com/afterdie/octops/blob/Participant/screens/siteA.py"
    click SSiteB "https://github.com/afterdie/octops/blob/Participant/screens/siteB.py"
    click SSpawn "https://github.com/afterdie/octops/blob/Participant/screens/spawn.py"
    click BS1 "https://github.com/afterdie/octops/blob/Participant/build/octops.py"
    click BS2 "https://github.com/afterdie/octops/blob/Participant/build/linux-build.sh"
    click BS3 "https://github.com/afterdie/octops/blob/Participant/build/windows-build.bat"
    click LinuxBuild "https://github.com/afterdie/octops/tree/Participant/build/Octops-build-dist-linux"
    click WindowsBuild "https://github.com/afterdie/octops/tree/Participant/build/Octops-build-dist-win"

    %% Styles
    classDef entry fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef control fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef screen fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef layout fill:#e2f0d9,stroke:#3c763d,stroke-width:2px;
    classDef asset fill:#fff2cc,stroke:#8a6d3b,stroke-width:2px;
    classDef build fill:#d9edf7,stroke:#31708f,stroke-width:2px;
    classDef external fill:#f7d9ed,stroke:#a94442,stroke-width:2px;
```
