Advanced data collection and analysis system for OpenFront.io lobby data with real-time scraping, game processing, and REST API.
- Real-time lobby scraping - Collects lobby data every 5 seconds
- Intelligent game processing - Analyzes FFA games for spawn coordinates and winner data
- Automated API calls - Fetches detailed game data with rate limiting
- RESTful API - Serves current and historical data
- Database migrations - Schema versioning and updates
- Docker containerization - Portable and scalable deployment
- Scrapes current lobby data from OpenFront.io API
- Extracts unique lobby IDs and metadata
- Calls individual game APIs for detailed data
- Processes FFA games to extract spawn coordinates and winner analysis
- Serves data via REST API with historical views
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Job Scheduler │ │ Express API │ │ PostgreSQL │
│ │ │ │ │ │
│ • Scrape lobbies│ │ • /health │ │ • snapshots │
│ • Extract IDs │◄──►│ • /current │◄──►│ • game_data │
│ • Call APIs │ │ • /stats │ │ • unique_lobbies│
│ • Process games │ │ • /history │ │ • migrations │
└─────────────────┘ └──────────────────┘ └─────────────────┘
- Docker & Docker Compose
- Node.js 16+ (for local development)
# Clone the repository
git clone <your-repo-url>
cd openfront-scraper
# Start the entire system
docker-compose up -d
# Check if everything is running
curl http://localhost:3000/health# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your database settings
# Run database migrations
npm run migrate
# Start the API server (includes job scheduler)
npm run dev:watch| Endpoint | Description | Example |
|---|---|---|
GET /health |
System health check | {"status": "healthy", "version": "2.0.0"} |
GET /current |
Latest lobby snapshot | Current lobbies with timestamp |
GET /stats?days=7 |
Statistics for last N days | Snapshot counts and breakdowns |
GET /history/24 |
Snapshots from last N hours | Time-series lobby data |
# Get current lobby data
curl http://localhost:3000/current
# Get stats for last 7 days
curl http://localhost:3000/stats?days=7
# Get last 24 hours of snapshots
curl http://localhost:3000/history/24Environment variables (create .env file):
# Database
DATABASE_URL=postgres://scraper:password@localhost:5432/openfront
DB_HOST=localhost
DB_NAME=openfront
DB_USER=scraper
DB_PASSWORD=password
# API
PORT=3000
# Scraping (optional)
SCRAPE_INTERVAL=5000
OPENFRONT_API_URL=https://openfront.io/api/public_lobbiesThe system uses PostgreSQL with the following main tables:
snapshots- Raw lobby data collected every 5 secondsunique_lobbies- Extracted lobby metadata and processing statusgame_data- Processed FFA game analysis with spawn coordinatesgame_api_responses- Temporary storage for detailed game dataschema_migrations- Database migration tracking
The system runs several automated jobs:
| Job | Schedule | Purpose |
|---|---|---|
scrape-lobbies |
Every 5 seconds | Collect current lobby data |
extract-lobby-ids |
Every 30 seconds | Extract unique lobbies from snapshots |
call-game-api |
Every 15 minutes | Fetch detailed game data |
process-ffa-games |
Every 5 minutes | Analyze FFA games for spawn data |
For each Free-for-All game, the system:
- Fetches detailed game data from OpenFront API
- Analyzes turn-by-turn data to find spawn coordinates
- Identifies winner and their spawn location
- Stores processed data for analysis
{
"game_id": "abc123",
"game_map": "europe",
"winner_username": "player1",
"spawn_x": 45,
"spawn_y": 67,
"start_time": "2024-01-01T12:00:00Z"
}# Run pending migrations
npm run migrate
# Reset a specific migration
npm run migrate:reset 001-cleanup-unused-tables- Create job file in
src/jobs/ - Add to
src/jobs/job-registry.js - Jobs automatically get scheduled and executed
├── src/
│ ├── jobs/ # All processing jobs
│ └── scheduler/ # Job scheduling system
├── api/ # Express API server
├── shared/ # Database connections & utilities
├── sql/
│ └── migrations/ # Database schema changes
├── scripts/ # Utility scripts
├── docker-compose.yml # Container orchestration
└── Dockerfile # Container definition
# Basic health check
curl http://localhost:3000/health
# Database connectivity
docker-compose exec app npm run test# View real-time logs
docker-compose logs -f app
# View specific service logs
docker-compose logs postgres# Build and deploy
docker-compose -f docker-compose.prod.yml up -d
# Scale processing
docker-compose -f docker-compose.prod.yml up -d --scale processor=3- Set production environment variables
- Configure database with proper credentials
- Set up monitoring and alerting
- Configure log aggregation
-
v1.0 - Basic scraper -
v1.1 - Database storage -
v1.2 - Automatic scraping -
v2.0 - Docker deployment -
v3.0 - Advanced game processing - v4.0 - Team game analysis
- v4.1 - Player statistics and rankings
- v4.2 - Map-specific spawn analysis
- v5.0 - Real-time dashboard
- v5.1 - API rate limiting and authentication
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and ensure migrations work
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
- OpenFront.io for providing the game data API
- PostgreSQL community for the excellent database
- Docker for containerization platform