All projects

Completed · Unofficial fan project

Mobile Game Backend Restoration

Backend Engineering / Protocol Analysis

Restored online play, progression, and matchmaking for a discontinued mobile game with a compatible Python backend.

Rebuilding the Backend

I rebuilt and deployed a compatible backend for a discontinued mobile game, restoring online play, player progression, and matchmaking. The implementation was tested with the existing Android client on physical devices and runs on a Linux VPS.

Protocol analysis and compatibility

I used Frida to inspect the client at runtime and trace its network behavior. I mapped the request and response formats the client expected and implemented a compatible backend in Python.

Gameplay services and persistent state

I implemented authentication, player progression, the in-game store, and rewards. The backend supports solo play, time-limited events, and asynchronous PvP seasons with matchmaking and rankings. PostgreSQL stores persistent game state, and Redis provides caching.

Performance and result integrity

I ran mixed-workload tests to identify bottlenecks, then optimized PostgreSQL queries and shortened write transactions. I added server-side validation for match results and safeguards against duplicate rewards when a client resubmits an accepted result.

Fixing abandoned battles without weakening validation

The legacy client sometimes reported an abandoned battle with a zero-duration timer while retaining its action counters. The backend treated this as an impossible action rate and rejected the report, leaving the battle open.

I added a bounded server-time fallback for this specific report format. Valid abandonment reports now close the battle without granting rewards; other reports continue through the existing duration-based validation.

Battle completion runs in a database transaction. An identical retry returns the stored response, while a conflicting report cannot overwrite a completed result. Reward updates and battle completion either commit together or roll back together.

I verified the behavior with 11 regression tests covering multiple game modes, concurrent submissions, and reward consistency.

with database.transaction():
    battle = lock_battle(battle_id, player_id)

    if battle.completed:
        if battle.matches_saved_report(report):
            return battle.saved_response
        raise ConflictingResult()

    validate_report(battle, report)

    rewards = (
        [] if report.is_abandoned
        else calculate_rewards(report)
    )
    apply_rewards(player_id, rewards)
    save_completion(battle, report, rewards)
Simplified Python-like pseudocode. Report validation, reward updates, and battle completion run in one transaction. Supporting checks and implementation details are omitted.

Android testing and deployment

I adapted the Android client to connect over HTTPS with certificate verification and tested the build on physical devices using ADB. I deployed the backend with Docker Compose and HAProxy, with administrative access restricted to an SSH tunnel.

Stack: Python · PostgreSQL · Redis · Docker Compose · HAProxy · Linux · Android · Frida · ADB

Rebuilding the backend: client inspection, protocol analysis, and compatible server implementation.