The Architecture of Engagement

Gamifly Docs

Gamifly is an API-first gamification engine designed to bridge the gap between administrative logic and real-time player experience. Deploy high-stakes missions, global tournaments, and self-sustaining economies into any application with sub-millisecond precision.

The Stitch Protocol

The **Stitch Protocol** is Gamifly's proprietary synchronization layer that ensures 100% data parity between your game backend and the player's visual overlay. Traditional gamification plugins suffer from "latency drift," where a player's achievement is recorded but not celebrated until a page refresh.

Infinite Scalability & Templates

Gamifly is built for limitless growth. Operators are empowered to create **as many tournaments, missions, and badges as their ecosystem requires**. There are no "content caps"—only your strategic vision. To accelerate launch times, you can deploy using our pre-built **Campaign Templates** or craft unique logic from scratch.

Event Shadowing

Gamifly processes events in parallel to your main transaction, ensuring zero impact on your core game performance.

Reactive HUD

The Stitch SDK listens for state changes via a WebSocket connection, reflecting mission progress instantly.

The Kafka Ingestion Layer

For enterprise deployments, the **Gamifly Ingestion Backbone** consumes live player bet data directly from your Kafka topics. This enables sub-millisecond calculation of leaderboard ranks and node progress without taxing your primary database.

KAFKA TOPIC bet.stream.v1

Gamifly acts as a consumer group, processing high-velocity JSON payloads representing player actions.

{
  "playerId": "David_007",
  "transactionId": "TX_99182",
  "action_type": "wager",
  "amount": 5.00,
  "currency": "EUR",
  "game_context": {
    "provider": "Pragmatic",
    "category": "Slots",
    "multiplier": 2.5
  }
}

Poll-to-Market Sync

Operators can manually trigger a Kafka Topic Poll from the Backoffice to sync promotional bonuses from partner providers and "Promote" them to the frontend Market.

Signed Reward Dispatch

When a prize is cleared, Gamifly produces a cryptographically signed event back to your fulfillment topic, ensuring end-to-end security.

Strategic Competitions

Managing the Arena

Gamifly Tournaments are designed to drive high-intensity volume through real-time rank competition. Below is the configuration logic for creating your first enterprise tournament.

1. Selection of Criteria

Choose the mathematical rule that governs player scoring. Gamifly supports complex win-condition aggregates handled by our streaming engine.

Highest Wager

Scoring is based on the total cumulative bet amount during the event timeframe. Ideal for high-stakes "Whale" retention.

criteria: 'total_wager'

Best Multiplier

Scoring is based on the single highest win-to-bet ratio. Levels the playing field for casual and VIP players alike.

criteria: 'multiplier'

2. Prize Budgeting & Tiers

Configure automated prize distribution across player ranks. Gamifly supports multi-currency rewards including Gems, Gold, and External Reward IDs (Bonuses).

Rank GroupReward TypeDefault Value
1st PlaceGrand Trophy + Bonus$1,000 + 500 Gems
2nd - 5thPremium Bonus$250 + 200 Gems
6th - 50thBoost Pack100 Free Spins
Engagement Blueprinting

Blueprinting Journeys

Missions are the narrative backbone of the Gamifly experience. Follow this operational guide to deploy a new sequence of player milestones.

01

Define thresholds

Set the numeric requirement for each node (e.g., "50 Spins" or "$200 Wagered"). These are processed in real-time against the Kafka bet stream.

02

Select World Skin

Map the journey to a 3D environment. We recommend **Void Station** for high-difficulty missions and **Lagoon Isle** for onboarding.

03

Assign Rewards

Connect each node to your fulfillment engine using webhooks or the Kafka reward dispatch topic.

Pro-Tip: Progressive Difficulty

Successful missions use an "Easy Start" model. The first node should have a low threshold (e.g., 5 spins) to trigger the initial "Stitch" celebration and hook the player into the journey loop.

Visual Storytelling

Mission Forge Worlds

Missions aren't just progress bars—they are journeys. The **Mission Forge** allows you to deploy 3D-accelerated landscapes that change based on player progress.

☁️

Nebula Heights

A serene, cloud-based floating city. Ideal for "Dream Hunter" or high-limit VIP journeys.

🌲

Emerald Glade

A deep, lush forest ecosystem. Perfect for exploration and multiplier-hunting missions.

🚀

Void Station

A high-tech space colony. Designed for intense, time-limited weekend rushes and hyper-volatile events.

🏝️

Lagoon Isle

A tropical paradise. Best for onboarding quests and low-volatility engagement loops.

Proven Game Theory

Campaign Blueprints

Don't reinvent the wheel. Start with our industry-validated templates designed for specific KPI outcomes.

Blueprint Core KPI Node Structure Default Rewards
The Welcome Odyssey Retention (D7) 7 Nodes (Deposit -> Wager) Free Spins + Gems
WEEKEND RUSH DAU / Weekend Volume 4 Nodes (Sprint format) Loss Rebates (5-15%)
EK TIME ZONE Cross-Sell (Sports) 6 Nodes (Settled Bets) Profit Boosts (5-15%)
VIP High Roller Mountain Yield / Whale LTV 5 Nodes (Min Wager $1k) Gems + Concierge Unlock
Slot Safari Discovery (Provider Mix) 7 Nodes (Spins per Provider) Dynamic Multipliers
Loyalty Ladder Churn Prevention 10-Week Login Streak Permanent Deposit Boost
Custom Control

Advanced SDK Integration

Beyond the drop-in overlay, Gamifly provides hooks to deeply integrate the engagement state into your own UI.

Real-time State Subscription

Listen for "Achievement Unlocked" or "Node Cleared" events to trigger your own celebration animations or sound effects.

// Subscribe to player progress updates
engine.on('node_cleared', (data) => {
  console.log(`Player completed ${data.nodeName}!`);
  
  // Trigger your own animation
  myConfettiOverlay.burst();
});

// Get current player state at any time
const state = await engine.getPlayerState('user_99');
console.log(state.activeMissions[0].progress);

Custom UI Override

Disable the default drawer and build your own HUD using our data stream.

const engine = new Gamifly({
  apiKey: '...',
  disableDefaultUI: true // Native UI mode
});
The Data Layer

API Reference Index

POST /v1/events/ingest

The primary entry point for behavior tracking. Ingests raw player data for processing.

ParamTypeDescription
playerIdStringUnique identifier for the user.
actionEnumspin | deposit | login | bet
valueFloatThe numerical value of the action (e.g. wager amount).
metadataObjectAdditional context (provider, odds, category).
GET /v1/players/{id}/economy

Returns the player's current currency balances and badge inventory.

Closed-Loop Fulfillment

Webhooks & Fulfillment

When a player earns a reward, Gamifly sends a cryptographically signed webhook to your fulfillment server.

// Example Webhook Payload (Fulfillment)
{
  "type": "reward_granted",
  "timestamp": "2026-04-14T18:30:00Z",
  "playerId": "user_99",
  "reward": {
    "id": "bonus_25_fs",
    "type": "free_spins",
    "amount": 25
  },
  "signature": "sha256=...."
}
Enterprise Delivery

Production Integration Guide

This document summarizes how to integrate the "Gamification Engine" infrastructure with your main betting/casino platform for technical teams. A more detailed and full version can be read from the docs/production-integration.md file within the source code.

1. Database (Supabase) Setup

After testing, create a new isolated project for the Production environment and apply the Migrations (supabase/migrations) via the CLI from your computer:

npx supabase login
npx supabase link --project-ref 
npx supabase db push

Also, ensure that seed (initial) data such as market_items and badges_config are migrated to the Production environment using the export/import method.

2. Iframe Integration and Security (JWT Auth)

To secure players, your main Casino system must generate a unique, one-time signed JWT token for the player before opening the Iframe (Gamifly).

// Casino Backend (Node.js Example)
const token = jwt.sign({
  sub: "DAVID", // player_id
  role: 'authenticated',
  exp: Math.floor(Date.now() / 1000) + (3600)
}, SUPABASE_JWT_SECRET);

// Iframe Source (src)
return `https://gamifly-domain.com/hub?token=${token}`;

RLS rules must be hardened in Production:

CREATE POLICY "Only owner can view" ON player_economy 
FOR SELECT USING (auth.uid() = player_id);

3. Reward Delivery (Fulfillment / Webhooks)

When a reward like "10 Free Spins" or a Cash Reward (Bonus Wallet) is earned in the Gamifly interface and the database processes the calculation, your system needs to assign the actual Spin (e.g., NetEnt) to the player. You can transmit this to your Casino server by triggering Database Webhooks via Supabase.