# spachecor/purrfectplatforming architecture

> Architecture diagram of the GitHub repository spachecor/purrfectplatforming, 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/spachecor/purrfectplatforming
- Repository: https://github.com/spachecor/purrfectplatforming

## Overview

##### Main Components
- Android Application Shell: At the outer layer, include the Android operating system integration with the AndroidManifest.xml specifying the declared activities and services.
- UI / Presentation Layer:
- Activities such as MainActivity, MenuActivity, LevelsActivity, GameActivity, and GameOverActivity.
- Layout resources (XML layouts) used by these activities.
- GameView that acts as the primary canvas for rendering the game.
- Game Logic & Domain Layer:
- GameThread – the dedicated thread responsible for the game loop.
- Level Generation components (packages “levelgenerator” with Level and LevelConfigurator classes, and assets/levels.json) responsible for configuring and generating game levels.
- Game Objects – classes like GameObject, Scenery, Trophy, and characters (Enemy, Gamer) that encapsulate the game elements.
- Services and Utilities:
- In-app services such as AdBannerService, LevelPassedService, and SoundEffectsService which handle advertising, game progress, and audio feedback.
- Collision Management – components in the “service.collision” package, including CollisionManager, CharacterCollisionManager, and PlatformCollisionManager, handling interaction and collision detection between game objects.
- Other utility services such as the SpriteManager.
- Resource Management:
- Testing Components:
- Instrumented tests (under app/src/androidTest) and unit tests (under app/src/test) that ensure various components are working as intended.

##### Relationships and Interactions
- How GameActivity initializes and then delegates rendering to GameView and the GameThread.
- Dependency of level generation and game setup on external assets (levels.json) and configuration classes in the “levelgenerator” package.
- Services (AdBannerService, SoundEffectsService, etc.) to the activities that need to interact with them.
- Use of the collision management classes by showing their interactions with the game object components.

##### Important Architectural Patterns and Principles
- Although the game might not strictly follow an MVC pattern, portions of the code hint at separation of concerns:
- Activities and views for UI (Presentation),
- Game objects, level generator, and the game thread for game logic (Domain/Logic),
- Services (e.g., collision, audio, ads) managing distinct functionalities.
- The modular package structure promotes reusability and single responsibility – each package (activity, service, gameobject, levelgenerator) clearly manages focused aspects of the application.

##### Incorporate Technologies/Frameworks
- Gradle Build System: Indicate that the project is built using Gradle (with configuration from build.gradle.kts and related files).
- Java: As the primary development language, which influences how the classes interact.

##### Elements
- Optionally, include notes or callouts that explain the role of each major package (e.g., “levelgenerator – configures game levels using external JSON asset”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android OS & Application Shell"
        manifest["AndroidManifest.xml (App Shell)"]:::shell
    end

    subgraph "Presentation Layer (Activities & Views)"
        mainActivity["MainActivity"]:::presentation
        menuActivity["MenuActivity"]:::presentation
        levelsActivity["LevelsActivity"]:::presentation
        gameActivity["GameActivity"]:::presentation
        gameOverActivity["GameOverActivity"]:::presentation
        layout["Layout Resources (XML)"]:::presentation
        gameView["GameView"]:::presentation
    end

    subgraph "Domain/Logic Layer"
        gameThread["GameThread"]:::logic
        level["Level"]:::logic
        levelConfig["LevelConfigurator"]:::logic
        levelsAsset["levels.json (Asset)"]:::logic
    end

    subgraph "Game Objects"
        gameObject["GameObject"]:::gameObjects
        scenery["Scenery"]:::gameObjects
        trophy["Trophy"]:::gameObjects
        character["Character"]:::gameObjects
        enemy["Enemy"]:::gameObjects
        gamer["Gamer"]:::gameObjects
        platform["Platform"]:::gameObjects
    end

    subgraph "In-App Services"
        adService["AdBannerService"]:::services
        levelPassedService["LevelPassedService"]:::services
        soundService["SoundEffectsService"]:::services
    end

    subgraph "Collision Management"
        collisionManager["CollisionManager"]:::collision
        charCollisionManager["CharacterCollisionManager"]:::collision
        platCollisionManager["PlatformCollisionManager"]:::collision
    end

    subgraph "Utility Services"
        spriteManager["SpriteManager"]:::utilities
    end

    subgraph "Resource Management"
        audio["Audio (game.mp3, jump.mp3, menu.mp3)"]:::resources
        drawable["Drawable Resources"]:::resources
        xmlConfigs["XML Configurations"]:::resources
    end

    subgraph "Testing"
        instrumentedTest["Instrumented Tests"]:::testing
        unitTest["Unit Tests"]:::testing
    end

    %% Relationships: Android Shell -> Activities
    manifest --> mainActivity
    manifest --> menuActivity
    manifest --> levelsActivity
    manifest --> gameActivity
    manifest --> gameOverActivity

    %% User Flow through Activities
    menuActivity -->|"launches"| levelsActivity
    levelsActivity -->|"selects"| gameActivity
    gameActivity -->|"ends in"| gameOverActivity

    %% Activities use layout resources
    mainActivity --> layout
    menuActivity --> layout
    levelsActivity --> layout
    gameActivity --> layout
    gameOverActivity --> layout

    %% GameActivity initializes GameView and GameThread
    gameActivity -->|"renders via"| gameView
    gameActivity -->|"starts"| gameThread

    %% Game Thread updates various game objects
    gameThread -->|"updates"| gameObject
    gameThread -->|"updates"| scenery
    gameThread -->|"updates"| trophy
    gameThread -->|"updates"| character
    gameThread -->|"updates"| enemy
    gameThread -->|"updates"| gamer
    gameThread -->|"updates"| platform

    %% Level Generation flow
    gameActivity -->|"configures level"| levelConfig
    levelConfig -->|"creates"| level
    levelConfig -->|"reads"| levelsAsset

    %% Services used by activities
    menuActivity --> adService
    levelsActivity --> levelPassedService
    gameActivity --> soundService

    %% Collision management invoked by GameThread
    gameThread -->|"collision-check"| collisionManager
    collisionManager --> charCollisionManager
    collisionManager --> platCollisionManager

    %% Utility service used by game logic
    gameThread --> spriteManager

    %% Resource dependencies
    layout --> drawable
    layout --> xmlConfigs
    soundService --> audio

    %% Testing relationships (dashed lines)
    instrumentedTest -.-> manifest
    unitTest -.-> gameThread

    %% Click Events
    click manifest "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/AndroidManifest.xml"
    click mainActivity "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/MainActivity.java"
    click menuActivity "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/MenuActivity.java"
    click levelsActivity "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/LevelsActivity.java"
    click gameActivity "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/GameActivity.java"
    click gameOverActivity "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/GameOverActivity.java"
    click layout "https://github.com/spachecor/purrfectplatforming/tree/master/app/src/main/res/layout"
    click gameView "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/view/GameView.java"
    click gameThread "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/thread/GameThread.java"
    click level "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/levelgenerator/Level.java"
    click levelConfig "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/levelgenerator/LevelConfigurator.java"
    click levelsAsset "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/assets/levels.json"
    click gameObject "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/GameObject.java"
    click scenery "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/Scenery.java"
    click trophy "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/Trophy.java"
    click character "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/character/Character.java"
    click enemy "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/character/Enemy.java"
    click gamer "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/character/Gamer.java"
    click platform "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/gameobject/platform/Platform.java"
    click adService "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/service/AdBannerService.java"
    click levelPassedService "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/service/LevelPassedService.java"
    click soundService "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/activity/service/SoundEffectsService.java"
    click spriteManager "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/service/SpriteManager.java"
    click collisionManager "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/service/collision/CollisionManager.java"
    click charCollisionManager "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/service/collision/CharacterCollisionManager.java"
    click platCollisionManager "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/main/java/com/spachecor/purrfectplatforming/service/collision/PlatformCollisionManager.java"
    click audio "https://github.com/spachecor/purrfectplatforming/tree/master/app/src/main/res/raw"
    click drawable "https://github.com/spachecor/purrfectplatforming/tree/master/app/src/main/res/drawable"
    click xmlConfigs "https://github.com/spachecor/purrfectplatforming/tree/master/app/src/main/res/xml"
    click instrumentedTest "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/androidTest/java/com/spachecor/purrfectplatforming/ExampleInstrumentedTest.java"
    click unitTest "https://github.com/spachecor/purrfectplatforming/blob/master/app/src/test/java/com/spachecor/purrfectplatforming/ExampleUnitTest.java"

    %% Class definitions for styles
    classDef shell fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef presentation fill:#ADD8E6,stroke:#0000CD,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef gameObjects fill:#FFB6C1,stroke:#CD5C5C,stroke-width:2px;
    classDef services fill:#D3D3D3,stroke:#A9A9A9,stroke-width:2px;
    classDef collision fill:#FFA500,stroke:#FF4500,stroke-width:2px;
    classDef utilities fill:#FFFFE0,stroke:#EEE685,stroke-width:2px;
    classDef resources fill:#E0FFFF,stroke:#4682B4,stroke-width:2px;
    classDef testing fill:#F0E68C,stroke:#BDB76B,stroke-width:2px;
```
