Technology stack
Rear JackMan is built with:- CloudFlare Workers - Serverless edge computing platform
- CloudFlare D1 - SQLite-based serverless database
- CloudFlare Queues - Message queue for background processing
- TypeScript - Type-safe JavaScript
- Jolpica F1 API - External data source for race information
The app is intentionally minimalist with no frontend framework. All HTML is server-rendered with vanilla CSS and minimal JavaScript for interactivity.
Architecture overview
The application has two primary flows as described in the README:- Sync flow - Background task to fetch data from external sources
- Serve flow - UI rendering to display race data
High-level architecture
Sync flow
The sync flow is responsible for fetching race data from the Jolpica F1 API and storing it in the D1 database.Sync triggers
There are two ways to trigger a data sync:-
Scheduled cron job - Runs every Monday at 6:00 AM UTC
- Defined in
wrangler.toml:crons = ["0 6 * * MON"] - Automatically syncs the latest completed race
- Checks if any races have occurred since the last sync
- Defined in
-
Manual sync endpoint -
POST /api/sync/:season- Requires
X-Sync-Secretheader for authentication - Allows syncing specific rounds with query parameters
- Example:
/api/sync/2026?from=5&to=10
- Requires
Sync process
When a sync is triggered:Queue consumer processes message
The queue consumer calls
syncSeason() from src/sync.ts to fetch data:- Fetches race schedule from Jolpica API
- For each completed race:
- Fetches race results
- Fetches driver standings (before/after)
- Fetches constructor standings (before/after)
- Implements rate limiting and retry logic
- Uses 2-second delays between API calls
Rate limiting and resilience
The sync system includes robust error handling:- Exponential backoff for 429 rate limit errors (5s, 10s, 20s, 40s, 80s)
- Retry-After header support to respect API rate limits
- Maximum 5 retries before failing
- Queue retry mechanism for failed sync jobs
Serve flow
The serve flow handles HTTP requests and renders HTML pages.Request routing
The main worker (src/worker.ts) implements a simple router that matches URL patterns:
Available routes
Home page - List of available seasonsReturns a simple list with the current season marked as “LIVE”.
Season list - All races in a specific seasonExample:
/2026 shows all races for the 2026 season with dates and circuits.Race detail - Complete race informationExample:
/2026/5 shows Round 5 results, standings, and position changes.Driver profile - Driver performance across seasonsExample:
/driver/max_verstappen?season=2026Shows race-by-race results for the specified driver.Constructor profile - Team performance across seasonsExample:
/constructor/red_bull?season=2026Shows all results for both team drivers.Manual sync trigger - Queue a data sync jobRequires
X-Sync-Secret header. Supports from and to query parameters for round ranges.Rendering system
All pages are server-rendered using TypeScript template functions:- Page renderers in
src/ui/pages/generate HTML for specific pages - Layout wrapper in
src/ui/layout.tsprovides the HTML shell - Inline CSS in
src/ui/styles.tsfor styling - Client script in
src/ui/client.tsfor interactivity (collapsible sections)
Data model
The application uses three main database tables:- races - One row per race with schedule and circuit details
- race_entries - One row per driver per race with results
- standings_snapshots - Championship standings “before” and “after” each race
The “before/after” snapshot approach allows users to see how the championship evolved throughout the season.
CloudFlare Workers features
Rear JackMan leverages several CloudFlare Workers features:D1 Database
SQLite-based serverless database with:- SQL migrations in
migrations/directory - Automatic replication and backups
- Global edge deployment
- Binding:
env.DB
Queues
Message queue for background sync processing:- Producer binding:
env.SYNC_QUEUE - Consumer configuration:
max_batch_size = 1,max_batch_timeout = 5 - Queue name:
rearjackman-sync
Cron Triggers
Scheduled execution for automated syncs:- Schedule:
0 6 * * MON(Monday 6 AM UTC) - Checks for completed races and queues sync
- Implements smart logic to only sync latest rounds
Observability
Logging and monitoring:- Enabled in
wrangler.toml - Invocation logs for all requests
- Console logs for debugging
Performance considerations
The architecture is optimized for performance:- Edge deployment - CloudFlare Workers run close to users globally
- Minimal JavaScript - Only 30 lines of client-side JS for collapsible sections
- Database indexes - Indexes on
season,round, andrace_id - Batch operations - Database writes use
db.batch()for efficiency - Collapsible UI - Large tables show only top 5 by default
Security
- Sync endpoint protection - Requires
SYNC_SECRETenvironment variable - No user authentication - App is read-only for end users
- Rate limiting - Respects Jolpica API rate limits with exponential backoff
- Input validation - Season and round parameters are validated
Future enhancements
From the README’s TODO list:- Circuit map display on race pages
- Incremental sync (only sync new rounds)
- Resumable sync for large season imports
- RSS news feeds with LLM filtering
- “Interesting Facts” section with AI-generated summaries
Next steps
Database schema
Explore the complete database structure
Data sync
Deep dive into the sync implementation
Rendering
Learn about the UI rendering system
Deploy to CloudFlare
Deploy your own instance