Next-generation analytics & ML-powered churn prediction for Solana gaming. Self-training models predict player churn 14 days in advance. Live dashboard + REST API analyzing 60M+ on-chain transactions across 12 games.
Last updated Jun 19, 2026
18
Stars
1
Forks
0
Issues
0
Stars/day
Attention Score
42
Topics
Language breakdown
No language data available.
โธ Files
click to expand
README
# Solana Game Analytics, Player Behavior Modeling and Predictive Forecasting
๐ฏ The Problem & Solution
The Problem
Solana's gaming ecosystem generates millions of on-chain transactions daily, but game developers lack tools to:- Predict which players will leave before they churn
- Understand cross-game behavior patterns
- Make data-driven retention decisions
The Solution
A production-grade platform that:- Aggregates 60M+ user transactions from 12 Solana games in real-time
- Predicts player churn 14 days in advance using advanced ML (typically >85% ROC-AUC accuracy)
- Auto-retrains models whenever fresh blockchain data arrives
- Visualizes insights through a gamified dashboard that auto-updates frequently
- Empowers game developers to proactively retain players, not just react to losses
๐ Value Proposition
For Game Developers
- ๐ฏ Predict churn 14 days before it happens (>85% accuracy)
- ๐ฐ Reduce player acquisition costs by improving retention
- ๐ Understand cross-game behavior across Solana ecosystem
- ๐ค Zero-maintenance ML that auto-improves with new data
For Players
- ๐ Discover top-performing games by retention metrics
- ๐ Find similar games you might enjoy
- ๐ See your own engagement patterns (future wallet integration)
For Solana Ecosystem
- ๐ First comprehensive gaming analytics platform
- ๐ง Open-source ML models for community use
- ๐ Cross-game insights unavailable elsewhere
โ๏ธ Solana Integration
This project is deeply integrated with the Solana blockchain:Direct Blockchain Data
- ๐ 60M+ Transactions: Real Solana on-chain data from 12 games
- ๐ Transaction Analysis: Every metric derived from verified blockchain transactions
- โฑ๏ธ Real-Time Sync: Updates as new blocks finalize on Solana
Technical Implementation
- RPC Analysis: Custom
classifier.pyidentifies Programs, NFTs, Tokens, PDAs via Solana RPC
- Dune Queries: 11 custom SQL queries across Solana's blockchain data
- Wallet Tracking: Individual user behavior per Solana wallet address
- Cross-Game Logic: Detects shared wallets across multiple Solana games
- Solscan Integration: Direct links to wallet explorers for transparency
Why This Matters for Solana Gaming
- ๐ฎ First Analytics Platform: Solana gaming lacks comprehensive analytics tools
- ๐ Ecosystem Growth: Helps games retain players = stronger Solana gaming ecosystem
- ๐ Network Effects: Cross-game insights only possible on-chain
- ๐ Open Source: All 11 Dune queries publicly available for community use
โจ Key Features
๐ Real-Time Analytics Engine
- 11 Behavioral Metrics: Activation, retention, reactivation, deactivation, cross-game behavior
- Individual User-Level Data: Granular transaction tracking per wallet
- 12 Games Tracked: Star Atlas, StepN, Genopets, Portals, Honeyland, and more
- 60-Day Rolling Window: Comprehensive behavior history
- Sub-100ms Response: Cached endpoints for instant insights
- Auto-Refresh: Data updates automatically from Dune Analytics
๐ค Self-Training ML System
- 5 ML Algorithms: Logistic Regression, Random Forest, Gradient Boosting, XGBoost, LightGBM
- Auto-Champion Selection: Best model automatically chosen by ROC-AUC score after each training
- Ensemble Predictions: Weighted average of top 3 models for robustness
- Automated Retraining: Models retrain whenever fresh data arrives (no manual intervention)
- 10 Engineered Features: Activity patterns, momentum, consistency, recency metrics
- Adaptive Risk Thresholds: Dynamic percentile-based classification ensures meaningful High/Medium/Low categories regardless of population health
- Real-Time Predictions: Churn risk calculated for all active users
๐จ Gamified Dashboard
- Elite Gamers Scroller: Live ticker of top power users with clickable Solscan links
- Dynamic Alerts: Real-time warnings (Critical/Warning/Success) that adapt as data changes
- Interactive Visualizations: Heatmaps, network graphs, time-series charts, etc.
- Light/Dark Mode: Solana-branded theme with particle effects
- Auto-Refresh: Auto-updates with zero manual reload
- 100% Data Display: All records shown via virtualized tables
โก Production-Grade Architecture
- 99%+ Uptime: Deployed on Railway (backend) and Vercel (frontend)
- Intelligent Caching: 168-hour TTL with automatic refresh
- Type-Safe: 100% TypeScript coverage (strict mode)
- Zero Runtime Errors: Comprehensive error handling
- Scalable: Handles 200K+ records without performance degradation
๐๏ธ System Architecture
Solana Blockchain (12 Games)
โ
Dune Analytics (11 Queries)
โ [Every 168 hours]
FastAPI Backend (Railway)
โโ Cache Manager (Auto-refresh on TTL expiry)
โโ Feature Engineering (10 features)
โโ ML Manager (5 models, auto-train)
โ โโ Train on fresh data
โ โโ Select champion by ROC-AUC
โ โโ Generate predictions
โโ Prediction Cache
โ
REST API (21 endpoints)
โ
React Frontend (Vercel)
โโ TanStack Query (30s polling)
โโ Zustand (State mgmt)
โโ Recharts/D3 (Viz)
Key Innovation: Self-training pipeline - Models automatically retrain whenever /api/cache/refresh is triggered, selecting the best-performing algorithm based on current data patterns. No manual retraining needed!
Full Architecture Details: See TECHNICAL_DOCUMENTATION.md for 15,000+ word deep dive.
๐ ๏ธ Technology Stack
| Layer | Technologies | Why? | |-------|-------------|------| | Backend | Python 3.11, FastAPI, pandas, scikit-learn, XGBoost, LightGBM, joblib | Async API, robust ML, efficient caching | | Frontend | React 19, TypeScript 5.0, Zustand, TanStack Query, Recharts, D3, Tailwind | Type-safe, reactive, performant | | Data Source | Dune Analytics SDK | Direct Solana blockchain data access | | Deployment | Railway (backend), Vercel (frontend) | Auto-deploy, edge network, 99%+ uptime |๐ Project Structure
solana-games-analytics/
โโโ backend/ # FastAPI ML Backend
โ โโโ main.py # ๐ฅ Core API (1,400+ lines)
โ โโโ requirements.txt # Python dependencies
โ โโโ Dockerfile # Container configuration
โ โโโ railway.json # Railway deployment config
โ โโโ .env.example # Environment variables template
โ โโโ rawdatacache/ # ๐พ Cached Dune query results
โ โ โโโ *.joblib # Serialized DataFrames
โ โ โโโ cache_metadata.json # Cache timestamps & row counts
โ โโโ ml_models/ # ๐ค Trained ML models
โ โโโ logistic_regression.joblib
โ โโโ random_forest.joblib
โ โโโ gradient_boosting.joblib
โ โโโ xgboost.joblib
โ โโโ lightgbm.joblib
โ โโโ scaler.joblib # Feature scaler
โ โโโ metadata.json # Model metrics & history
โ
โโโ frontend/ # React 19 Dashboard
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ features/
โ โ โ โ โโโ analytics/ # Analytics visualizations
โ โ โ โ โ โโโ GamerRetention.tsx
โ โ โ โ โ โโโ DailyActivity.tsx
โ โ โ โ โ โโโ CrossGameNetwork.tsx
โ โ โ โ โ โโโ ...
โ โ โ โ โโโ ml/ # ML prediction displays
โ โ โ โ โโโ ChurnPredictions.tsx
โ โ โ โ โโโ HighRiskUsers.tsx
โ โ โ โ โโโ ModelLeaderboard.tsx
โ โ โ โ โโโ ...
โ โ โ โโโ layout/
โ โ โ โ โโโ Header.tsx # Logo, theme toggle, live indicator
โ โ โ โ โโโ Footer.tsx # Credits, API status, timestamp
โ โ โ โ โโโ EliteGamerScroller.tsx # ๐ Infinite scroller
โ โ โ โโโ providers/
โ โ โ โ โโโ ThemeProvider.tsx
โ โ โ โโโ ui/ # Design system primitives
โ โ โ โโโ GlassCard.tsx
โ โ โ โโโ NeonButton.tsx
โ โ โ โโโ ...
โ โ โโโ hooks/
โ โ โ โโโ useAutoRefresh.ts # 30-second polling hook
โ โ โ โโโ useTheme.ts
โ โ โโโ pages/
โ โ โ โโโ DashboardPage.tsx # Main analytics view
โ โ โ โโโ MLPage.tsx # AI predictions view
โ โ โโโ services/
โ โ โ โโโ api.ts # Typed API client
โ โ โโโ types/
โ โ โ โโโ api.ts # Shared TypeScript types
โ โ โโโ utils/
โ โ โโโ formatters.ts # Number/date formatting
โ โโโ public/ # Static assets
โ โโโ package.json
โ โโโ tsconfig.json
โ โโโ tailwind.config.js
โ โโโ vite.config.ts
โ
โโโ classifier.py # On-chain address type detector
โ # Identifies: Programs, NFTs, Tokens,
โ # Token Accounts, PDAs via RPC analysis
โ # Guided creation of 11 Dune queries
โโโ TECHNICAL_DOCUMENTATION.md # ๐ Architecture deep-dive (15,000+ words)
โโโ README.md # ๐ You are here
๐ง Machine Learning Pipeline
Features Extracted (10 per user-game pair)
| Feature | What It Measures | Why It Matters | |---------|------------------|----------------| |activedayslast_8 | Recent activity level | Recent engagement is strongest churn predictor |
| transactionslast8 | Recent engagement intensity | High recent activity = lower churn risk |
| totalactivedays | Tenure/experience | Longer-term users less likely to churn |
| total_transactions | Lifetime value proxy | High LTV users worth retention effort |
| avgtransactionsper_day | Average engagement rate | Consistent engagement indicates habit |
| dayssincelast_activity | Recency (lower = better) | Long absence = high churn signal |
| week1_transactions | Onboarding success | Strong start = better retention |
| weeklasttransactions | Current engagement | Declining recent activity = warning |
| earlytolate_momentum | Trend (>1 = growing, <1 = declining) | Momentum direction predicts future |
| consistency_score | Play regularity | Regular players vs sporadic visitors |
Automated Training Process
1. Data Ingestion โ Dune Analytics queries (last 60 days)
- Cache Check โ Use cached if <168hrs old, else fetch fresh
- Feature Eng โ Extract 10 features per user-game pair
- Data Split โ 75% train, 25% test (stratified)
4.5. SMOTE Balance โ Synthetic minority oversampling to handle 95%+ class imbalance
- Standardize โ Z-score normalization (mean=0, std=1)
- Train 5 Models โ Parallel training (all algorithms)
- Evaluate โ ROC-AUC (primary), Accuracy, Precision, Recall
- Select Champion โ Best ROC-AUC wins (typically Random Forest or LightGBM)
- Build Ensemble โ Top 3 models weighted by performance
- Generate Preds โ Churn risk for all active users
- Cache Results โ Predictions cached for 168 hours
Retraining Triggers:
- Manual:
POST /api/cache/refresh
- Automatic: When cache expires and new data requested
- Result: Champion model may change based on current data patterns
Prediction Methods
- Champion Method: Uses only the current best-performing model
- Ensemble Method: Weighted average of top 3 models (more robust)
Risk Classification (Dynamic Percentile-Based)
- ๐ด High Risk (Top 15%): Immediate intervention needed
- ๐ก Medium Risk (50th-85th percentile): Monitor closely
- ๐ข Low Risk (Bottom 50%): Healthy engagement
Current Performance (Live Examples)
- ROC-AUC: ~86% (excellent discrimination)
- Recall: ~55% (catches over half of churners)
- Precision: ~8% (conservative flagging for low-cost interventions)
- Accuracy: ~87% (post-SMOTE balancing)
๐ API Endpoints
Analytics (11 Endpoints)
All return{metadata, data} with cache info and UTC timestamps.
| Endpoint | Purpose | What It Shows |
|----------|---------|---------------|
| /api/analytics/gamer-activation | New user acquisition | Daily new players per game |
| /api/analytics/gamer-retention | Cohort retention | Week-over-week retention % |
| /api/analytics/gamer-reactivation | Returning users | Weekly reactivation counts |
| /api/analytics/gamer-deactivation | Churned users | Weekly churn tracking |
| /api/analytics/high-retention-users | Power users | Players with >50% retention |
| /api/analytics/high-retention-summary | Game-level retention | Per-game retention stats |
| /api/analytics/gamers-by-games-played | Multi-game distribution | Users by # of games played |
| /api/analytics/cross-game-gamers | Multi-game players | Cross-game engagement |
| /api/analytics/gaming-activity-total | Lifetime metrics | Total txs & users per game |
| /api/analytics/daily-gaming-activity | Time-series data | Daily activity trends |
| /api/analytics/user-daily-activity | User-level log | Individual transaction data |
ML Predictions (5 Endpoints)
| Endpoint | Purpose | |----------|---------| |/api/ml/predictions/churn?method=ensemble | Churn risk for all users |
| /api/ml/predictions/churn/by-game | Game-level churn aggregates |
| /api/ml/predictions/high-risk-users?limit=100 | Top N at-risk users |
| /api/ml/models/leaderboard | All 5 models ranked by performance |
| /api/ml/models/info | Current champion details & features |
Utilities (5 Endpoints)
/api/health- System health & current stats
/api/cache/status- Cache freshness & ages
/api/cache/refresh- Force refresh & retrain (POST)
/api/bulk/analytics- All 11 analytics at once
/api/bulk/predictions- All ML predictions at once
๐ Quick Start
Backend Setup
# 1. Clone repository
git clone https://github.com/joshuatochinwachi/Solana-Game-Signals-and-Predictive-Modelling.git
cd Solana-Game-Signals-and-Predictive-Modelling/backend
2. Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
3. Install dependencies
pip install -r requirements.txt
4. Configure environment
cp .env.example .env
Add your DEFIJOSHDUNEQUERYAPIKEY1 (and 2, 3 for rotation)
5. Run server
uvicorn main:app --reload --port 8000
API: http://localhost:8000
Docs: http://localhost:8000/docs
Frontend Setup
# 1. Navigate to frontend
cd ../frontend
2. Install dependencies
npm install
3. Configure environment
cp .env.example .env
Set VITEAPIBASE_URL=http://localhost:8000
4. Start dev server
npm run dev
Dashboard: http://localhost:5173
Environment Variables
Backend (.env) - See.env.example for full list:
# Dune API Keys (required - supports multi-key rotation)
DEFIJOSHDUNEQUERYAPIKEY1=yourkey1
DEFIJOSHDUNEQUERYAPIKEY2=yourkey2 # Optional
DEFIJOSHDUNEQUERYAPIKEY3=yourkey3 # Optional
Configuration
CACHE_DURATION=604800 # 168 hours (default)
MINTRAININGSAMPLES=100
PREDICTIONWINDOWDAYS=14
FASTAPISECRET=yoursecret
Query IDs (11 total - see .env.example)
Frontend (.env):
VITEAPIBASE_URL=http://localhost:8000
๐จ Dashboard Features
Elite Gamers Scroller
Infinite horizontal ticker showing top power users:- ๐
abc123...xyz | 3 Games | 95% Retention | Low Riskโ
- Clickable wallet addresses (links to Solscan)
- Auto-scrolls continuously (pauses on hover)
- Updates every 30 seconds with fresh predictions
Dynamic Alerts
Real-time warnings that adapt as data changes:- ๐จ Critical: High-risk users exceed threshold
- โ ๏ธ Warning: Deactivation spikes, declining retention
- โ Success: Improving ecosystem metrics
- ๐ก Opportunity: Cross-game promotion potential
Interactive Visualizations
- Cohort Retention Heatmap: Week-over-week retention %
- Cross-Game Network Graph: Shared user connections (D3.js)
- Daily Activity Time-Series: Transaction trends per game
- Risk Distribution Pie: High/Medium/Low churn segments
- Complete Data Tables: All records with search, sort, pagination, virtualization
Design System
- Solana Gradient: Purple (
#9945FF) โ Cyan (#14F195)
- Glassmorphism: Semi-transparent cards with backdrop blur
- Particle Background: 50 floating particles (20s animation)
- Neon Accents: Glowing borders on hover
- Gaming Typography: Orbitron headers, Inter body
- Light/Dark Mode: Fully themed toggle
๐ Technical Achievements
Performance
- โก API Response: <100ms (cached), 2-5s (fresh data)
- ๐ Frontend Load: <2s (Lighthouse 99/100)
- ๐ Data Completeness: 100% (all records displayed)
- ๐ Update Frequency: 30 seconds (frontend polling)
- ๐ ML Training: Fully automated, no manual intervention
- ๐ฏ Typical ROC-AUC: 85-90% (varies with data)
Code Quality
- โ Type Safety: 100% TypeScript (strict mode)
- โ Error Handling: Comprehensive try-catch blocks
- โ Zero Runtime Errors: Clean production build
- โ Accessibility: WCAG 2.1 AA compliant
- โ Responsive: Mobile/tablet/desktop/ultrawide
- โ Robust ML: Proper churn labeling with adaptive risk thresholds
- โ No Data Leakage: Temporal validation prevents future information from affecting training
Scalability
- ๐ง API Key Rotation: Round-robin across 3 keys
- ๐ง Atomic State: Zustand for minimal re-renders
- ๐ง Virtualized Tables: Handle 200K+ rows smoothly
- ๐ง Code Splitting: Lazy-loaded routes
- ๐ง Edge Deployment: Vercel CDN globally
๐ Live Ecosystem Insights
Want to see current stats? Visit these endpoints:- Overall Health: /api/health
- Current Champion: /api/ml/models/info
- Model Rankings: /api/ml/models/leaderboard
- Churn Summary: /api/ml/predictions/churn
๐ Traction & Impact
Live Metrics
- ๐ฎ 12 Games Tracked: Largest Solana gaming dataset
- ๐ฅ Active Users: Check live count
- โก 99%+ Uptime: Production-grade reliability since deployment
- ๐ Auto-Updates: Self-training ML requires zero maintenance
- ๐ Global Reach: Vercel edge deployment across 25+ regions
Technical Validation
- โ Live API: 21 endpoints operational
- โ Real Predictions: View current churn risks
- โ Model Performance: Live leaderboard
- โ Open Source: All code and queries publicly available
Community Engagement
- ๐ฆ Twitter/X: @defijosh
- ๐ Dune Dashboard: Public analytics
- ๐ฌ GitHub Discussions: Open for collaboration
- ๐ง Developer Contact: joshuatochinwachi@gmail.com
๐ฃ๏ธ Roadmap
โ Phase 1: Current (Completed)
- โ 11 analytics endpoints with real-time data
- โ 5-model ML ensemble with auto-selection
- โ Self-training pipeline (no manual retraining)
- โ Gamified React dashboard
- โ Production deployment (Railway + Vercel)
- โ Dynamic risk classification system
๐ Phase 2: Enhanced Intelligence (Q1 2026)
- ๐ฒ LTV Prediction: Forecast user lifetime value
- ๐ฒ Anomaly Detection: Alert on unusual patterns
- ๐ฒ Sentiment Analysis: Discord/Twitter mood tracking
- ๐ฒ Recommendation Engine: Game suggestions
๐ Phase 3: Platform Expansion (Q2 2026)
- ๐ฒ Mobile App: React Native iOS/Android
- ๐ฒ Wallet Connect: Personalized insights
- ๐ฒ Developer API: Public API for studios
- ๐ฒ Zapier Integration: No-code automation
๐ Phase 4: Decentralization (Q3 2026)
- ๐ฒ On-Chain Analytics: Solana program deployment
- ๐ฒ ZK-Proofs: Privacy-preserving profiling
- ๐ฒ Token Incentives: Reward contributors
- ๐ฒ DAO Governance: Community-driven roadmap
Partner Integration Opportunities
Ready to integrate with: | Partner | Integration Idea | Benefit | |---------|------------------|---------| | ๐ฎ Play Solana | Embed analytics widget in game portals | Players discover high-retention games | | ๐จ Moddio | Real-time churn alerts in game dev tools | Developers get instant notifications | | ๐ค icm.run | Trigger automated retention campaigns | AI-powered personalized interventions | | ๐ฑ Alphabot | Discord bot for whale tracking | Studios monitor VIP players 24/7 | Value Proposition: Game studios get enterprise-grade analytics without building infrastructure.๐ค Contributing
I welcome contributions! Here's how:- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Guidelines:
- Write tests for new features
- Follow existing code style (ESLint/Black)
- Update docs for API changes
- Keep commits atomic
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.๐ Acknowledgments
- Data: Dune Analytics โข Solana
- Libraries: FastAPI, React, scikit-learn, XGBoost, LightGBM, Recharts, D3.js, Tailwind CSS
- Infrastructure: Railway โข Vercel
- Games Analyzed: Star Atlas, StepN, Genopets, Portals, Honeyland, Aurory, MixMob, Nyan Heroes, Faraway, Axie Rescue, ev.io, Portals Chrono Rush
๐ง Contact & Resources
- Developer: Josh (@defi__josh) - Solo Developer
- Twitter/X: @defijosh
- Email: joshuatochinwachi@gmail.com
- GitHub: @joshuatochinwachi
- Live Demo/Frontend Web App: https://solana-games.app
- Issues: Open an issue
- Questions: Start a discussion
- Technical Deep Dive: TECHNICAL_DOCUMENTATION.md
๐ Try It Now & Support
๐ฎ Launch Live Dashboard
Experience real-time analytics and ML predictions๐ Explore Interactive API
Try all 21 endpoints in your browserSupport This Project
|
โญ Star on GitHub Show your support |
๐ฆ Follow @defijosh Get updates |
๐ฌ Share Feedback Help us improve |
Built with โค๏ธ for the Solana Gaming Ecosystem
๐ More in this category