How prathxmop/prathxm-patches works
1. What this repository is
- This is a multi-module Android patch source for Chess.com on Android.
- It is not the app itself; it produces a patch bundle that Morphe can apply to the Chess.com APK.
- The architecture splits into a patch-definition layer and an injected runtime layer.
2. Top-level module split
- patches/ contains the Kotlin patch modules that identify target app code and modify behavior.
- extensions/extension/ contains the Android runtime code that is injected into the patched app and provides UI, overlays, local engine integration, and feature screens.
- This separation is important: patches decide *what to hook*, while extensions implement *what runs after injection*.
3. Patch layer as the integration boundary
- Each patch is organized by feature: adfree, botunlock, lichesspuzzle, stockfish, and misc.
- The patch code references app fingerprints and applies changes against specific Chess.com versions listed in the README.
- patches/src/main/kotlin/util/PatchListGenerator.kt and the JSON bundle/list files suggest this module also generates the patch catalog that Morphe Manager consumes.
4. Runtime extension layer
- The extension module is a standard Android app-like runtime packaged under Chess.com’s process.
- It includes activities, dialogs, custom views, overlays, and managers in Java.
- Major runtime areas are stockfish/, lichesspuzzle/, titles/, and crash/, each representing a feature subsystem surfaced inside the host app.
5. Local Stockfish analysis subsystem
- StockfishExtension, LocalAnalysisFlow, StockfishBridge, and StockfishProcess form the engine-control path.
- The bundled engine is shipped under extensions/extension/src/main/assets/stockfish, so analysis runs locally and offline on-device.
- Supporting UI/UX classes like OverlayManager, EvalBarView, WdlBarView, ArrowInjector, and GestureInterceptor render analysis results and interact with the game board.
- MoveClassifier and StockfishSettings/StockfishSettingsDialog show that analysis is not just engine output; it also maps engine evaluations into chess annotations and user-configurable behavior.
6. Offline Lichess puzzles subsystem
- LichessPuzzleExtension is the feature entry point for puzzle functionality.
- LichessPuzzleDatabaseHelper, PuzzleDownloadManager, PuzzleGameEngine, PuzzleRushManager, and PuzzleSoundManager indicate a self-contained offline puzzle system with storage, progression, game logic, streak/rush tracking, and audio feedback.
- UI classes such as LichessPuzzleJourneyActivity, JourneyBottomSheet, PuzzleJourneyMapView, LichessBoardView, and StandaloneLichessActivity suggest a dedicated puzzle journey experience rendered inside the patched app.
- The GitHub scripts/workflows around Lichess DB updates imply this subsystem is fed by periodically generated puzzle data rather than live network lookup at runtime.
7. Ad-free and unlock patches
- AdFreePatch removes in-app advertisements and promotional surfaces.
- BotUnlockPatch removes restrictions from Chess.com’s bot opponents.
- These are classic “behavior patches” with minimal runtime UI of their own; they change host-app logic rather than introduce new screens.
8. Custom titles and crash handling
- CustomTitlesPatch and CustomTitlesExtension implement a remote title feature tied to user profile presentation.
- CrashHandlerPatch plus crash/CrashHandler and CrashActivity provide a global uncaught-exception boundary that routes failures to a custom error screen instead of a generic app crash.
- These features are cross-cutting: they sit outside chess-specific flows and affect global app behavior.
9. Feature access and UI control
- The README describes the Chess.com logo as a control surface: tap-and-hold opens settings, double-tap toggles panic mode.
- That behavior is likely implemented through the overlay/gesture classes in the stockfish subsystem, which act as the global interaction layer for turning injected features on and off.
- This makes the overlay system a central runtime boundary, not just a visualization component.
10. Assets and bundled native dependencies
- assets/images and assets/stockfish are the main packaged resources.
- Stockfish is the key native dependency that materially affects architecture because analysis depends on an embedded engine rather than external services.
- The app therefore has a strong offline-first design for analysis and puzzles.
11. Build, release, and automation pipeline
- The repository includes GitHub Actions for pull-request builds, release publishing, source updates, and Lichess database refreshes.
- Scripts like download_stockfish.sh, extract_puzzles.py, and generate_patches_readme.py automate asset acquisition and documentation generation.
- This means the repo has a clear separation between source code, generated patch metadata, and periodic data refresh jobs.
12. External dependencies and operational boundary
- The runtime directly depends on the Chess.com Android app as its host environment.
- The extension also interacts with Lichess data for puzzles and may use a remote service for custom titles.
- Morphe is the packaging and injection mechanism, so the final architecture is best understood as “patch bundle + injected Android runtime + bundled engine/data.”
13. How to diagram it
- A good diagram should show:
- Morphe / patch bundle on one side,
- Chess.com APK as the host app in the middle,
- Injected extension runtime inside the host process,
- and separate feature lanes for Stockfish analysis, Lichess puzzles, ad/bot/title/crash patches.
- The most important data flows are:
- host app events → injected overlays/gesture handlers,
- game position → Stockfish engine → evaluation/UI,
- puzzle download/data → local puzzle database → puzzle gameplay,
- exceptions → crash handler screen,
- patch metadata → build/release pipeline.
Main entry points: LocalAnalysisFlow.java Analysis flow · LichessPuzzleExtension.java Puzzle ext · patches-bundle.json Patch bundle · OverlayManager.java Overlay mgr
Components 25
Patch bundle
Kotlin patch modules and generated metadata that target Chess.com internals.
- Patch bundle · Compiled patch catalog and bundle descriptors consumed by Morphe Manager.
patches-bundle.json - List gen · Build-time generator for the patch catalog and bundle list.
patches/src/main/kotlin/util/PatchListGenerator.kt - Ad-free · Removes advertisements and promotional surfaces from the host app.
patches/src/main/kotlin/app/prathxm/chess/patches/adfree/AdFreePatch.kt - Bot unlock · Lifts restrictions around Chess.com bot opponents.
patches/src/main/kotlin/app/prathxm/chess/patches/botunlock/BotUnlockPatch.kt - Stockfish patch · Hooks host app game state for local analysis features.
patches/src/main/kotlin/app/prathxm/chess/patches/stockfish/StockfishPatch.kt - Puzzle patch · Enables Lichess puzzle features inside the host app flow.
patches/src/main/kotlin/app/prathxm/chess/patches/lichesspuzzle/LichessPuzzlePatch.kt - Titles patch · Connects host profile/title behavior to the custom titles feature.
patches/src/main/kotlin/app/prathxm/chess/patches/misc/CustomTitlesPatch.kt - Crash patch · Redirects uncaught failures into a custom crash handling path.
patches/src/main/kotlin/app/prathxm/chess/patches/misc/CrashHandlerPatch.kt - Clone app · Miscellaneous app cloning/support patch.
patches/src/main/kotlin/app/prathxm/chess/patches/misc/CloneAppPatch.kt
Injected runtime
Android runtime code injected into the host app to provide overlays, puzzles, titles, and crash UI.
- Stockfish ext · Entry point for the injected local analysis subsystem.
extensions/extension/src/main/java/app/prathxm/chess/extension/stockfish/StockfishExtension.java - Overlay mgr · Coordinates overlays, controls, and board-facing interaction surfaces.
extensions/extension/src/main/java/app/prathxm/chess/extension/stockfish/OverlayManager.java - Analysis flow · Moves board position data into engine analysis and result handling.
extensions/extension/src/main/java/app/prathxm/chess/extension/stockfish/LocalAnalysisFlow.java - Stockfish proc · Runs the bundled Stockfish engine locally on-device.
extensions/extension/src/main/java/app/prathxm/chess/extension/stockfish/StockfishProcess.java - Engine assets · Packaged Stockfish binaries and resources used for offline analysis.
extensions/extension/src/main/assets/stockfish - Puzzle ext · Entry point for the offline Lichess puzzle subsystem.
extensions/extension/src/main/java/app/prathxm/chess/extension/lichesspuzzle/LichessPuzzleExtension.java - Puzzle DB · Local database for downloaded puzzle content and progression state.
extensions/extension/src/main/java/app/prathxm/chess/extension/lichesspuzzle/LichessPuzzleDatabaseHelper.java - Puzzle engine · Executes puzzle gameplay, rush mode, and state transitions.
extensions/extension/src/main/java/app/prathxm/chess/extension/lichesspuzzle/PuzzleGameEngine.java - Puzzle download · Fetches and prepares offline puzzle data before local play.
extensions/extension/src/main/java/app/prathxm/chess/extension/lichesspuzzle/PuzzleDownloadManager.java - Titles ext · Runtime support for custom title presentation inside the host app.
extensions/extension/src/main/java/app/prathxm/chess/extension/titles/CustomTitlesExtension.java - Crash handler · Intercepts crashes and routes them to a dedicated failure screen.
extensions/extension/src/main/java/app/prathxm/chess/extension/crash/CrashHandler.java - Crash screen · Displays custom crash recovery UI after a fatal error.
extensions/extension/src/main/java/app/prathxm/chess/extension/crash/CrashActivity.java
Build pipeline
Automation for asset refresh, patch generation, and release publishing.
- CI/CD · GitHub Actions workflows for build, release, source updates, and database refreshes.
.github/workflows/release.yml - Refresh scripts · Scripts that fetch Stockfish, extract puzzles, and regenerate documentation.
.github/scripts/extract_puzzles.py
Other components
- Morphe · External packaging and injection system that consumes this repository's patch bundle.
- Chess.com APK · The target Android application that receives patches and injected runtime code.
Connections 27
- Morphe → Patch bundle: consumes · Morphe reads the generated patch metadata and bundle descriptors.
- List gen → Patch bundle: generates · Build-time generation of the patch catalog and bundle list.
- CI/CD → List gen: runs · CI drives generation, validation, and release packaging.
- Refresh scripts → CI/CD: feeds · Automation scripts supply refreshed engine, puzzle, and docs assets.
- Patch bundle → Chess.com APK: patches · The bundle is applied to the target Chess.com APK.
- Ad-free → Chess.com APK: modifies · Removes in-app advertising and promo surfaces.
- Bot unlock → Chess.com APK: modifies · Removes bot access restrictions.
- Stockfish patch → Chess.com APK: hooks · Intercepts host game state for analysis features.
- Puzzle patch → Chess.com APK: hooks · Enables puzzle-related integration points in the host app.
- Titles patch → Chess.com APK: modifies · Adjusts profile/title presentation behavior.
- Crash patch → Chess.com APK: redirects · Redirects fatal failures into custom crash handling.
- Clone app → Chess.com APK: modifies · Miscellaneous host-app behavior support.
- Chess.com APK → Stockfish ext: injects · The runtime extension executes inside the host process.
- Chess.com APK → Puzzle ext: injects · Puzzle runtime is injected into the host process.
- Chess.com APK → Titles ext: injects · Custom title runtime is loaded into the host process.
- Chess.com APK → Crash handler: routes errors · Fatal exceptions are intercepted before the default crash path.
- Stockfish ext → Overlay mgr: starts · The extension entry point brings up overlay and interaction management.
- Overlay mgr → Analysis flow: drives · Overlay interactions trigger analysis requests and result rendering.
- Analysis flow → Stockfish proc: executes · Position data is sent to the local engine process.
- Stockfish proc → Overlay mgr: returns eval · Engine output is rendered back into overlays and board UI.
- Analysis flow → Engine assets: uses assets · The engine runs from bundled Stockfish assets.
- Puzzle ext → Puzzle download: ingests · Offline puzzle content is downloaded and prepared for local play.
- Puzzle download → Puzzle DB: stores · Downloaded puzzles and metadata are written into local storage.
- Puzzle ext → Puzzle engine: starts · The feature entry point launches puzzle gameplay logic.
- Puzzle engine → Puzzle DB: persists · Gameplay progress and downloaded puzzles are stored locally.
- Crash handler → Crash screen: opens · Handled failures are shown in a dedicated crash screen.
- Titles ext → Chess.com APK: annotates · Custom titles affect how the host app presents user profiles.