# prabanjanm/motionstrike architecture

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

- Interactive diagram: https://gitdiagram.com/prabanjanm/motionstrike
- Repository: https://github.com/prabanjanm/motionstrike

## Overview

#### Purpose and Runtime
MobileStrike is a native Android multiplayer proximity-combat game. It combines Bluetooth Low Energy (BLE) discovery/ranging, device compass and motion sensors, local combat rules, and WebSocket-based state exchange. The Android app module is defined by `app/build.gradle`; app component registration begins in `app/src/main/AndroidManifest.xml`.

#### Application Entry and Navigation
The activity layer provides the user-facing lifecycle and game flow: splash/start, main menu, and active match. `app/src/main/java/com/example/mobilestrike/MainActivity.java` is a top-level entry point alongside the specialized activities in `app/src/main/java/com/example/mobilestrike/activity/SplashActivity.java`, `app/src/main/java/com/example/mobilestrike/activity/MainMenuActivity.java`, and `app/src/main/java/com/example/mobilestrike/activity/GameActivity.java`. Corresponding layouts establish separate UI states under `app/src/main/res/layout/`.

#### Session and Player Coordination
Central managers coordinate player identity, match/session concerns, and packet exchange boundaries. `app/src/main/java/com/example/mobilestrike/PlayerManager.java` owns player-oriented coordination; `app/src/main/java/com/example/mobilestrike/NetworkPacket.java` represents general network payloads; `app/src/main/java/com/example/mobilestrike/util/GameIdGenerator.java` supplies game identifiers. Shared constants are concentrated in `app/src/main/java/com/example/mobilestrike/Constants.java`.

#### BLE Proximity Pipeline
BLE is the local physical-world transport and distance signal. `app/src/main/java/com/example/mobilestrike/BLEManager.java` is the likely facade over advertising/scanning, while `app/src/main/java/com/example/mobilestrike/bluetooth/BLEAdvertiser.java` and `app/src/main/java/com/example/mobilestrike/bluetooth/BLEScanner.java` interact with Android BLE APIs. Discovered peers are modeled by `app/src/main/java/com/example/mobilestrike/bluetooth/BLEDevice.java`; RSSI flows through `RSSIFilter`, `DistanceEstimator`, and `RangeClassifier` to convert noisy radio observations into gameplay-relevant proximity.

#### Sensor Orientation and Motion
Device sensors provide physical aiming and movement inputs. `app/src/main/java/com/example/mobilestrike/sensor/CompassManager.java` supplies directional/orientation data, and `app/src/main/java/com/example/mobilestrike/sensor/MotionSensorManager.java` supplies motion readings. These inputs form a boundary between Android hardware services and deterministic game validation.

#### Combat Engine
`app/src/main/java/com/example/mobilestrike/game/GameEngine.java` is the core rules orchestrator. It combines target selection/proximity (`EnemyFinder`, `PositionManager`), shot permission (`FireValidator`, `AimValidator`, `CooldownManager`), hit evaluation (`HitDetector`), and health/damage mutation (`DamageManager`, `HealthManager`). Weapon definitions and selection are contained in `app/src/main/java/com/example/mobilestrike/game/Weapon.java` and `app/src/main/java/com/example/mobilestrike/game/WeaponManager.java`. The essential flow is sensor + BLE-derived enemy state → validate fire/aim/range → detect hit → apply damage/cooldown → publish refreshed game state.

#### State Models and Remote Synchronization
Game state crosses a serialization/network boundary through `app/src/main/java/com/example/mobilestrike/model/GameStatePacket.java` and `app/src/main/java/com/example/mobilestrike/model/PlayerPacket.java`, backed by player and match state models. `app/src/main/java/com/example/mobilestrike/network/WebSocketManager.java` provides the external real-time transport, distinct from BLE’s nearby-device discovery role. There are two similarly named state domains—`game/GameState.java` and `model/GameState.java`—which should be treated carefully as potentially separate engine versus transport/UI representations.

#### Important Boundaries
Android Activities render and collect interaction; sensor and BLE adapters acquire device/world signals; the game package owns combat decisions; model/packet classes carry state across processes/devices; WebSockets connect the game to a remote real-time service. No server implementation or backend infrastructure is present in this repository.

Main entry points: [`app/src/main/java/com/example/mobilestrike/game/GameEngine.java`](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/GameEngine.java) (Game engine), [`app/src/main/java/com/example/mobilestrike/activity/GameActivity.java`](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/activity/GameActivity.java) (Game activities), [`app/src/main/java/com/example/mobilestrike/PlayerManager.java`](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/PlayerManager.java) (Player manager), [`app/src/main/java/com/example/mobilestrike/game/FireValidator.java`](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/FireValidator.java) (Fire validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Android UI"]
  node_manifest["App registration<br/>Android manifest"]
  node_activities["Game activities<br/>Android activities<br/>[GameActivity.java]"]
  node_main_activity["Main entry<br/>Android activity<br/>[MainActivity.java]"]
  node_layouts["Screen layouts<br/>Android resources"]
end

subgraph group_inputs["Physical inputs"]
  node_ble_manager["BLE manager<br/>BLE facade<br/>[BLEManager.java]"]
  node_ble_io["BLE advertise &amp; scan<br/>Android BLE adapters<br/>[BLEScanner.java]"]
  node_ble_device["Discovered peers<br/>BLE device model<br/>[BLEDevice.java]"]
  node_proximity["Proximity pipeline<br/>RSSI ranging"]
  node_compass["Compass manager<br/>orientation input"]
  node_motion["Motion manager<br/>motion input"]
end

subgraph group_combat["Combat engine"]
  node_game_engine{{"Game engine<br/>combat rules orchestrator<br/>[GameEngine.java]"}}
  node_targeting["Targeting &amp; position<br/>enemy selection<br/>[EnemyFinder.java]"]
  node_fire_rules["Fire validation<br/>aim and cooldown rules<br/>[FireValidator.java]"]
  node_damage["Hit &amp; health<br/>combat mutation<br/>[HitDetector.java]"]
  node_weapons["Weapon manager<br/>weapon selection<br/>[WeaponManager.java]"]
  node_engine_state["Engine game state<br/>runtime state<br/>[GameState.java]"]
end

subgraph group_sync["State &amp; sync"]
  node_player_manager["Player manager<br/>session coordinator<br/>[PlayerManager.java]"]
  node_game_id["Game ID generator<br/>identifier utility"]
  node_packets["State packets<br/>transport models"]
  node_websocket["WebSocket manager<br/>real-time transport"]
end

node_manifest -->|"registers"| node_main_activity
node_main_activity -->|"navigates"| node_activities
node_activities -->|"renders"| node_layouts
node_activities -->|"drives match"| node_game_engine
node_activities -->|"coordinates player"| node_player_manager
node_player_manager -->|"creates session ID"| node_game_id
node_ble_manager -->|"controls"| node_ble_io
node_ble_io -->|"discovers"| node_ble_device
node_ble_device -->|"RSSI observations"| node_proximity
node_proximity -->|"range state"| node_targeting
node_compass -->|"aim direction"| node_fire_rules
node_motion -->|"motion input"| node_game_engine
node_targeting -->|"candidate target"| node_game_engine
node_weapons -->|"selected weapon"| node_game_engine
node_game_engine -->|"requests validation"| node_fire_rules
node_fire_rules -->|"valid shot"| node_damage
node_damage -->|"mutates state"| node_engine_state
node_game_engine -->|"updates"| node_engine_state
node_engine_state -->|"serializes"| node_packets
node_packets -->|"sends and receives"| node_websocket
node_websocket -->|"remote player updates"| node_player_manager
node_player_manager -->|"session/player state"| node_game_engine

click node_manifest "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/AndroidManifest.xml"
click node_activities "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/activity/GameActivity.java"
click node_main_activity "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/MainActivity.java"
click node_player_manager "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/PlayerManager.java"
click node_game_id "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/util/GameIdGenerator.java"
click node_ble_manager "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/BLEManager.java"
click node_ble_io "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/bluetooth/BLEScanner.java"
click node_ble_device "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/bluetooth/BLEDevice.java"
click node_compass "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/sensor/CompassManager.java"
click node_motion "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/sensor/MotionSensorManager.java"
click node_game_engine "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/GameEngine.java"
click node_targeting "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/EnemyFinder.java"
click node_fire_rules "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/FireValidator.java"
click node_damage "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/HitDetector.java"
click node_weapons "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/WeaponManager.java"
click node_engine_state "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/GameState.java"
click node_packets "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/model/GameStatePacket.java"
click node_websocket "https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/network/WebSocketManager.java"

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_manifest,node_activities,node_main_activity,node_layouts toneBlue
class node_ble_manager,node_ble_io,node_ble_device,node_proximity,node_compass,node_motion toneAmber
class node_game_engine,node_targeting,node_fire_rules,node_damage,node_weapons,node_engine_state toneMint
class node_player_manager,node_game_id,node_packets,node_websocket toneRose
```

## Components

### Android UI

- [App registration](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/AndroidManifest.xml): Android manifest · `app/src/main/AndroidManifest.xml`
- [Game activities](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/activity/GameActivity.java): Android activities · Splash, menu, and match lifecycle screens. · `app/src/main/java/com/example/mobilestrike/activity/GameActivity.java`
- [Main entry](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/MainActivity.java): Android activity · `app/src/main/java/com/example/mobilestrike/MainActivity.java`
- **Screen layouts**: Android resources

### Physical inputs

- [BLE manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/BLEManager.java): BLE facade · `app/src/main/java/com/example/mobilestrike/BLEManager.java`
- [BLE advertise & scan](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/bluetooth/BLEScanner.java): Android BLE adapters · Advertises locally and discovers nearby devices. · `app/src/main/java/com/example/mobilestrike/bluetooth/BLEScanner.java`
- [Discovered peers](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/bluetooth/BLEDevice.java): BLE device model · `app/src/main/java/com/example/mobilestrike/bluetooth/BLEDevice.java`
- **Proximity pipeline**: RSSI ranging · Filters RSSI and classifies gameplay range.
- [Compass manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/sensor/CompassManager.java): orientation input · `app/src/main/java/com/example/mobilestrike/sensor/CompassManager.java`
- [Motion manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/sensor/MotionSensorManager.java): motion input · `app/src/main/java/com/example/mobilestrike/sensor/MotionSensorManager.java`

### Combat engine

- [Game engine](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/GameEngine.java): combat rules orchestrator · `app/src/main/java/com/example/mobilestrike/game/GameEngine.java`
- [Targeting & position](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/EnemyFinder.java): enemy selection · Finds enemies from proximity and position state. · `app/src/main/java/com/example/mobilestrike/game/EnemyFinder.java`
- [Fire validation](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/FireValidator.java): aim and cooldown rules · Validates aim, firing permission, and cooldown. · `app/src/main/java/com/example/mobilestrike/game/FireValidator.java`
- [Hit & health](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/HitDetector.java): combat mutation · Detects hits and applies damage to health. · `app/src/main/java/com/example/mobilestrike/game/HitDetector.java`
- [Weapon manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/WeaponManager.java): weapon selection · `app/src/main/java/com/example/mobilestrike/game/WeaponManager.java`
- [Engine game state](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/game/GameState.java): runtime state · Combat-domain state, distinct from transport state. · `app/src/main/java/com/example/mobilestrike/game/GameState.java`

### State & sync

- [Player manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/PlayerManager.java): session coordinator · `app/src/main/java/com/example/mobilestrike/PlayerManager.java`
- [Game ID generator](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/util/GameIdGenerator.java): identifier utility · `app/src/main/java/com/example/mobilestrike/util/GameIdGenerator.java`
- [State packets](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/model/GameStatePacket.java): transport models · Player and game state serialization boundary. · `app/src/main/java/com/example/mobilestrike/model/GameStatePacket.java`
- [WebSocket manager](https://github.com/prabanjanm/motionstrike/blob/main/app/src/main/java/com/example/mobilestrike/network/WebSocketManager.java): real-time transport · Exchanges state with the remote service. · `app/src/main/java/com/example/mobilestrike/network/WebSocketManager.java`

## Connections

- App registration → Main entry: registers
- Main entry → Game activities: navigates
- Game activities → Screen layouts: renders
- Game activities → Game engine: drives match
- Game activities → Player manager: coordinates player
- Player manager → Game ID generator: creates session ID
- BLE manager → BLE advertise & scan: controls
- BLE advertise & scan → Discovered peers: discovers
- Discovered peers → Proximity pipeline: RSSI observations
- Proximity pipeline → Targeting & position: range state
- Compass manager → Fire validation: aim direction
- Motion manager → Game engine: motion input
- Targeting & position → Game engine: candidate target
- Weapon manager → Game engine: selected weapon
- Game engine → Fire validation: requests validation
- Fire validation → Hit & health: valid shot
- Hit & health → Engine game state: mutates state
- Game engine → Engine game state: updates
- Engine game state → State packets: serializes
- State packets → WebSocket manager: sends and receives
- WebSocket manager → Player manager: remote player updates
- Player manager → Game engine: session/player state
