Sports Analytics Platform

Comprehensive Sports Data & Content Management System

A full-stack sports platform featuring real-time data synchronization, AI-powered content generation, and comprehensive analytics built with modern web technologies and intelligent automation.

Project Overview

Challenge

Build a comprehensive sports platform that aggregates real-time data from multiple APIs, generates intelligent content automatically, and provides users with detailed analytics while maintaining high performance and SEO optimization.

Solution

Developed a monorepo architecture with Next.js frontend and Python AI backend, featuring automated content generation, real-time data synchronization, and intelligent editorial workflows using OpenAI Agents SDK.

System Architecture

Frontend (apps/web)

  • • Next.js 15 with App Router
  • • Server-side rendering (SSR)
  • • Auth.js authentication
  • • Slug-based URL system
  • • Comprehensive SEO optimization
  • • Unified search functionality
  • • Deployed on Vercel

Backend (apps/agents)

  • • Python with OpenAI Agents SDK
  • • Editorial workflow system
  • • Automated content generation
  • • Image sourcing from Wikimedia
  • • Scheduled task execution
  • • Railway deployment
  • • PostgreSQL database

Core Features

AI Editorial Workflow System

Advanced AI content generation system using OpenAI Agents SDK:

  • • Editor-in-Chief agent for task delegation
  • • Content Writer agent for article generation
  • • Image Editor agent for visual content
  • • Photo Researcher agent for player profiles
  • • Research Analyst agent for content strategy
  • • Content Coordinator for complex workflows

Editorial Workflow

Natural language prompts → Editor-in-Chief → Specialized agents → Content generation → Image sourcing → Database storage. Every piece of content gets unique, legally-compliant images.

Real-time Sports Data Synchronization

Comprehensive data integration from multiple sports APIs:

  • • API-Football integration for live scores
  • • Player statistics and career data
  • • Team information and standings
  • • Match fixtures and results
  • • League and tournament data
  • • RSS news feed aggregation

Data Pipeline

Scheduled synchronization jobs fetch data from external APIs, normalize into PostgreSQL schema, and trigger Supabase Edge Functions for additional processing and notifications.

Unified Search & Discovery

Comprehensive search functionality across all platform entities:

  • • Multi-entity search (players, teams, articles, matches)
  • • Debounced search with real-time results
  • • Categorized results with dedicated tabs
  • • URL parameters for shareable searches
  • • Case-insensitive pattern matching
  • • Paginated results for performance

Search Implementation

Uses Supabase's ilike operator for efficient searching across multiple fields per entity type, with dedicated API endpoint at /api/supabase/search returning categorized results.

Technical Implementation

Frontend Architecture

  • Next.js 15: App Router with async params handling
  • Slug URLs: SEO-friendly routing with fallback to IDs
  • Auth.js: Magic link authentication with Resend
  • Metadata API: Dynamic SEO with centralized helpers
  • JSON-LD: Structured data for search engines

Backend Systems

  • PostgreSQL: Primary database on Railway
  • Drizzle ORM: Type-safe database operations
  • Edge Functions: Supabase serverless functions
  • Cron Jobs: Scheduled data synchronization
  • API Routes: Next.js API endpoints for data sync

AI & Automation

  • OpenAI Agents SDK: Specialized editorial agents
  • Wikimedia API: Automated image sourcing
  • RSS Aggregation: News feed processing
  • Scheduled Tasks: Daily content generation
  • Attribution System: Legal compliance for images

Database & Content Architecture

Core Sports Data

  • Players: Comprehensive profiles with career statistics
  • Teams: Squad information, standings, and performance
  • Leagues: Competition structure and scheduling
  • Fixtures: Match data with events and timelines
  • Statistics: Season-by-season player/team metrics

Content Management

  • Generated Content: AI-created articles and summaries
  • Supplemental Images: Content and player photos
  • RSS Feeds: External news aggregation
  • User System: Authentication and preferences
  • Attribution Data: Legal compliance tracking

AI Agent Workflows

Daily Content Generation

Workflow

Scheduled task at 10:00 AM UTC sends prompt to Editor-in-Chief → Content Writer generates daily summary → Image Editor sources relevant image → Content saved to database with full attribution.

Features

Each summary gets unique Wikimedia Commons image, full legal attribution, and structured content storage with metadata for frontend display.

Player Profile Creation

Workflow

Content Coordinator → Content Writer creates profile → Photo Researcher finds player photo → Image Editor sources content image → Complete profile with multiple images stored.

Features

Automatic player photo sourcing, content image generation, and comprehensive attribution tracking for all visual assets.

Key Achievements

Platform Features

  • • Monorepo architecture with Next.js and Python services
  • • Automated content generation with unique image sourcing
  • • Real-time sports data synchronization
  • • Comprehensive search across multiple entity types
  • • SEO-optimized slug-based URL system
  • • Legal compliance with full image attribution

Technical Implementation

  • • OpenAI Agents SDK with specialized editorial workflow
  • • Server-side authentication with Auth.js and magic links
  • • Dynamic metadata generation for optimal SEO
  • • Scheduled task execution on Railway infrastructure
  • • Comprehensive testing with Playwright
  • • RSS feed aggregation and processing

Technical Challenges & Solutions

Content Attribution & Legal Compliance

Challenge

Ensuring all AI-generated content with automated image sourcing maintains proper attribution and legal compliance across thousands of assets.

Solution

Implemented comprehensive attribution system with dedicated database tables for tracking license information, source URLs, and attribution HTML for all images.

Next.js 15 Async Params

Challenge

Next.js 15.3.2+ with Turbopack requires awaiting params Promise in dynamic routes, breaking existing synchronous param access patterns.

Solution

Updated all dynamic route components to properly await params Promise before accessing route parameters, ensuring compatibility with latest Next.js.

AI Agent Orchestration

Challenge

Coordinating multiple AI agents for content creation while ensuring consistent quality and avoiding duplicate image usage across content.

Solution

Implemented OpenAI Agents SDK handoff patterns with specialized agents and unique image tracking to prevent duplication across content pieces.

Deployment & Infrastructure

Frontend Deployment

Next.js application on Vercel

  • • Automatic deployments from Git
  • • Environment variable management
  • • Preview deployments for testing
  • • Edge function optimization

Backend Infrastructure

Python services on Railway

  • • Continuous worker process
  • • PostgreSQL database hosting
  • • Scheduled task execution
  • • Environment configuration

Monitoring & Quality

Comprehensive testing and monitoring

  • • Playwright end-to-end testing
  • • Status reporting system
  • • Error handling and logging
  • • Performance monitoring