A complete statistics dashboard and automation toolkit for Rise of Kingdoms.
Dashboard & Statistics
- Real-time kingdom rankings (Power, Kill Points, Deaths)
- Player profiles with historical stat charts
- Alliance rankings and member statistics
- Inactive player detection
DKP System (KvK Performance Tracking)
- Configurable KvK performance formula
- Power-tiered goals (different targets per power bracket)
- Formula:
(T4×2) + (T5×4) + (Dead×6) - (Power × coefficient) - Visual ranking with progress indicators
Title Bot
- Automated title management via in-game chat
- Queue system for title requests
- Real-time status tracking
Scanner
- OCR-based kingdom scanning
- Automatic data upload to dashboard
- Support for BlueStacks emulator
| Software | Version | Download | Notes |
|---|---|---|---|
| Python | 3.11+ | python.org | Check "Add to PATH" during install |
| Node.js | 20 LTS+ | nodejs.org | LTS version recommended |
| Git | Latest | git-scm.com | |
| Tesseract OCR | 5.x | See below | Required for scanner |
| BlueStacks | 5.x | bluestacks.com | Required for scanner |
The scanner requires Tesseract OCR to read text from the game.
Windows:
- Download installer from: https://github.com/UB-Mannheim/tesseract/wiki
- Direct link: tesseract-ocr-w64-setup-5.3.3.exe
- Run the installer
- IMPORTANT: Check "Add to PATH" during installation
- Default install path:
C:\Program Files\Tesseract-OCR - Verify installation:
tesseract --version
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install tesseract-ocr tesseract-ocr-engmacOS:
brew install tesseractThe scanner needs ADB to communicate with BlueStacks.
- Download Platform Tools
- Extract the ZIP file
- Copy
platform-toolsfolder to:RokTracker/deps/platform-tools/ - Enable ADB in BlueStacks: Settings > Advanced > Android Debug Bridge
Verify ADB works:
cd RokTracker\deps\platform-tools
.\adb.exe devicesgit clone https://github.com/YOUR_USERNAME/rok-stats-hub.git
cd rok-stats-hubcd backend
# Create virtual environment
python -m venv .venv
# Activate (Windows)
.\.venv\Scripts\activate
# Activate (Linux/Mac)
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create config file
copy .env.example .envEdit backend/.env:
DATABASE_URL=sqlite:///./rokstats.db
SECRET_KEY=generate-a-random-32-char-string-here
INGEST_TOKEN=generate-another-random-string-hereGenerate random keys:
python -c "import secrets; print(secrets.token_hex(32))"Initialize database and start:
alembic upgrade head
uvicorn app.main:app --host 0.0.0.0 --port 8000Backend runs at: http://localhost:8000
Open a new terminal:
cd frontend-next
# Install dependencies
npm install
# Create config file
copy .env.example .env.local
# Start development server
npm run devFrontend runs at: http://localhost:3000
- Open http://localhost:3000/admin
- Create an admin account
- Go to Admin Dashboard
- Create your kingdom (enter kingdom number)
cd RokTracker
# Create virtual environment
python -m venv venv
.\venv\Scripts\activate
# Install dependencies
pip install -r requirements_win64.txt
# Create config files
copy api_config.example.json api_config.json
copy bot_config.example.json bot_config.jsonEdit RokTracker/api_config.json:
{
"api_url": "http://localhost:8000/api",
"kingdom_numbers": [YOUR_KINGDOM_NUMBER],
"primary_kingdom": YOUR_KINGDOM_NUMBER,
"auto_upload": true
}Setup external dependencies:
- See
RokTracker/deps/README.mdfor ADB and Tesseract data setup
rok-stats-hub/
├── backend/ # FastAPI backend (Python)
│ ├── app/ # Application code
│ │ ├── main.py # API routes
│ │ ├── models.py # Database models
│ │ ├── schemas.py # Data validation
│ │ └── auth.py # Authentication
│ ├── alembic/ # Database migrations
│ ├── .env.example # Config template
│ └── requirements.txt # Python dependencies
│
├── frontend-next/ # Next.js dashboard
│ ├── app/ # Pages (App Router)
│ ├── components/ # React components
│ ├── lib/ # Utilities
│ └── .env.example # Config template
│
├── RokTracker/ # Scanner & Title Bot
│ ├── kingdom_scanner_*.py # Kingdom scanners
│ ├── title_bot.py # Title bot
│ ├── roktracker/ # Core scanner module
│ ├── deps/ # External dependencies
│ │ ├── platform-tools/ # ADB (download required)
│ │ └── tessdata/ # OCR data (optional)
│ ├── api_config.example.json
│ └── requirements_win64.txt
│
├── scripts/ # Deployment scripts
├── SETUP.bat # Windows auto-setup
└── START-DEV.bat # Start all services
| Variable | Description | Example |
|---|---|---|
| DATABASE_URL | Database connection | sqlite:///./rokstats.db |
| SECRET_KEY | JWT signing key (32+ chars) | your-random-secret |
| INGEST_TOKEN | Scanner auth token | your-ingest-token |
| HOST | Server host | 0.0.0.0 |
| PORT | Server port | 8000 |
| Variable | Description | Example |
|---|---|---|
| NEXT_PUBLIC_API_URL | Backend API URL | http://localhost:8000 |
| Field | Description |
|---|---|
| api_url | Backend API endpoint |
| kingdom_numbers | List of kingdom numbers to track |
| primary_kingdom | Main kingdom for reports |
| auto_upload | Auto-upload scans to API |
Quick start (Windows):
.\START-DEV.batManual start:
# Terminal 1 - Backend
cd backend
.\.venv\Scripts\activate
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Terminal 2 - Frontend
cd frontend-next
npm run dev- Open BlueStacks with Rise of Kingdoms
- Navigate to kingdom rankings screen
- Run scanner:
cd RokTracker .\venv\Scripts\activate python kingdom_scanner_console.py
- Follow on-screen instructions
- Open BlueStacks with Rise of Kingdoms
- Ensure your account has title permissions
- Run bot:
cd RokTracker .\venv\Scripts\activate python title_bot.py
- Players request titles via alliance chat
When backend is running:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| GET | /kingdoms | List all kingdoms |
| GET | /kingdoms/{id}/summary | Kingdom overview |
| GET | /kingdoms/{id}/top-power | Power rankings |
| GET | /kingdoms/{id}/dkp | DKP rankings |
| GET | /governors/{id} | Governor profile |
| POST | /ingest/roktracker | Upload scan data |
- Ensure Tesseract is installed
- Check it's in PATH:
tesseract --version - Restart terminal after installation
- Download platform-tools and extract to
RokTracker/deps/platform-tools/ - Enable ADB in BlueStacks (Settings > Advanced)
- Connect manually:
.\deps\platform-tools\adb.exe connect localhost:5555
- Ensure BlueStacks window is visible (not minimized)
- Try running as Administrator
- Check correct BlueStacks instance name in config
- Only run one backend instance at a time
- For production, use PostgreSQL instead of SQLite
- Ensure virtual environment is activated
- Run
pip install -r requirements.txtagain
See DEPLOY-GUIDE.md for production deployment instructions.
Quick Docker deployment:
docker-compose up -dSee CONTRIBUTING.md for contribution guidelines.
This project is for educational purposes. Use of automated tools in Rise of Kingdoms may violate the game's Terms of Service. Use at your own risk. The authors are not responsible for any consequences including account bans.
MIT License - See LICENSE