epic backend infrastructure

Guide for epic backend infrastructure

Epic: Backend Infrastructure & Performance

✅ Mission PERFORMANCE-CORE: Spatial Partitioning & Broadcasts

Status: ✅ Complete Completed: 2026-01-21
Functional Changes:
  • Performance: Game ticks are now more stable under high load due to distributed processing and spatial partitioning.
  • Scalability: The server can now efficiently handle significantly more concurrent players and NPCs.
  • SpatialGrid: Implemented generic grid for both Players and NPCs with O(1) chunk lookups.
  • BroadcastSystem: "Serialize Once, Broadcast Many" system, reducing O(N^2) complexity.

✅ Mission DB-MIGRATION: Apply death_state Column

Status: ✅ Complete Completed: 2026-01-23
Functional Changes:
  • Database Consistency: Fixed broken migration chain by restoring active_boosts, orders, users, item_bonuses, skills, product_catalog tables.
  • New Features: Successfully applied death_state (JSONB) column to players table.
  • Clean Slate: Database is now fully synchronized with codebase migrations.

✅ Mission STORE-ROUTES-WIRING: Expose Store API

Status: ✅ Complete Completed: 2026-01-22
Functional Changes:
  • Store API: Authentic Store functionality (Cart, Checkout) is now exposed via HTTP API.
  • Router: Wired validate_cart, create_checkout_intent, finalize_checkout to /v1/store/.

✅ Mission ECOMMERCE-API: Wire Remaining Store HTTP Routes

Status: ✅ Complete Completed: 2026-01-21
Functional Changes:
  • Store Checkout: Users can now validate carts and process checkouts via the API (supporting Stripe intents).
  • Chargebacks: Implemented ChargebackHandler handling charge.dispute.created events.
  • Debt System: Integrated DebtManager to block login for users with outstanding chargeback debt.

✅ Mission GROWTH-ENGINE: Wire Growth HTTP Routes

Status: ✅ Complete Completed: 2026-01-21
Functional Changes:
  • Players can now generate/view referral codes and apply referrals via API (MOK-XXXXXXX format).
  • Admins can view and approve affiliate applications via API.

📦 Mission FIX-WS-PANIC: Panic-Safe Session Cleanup

Status: ✅ Complete Completed: 2026-01-26 Functional Changes:
  • Reliability: Implemented SessionCleanupGuard to guarantee session removal on panic.
  • Stability: Resolved "Connection reset" errors causing bot login loops.

📦 Mission PERFORMANCE-HARDENING: Database Optimization & Scalability

Status: ✅ Complete Completed: 2026-01-26 Functional Changes:
  • Market DB Separation: Isolated Market data to dedicated database loh_market.
  • Query Optimization: Fixed N+1 issues in Inventory Save (UNNEST), Bank Presets, and PVP Deaths.
  • Caching: Implemented 1-hour Cache-Control for Market Analytics.
  • Indexing: Added idx_market_history_time for fast analytics.