# ndokutovich/spaceshooter architecture

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

- Interactive diagram: https://gitdiagram.com/ndokutovich/spaceshooter
- Repository: https://github.com/ndokutovich/spaceshooter

## Overview

##### Main Components
- Game Layer: This includes the core game engine and logic hosted primarily in the lib/game directory. Key sub-components are:
- Entities (e.g., player, enemy, asteroid, bonus items, boss)
- Managers (e.g., collision_manager, game_state_manager, bonus_manager, input_manager)
- Controllers (handling user inputs and game behaviors)
- Utility functions and configuration constants used across the game
- UI / Presentation Layer: Found in both lib/screens and lib/widgets. This layer covers:
- Game Screens (splash, main menu, game screen, high scores screen, options screen)
- Reusable Widgets (game logos, menu buttons, background widgets, performance overlay, etc.)
- Specific game UI components (player view, on-screen controls, custom painters for dynamic effects)
- Data & Persistence: Within lib/utils/high_scores and models where game state (e.g., high score tracking, save data) is handled.
- Platform Integration: Although most logic is in Flutter code, platform-specific code exists for:
- Android (android/ directory)
- iOS (ios/ directory)
- macOS, Windows, Web (their respective directories)
These components manage native configurations, build-and-deploy settings, and platform-specific integrations.

##### Relationships and Interactions
- Between UI elements (screens and widgets) and the game engine, indicating how user inputs are captured and passed to game controllers/managers.
- Between the game layer and data persistence modules (for high scores and local saves).
- From the platform-specific wrappers to the Flutter engine, demonstrating that they essentially act as hosts that provide rendering and input backends.
- Separation between the game engine, the UI, and platform integration, signifying a clear separation of concerns.

##### Architectural Patterns and Design Principles
- Model-View-Controller (MVC) or similar separation: Indicate how game state (models) is managed, how controllers interpret inputs/actions, and how views/renderers are updated.
- Layered Architecture: Visually separate core game logic from presentation (screens and widgets) and peripheral platform-specific configurations.
- Modularity: Demonstrate that each module (entities, managers, controllers) is decoupled and designed for reusability.

##### Technology and Frameworks to Highlight
- Flutter & Dart for UI and game logic (lib/ directory as the central hub)
- Platform-specific configurations (Android’s Gradle scripts, iOS’s Xcode settings, etc.)
- Cross-platform build tooling (pubspec.yaml, build configs for desktop/web/mobile)
- Custom paintings and animations using Flutter’s custom painter API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        UI_Screens["UI Screens"]:::ui
        UI_Widgets["UI Widgets"]:::ui
    end

    %% Game Layer
    subgraph "Game Layer"
        GE["Game Engine & Core Logic"]:::game
        Entities["Entities"]:::game
        Managers["Game Managers"]:::game
        Controllers["Game Controllers"]:::game
    end

    %% Data & Persistence
    subgraph "Data & Persistence"
        Data["High Scores & Game State"]:::data
    end

    %% Platform Integration
    subgraph "Platform Integration"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        macOS["macOS"]:::platform
        Windows["Windows"]:::platform
        Web["Web"]:::platform
    end

    %% Connections between UI and Game Layer
    UI_Screens -->|"UserInput"| Controllers
    UI_Widgets -->|"TriggerActions"| Controllers
    Controllers -->|"ProcessInput"| GE
    UI_Screens -->|"RenderState"| GE

    %% Connections within Game Layer
    GE -->|"UpdateEntities"| Entities
    GE -->|"ManageState"| Managers
    GE -->|"PersistData"| Data
    Data -->|"ReturnData"| GE

    %% Connections from Platform Integration to Game Layer
    Android -->|"NativeService"| GE
    iOS -->|"NativeService"| GE
    macOS -->|"NativeService"| GE
    Windows -->|"NativeService"| GE
    Web -->|"NativeService"| GE

    %% Click Events
    click GE "https://github.com/ndokutovich/spaceshooter/tree/main/lib/game/engine"
    click Entities "https://github.com/ndokutovich/spaceshooter/tree/main/lib/game/entities"
    click Managers "https://github.com/ndokutovich/spaceshooter/tree/main/lib/game/managers"
    click Controllers "https://github.com/ndokutovich/spaceshooter/tree/main/lib/game/controllers"
    click UI_Screens "https://github.com/ndokutovich/spaceshooter/tree/main/lib/screens"
    click UI_Widgets "https://github.com/ndokutovich/spaceshooter/tree/main/lib/widgets"
    click Data "https://github.com/ndokutovich/spaceshooter/tree/main/lib/utils/high_scores"
    click Android "https://github.com/ndokutovich/spaceshooter/tree/main/android"
    click iOS "https://github.com/ndokutovich/spaceshooter/tree/main/ios"
    click macOS "https://github.com/ndokutovich/spaceshooter/tree/main/macos"
    click Windows "https://github.com/ndokutovich/spaceshooter/tree/main/windows"
    click Web "https://github.com/ndokutovich/spaceshooter/tree/main/web"

    %% Styles
    classDef game fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef ui fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef platform fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
```
