HomeCase studiesReal-Money Sports Prediction Contest Engine on Laravel...

Case study · Prague, Czech Republic

Real-Money Sports Prediction Contest Engine on Laravel & React Native

Sports gaming — real-money prediction contests

We designed and delivered a cross-platform real-money sports prediction contest system built around a Laravel API, React Native mobile apps, and a React web portal hosted on Google Cloud. Participants enter fixture-based prediction tournaments, lock selections prior to official kickoff timestamps, and compete on verified leaderboards backed by an auditable MySQL wallet ledger. Strict server-side cutoff enforcement, Laravel Passport OAuth2 scoping, and idempotent settlement queues eliminate race conditions across concurrent entry bursts and prize distributions.

Industry
Sports gaming — real-money prediction contests
Solution
Cross-platform React Native mobile apps, a React web interface, and a transactional Laravel/MySQL contest engine on Google Cloud.
Platforms
Cross-platform · Web & API
Stack
Laravel · PHP · React Native · React · MySQL · Google Cloud
Location
Prague, Czech Republic · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Prague, Czech Republic. Names withheld by agreement.

Project Overview

Real-money sports prediction contests place unforgiving demands on state consistency: a millisecond difference around match kickoff separates a valid slip from an invalid one, and every entry fee or prize payout must reconcile to the last decimal. Working with a gaming operator in Prague, we built a cross-platform contest ecosystem comprising React Native apps for iOS and Android, a React web application, and a transactional Laravel backend deployed on Google Cloud. Players join scheduled fixture pools, submit multi-match predictions against clear scoring rules, monitor live leaderboard movement, and manage real-money balances with full audit traceability.

Business Bottleneck

Peak activity in sports contests does not arrive smoothly; it compresses into the final ten minutes before major European kickoffs, followed by a second surge the moment final whistles blow. Legacy contest scripts relied on non-transactional balance updates and client-trusted timestamps, creating exposure to duplicate entry debits on flaky connections, post-kickoff submission exploits, and manual spreadsheet reconciliation whenever matches were postponed or abandoned. Operations teams needed automated lifecycle controls and deterministic financial accounting before scaling contest volume.

Architectural Strategy

We structured the platform as a single authoritative Laravel domain core consumed identically by React Native mobile clients and the React web portal via Laravel Passport OAuth2 tokens. Financial integrity rests on an immutable double-entry ledger inside MySQL rather than mutable balance columns alone. Contest scoring and payout execution run on isolated background queues with idempotent state machines so upstream fixture updates, tie-breaking splits, and cancelled-match refunds resolve predictably without blocking player traffic.

Core Capabilities

  • Multi-Fixture Contest Lobby: Players filter upcoming prediction pools by sport, entry tier, prize structure, and lock countdown across mobile and desktop.
  • Server-Locked Prediction Slips: Entries validate against contest eligibility, maximum entries per player, and authoritative UTC kickoff boundaries before debiting funds.
  • Double-Entry Wallet Ledger: Deposits, entry stakes, cancelled-contest refunds, and tournament winnings write balanced journal entries with complete statement exports.
  • Live Scoring & Tie-Break Engine: Configurable point matrices score outcomes, bonus multipliers, and tie-breaker criteria automatically as official match statuses finalize.
  • Contest Operations Console: Administrators configure contest templates, adjust provisional states, handle voided fixtures, and audit user ledger histories from a gated React interface.
  • Verified Transaction Notifications: SendGrid delivers signed entry receipts, tournament rank summaries, and payout confirmations triggered strictly after ledger commit.

Technical Architecture

Flow: React Native / React SPA -> Laravel Passport OAuth2 -> Laravel Contest & Ledger API -> Cloud SQL (MySQL) -> Queue Workers -> SendGrid

Upon login, both React Native and React clients authenticate against Laravel Passport to obtain scoped OAuth2 access and refresh tokens. All contest mutations pass through dedicated Laravel FormRequest validators and service classes wrapped in DB::transaction(). When a participant enters a contest, the ledger service acquires a pessimistic row lock (lockForUpdate()) on the user's wallet summary row, verifies sufficient settled funds, appends balanced debit and contest-escrow rows, and records the prediction slip atomically.

Fixture ingestion jobs update match statuses (scheduled, live, provisional, final, void) independently from payout jobs. Once all fixtures in a pool reach final, a queued settlement job computes final ranks, applies dead-heat prize splits where tied participants share pooled tiers, and writes idempotent payout ledger entries keyed by (contest_id, entry_id, payout_type). SendGrid dispatch listeners subscribe only to post-commit domain events, ensuring players never receive a payout confirmation email for a rolled-back database transaction.

Technology Stack

Category Technology detail
Mobile Clients React Native (iOS & Android shared prediction slip and live leaderboard UI)
Web Application React SPA for desktop bracket management and wallet history
Core API & Domain Laravel (PHP 8) handling contests, scoring rules, and ledger transactions
Database & Ledger MySQL with InnoDB row locking and immutable double-entry ledger tables
Authentication Laravel Passport OAuth2 tokens for mobile and web client sessions
Background Queues Laravel Queue workers on Google Cloud for scoring and prize payouts
Cloud Hosting Google Cloud Compute Engine, Cloud SQL, and managed load balancing
Email & Receipts SendGrid transactional API for entry confirmations and settlement statements

Engineering Trade-offs & Solutions

Challenge Architectural Solution
Double-spend or negative balances under concurrent taps Pessimistic InnoDB row locks (SELECT ... FOR UPDATE) paired with an immutable double-entry ledger inside single MySQL transactions
Post-kickoff prediction tampering Authoritative server-UTC cutoff checks executed inside the Laravel submission transaction, ignoring client device clocks
Duplicate payouts from retried queue workers Deterministic settlement keys enforced by MySQL unique constraints so retried jobs turn into safe idempotent no-ops
Late match corrections or abandoned games Multi-stage provisional to settled state machine with automated escrow refund jobs for voided contests
Divergent business rules across web and mobile Single versioned Laravel API backing both React Native and React clients with shared DTO serialization

Security & Reliability

Real-money workflows demand strict boundaries between player actions and administrative overrides. Laravel Passport scopes separate player endpoints from internal contest-operations and settlement routes, reinforced by role-based policies and audit logging on every manual state intervention. Input payloads undergo strict whitelist validation, and CSRF/CORS policies lock browser origins for the React web portal. Cloud SQL runs automated daily backups with binary-log point-in-time recovery enabled, giving finance administrators exact replay capability if an external payment webhook requires investigation. SendGrid templates strip sensitive internal identifiers and sign transactional emails via SPF and DKIM records.

Performance & Scale

Pre-kickoff traffic spikes hit read-heavy lobby endpoints and write-heavy slip-submission endpoints simultaneously. To keep lobby browsing responsive while wallet writes serialize safely per user, contest metadata and countdown schedules are served from short-lived cache layers invalidated on contest state transitions, while wallet locks scope strictly to the individual participant's wallet row rather than global tables. Leaderboard calculations execute incrementally in background workers as fixtures conclude, serving pre-ranked pages directly from indexed MySQL summary tables to thousands of concurrent mobile viewers. React Native clients apply optimistic slip drafting locally and issue compact diff payloads only upon final submission, reducing redundant payload chatter across mobile connections.

Operational Outcomes

Consolidating web and mobile contest rules behind one transactional Laravel core eliminated discrepancies between desktop and phone prediction slips. Finance and contest operations teams gained an auditable double-entry ledger and automated void/refund handling, replacing error-prone manual reconciliations. Players experience reliable pre-kickoff slip confirmation, transparent rank calculations, and prompt post-match prize settlement across both React Native and React web interfaces.

01 — Questions

asked about this kind of project

How does the system prevent users from submitting or editing predictions after a match begins?

Every fixture carries an authoritative UTC kickoff cutoff stored in MySQL. The Laravel API evaluates request arrival against server UTC time inside the submission transaction, rejecting any entry or edit after lock regardless of mobile device clock settings.

How are real-money wallet balances protected against race conditions and double-spending?

Wallet balances are never mutated directly in memory. Every contest entry fee, refund, and prize credit writes paired debit/credit rows to a double-entry ledger inside a MySQL transaction using SELECT ... FOR UPDATE on the account balance record.

What happens if an upstream sports score feed emits a late stat correction?

Contests move through distinct states: open, locked, provisional, and settled. Prize disbursements execute only when a contest transitions from provisional to settled after a configurable verification window, with automated reversal workflows if an event is voided.

Why pair React Native for mobile with a separate React web app over the same Laravel API?

Players frequently research multi-match prediction slips on desktop screens before tracking live standings on their phones. Sharing one versioned Laravel Passport API across React and React Native preserved domain parity while tailoring navigation density to each form factor.

How do you avoid duplicate prize payouts if a settlement queue job retries after a transient failure?

Each payout line item carries a deterministic settlement key derived from contest_id, entry_id, and payout_type. MySQL unique constraints combined with transactional state checks ensure retried jobs never issue a second credit.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.