Complete Platform Guide
Full-Context Overview: Everything you need to know about the AltSportsLeagues.ai platform in one place.
Platform Overview
AltSportsLeagues.ai is a comprehensive sports league data platform combining business intelligence, MCP (Model Context Protocol) integration, and modern web technologies to deliver a complete ecosystem for sports data management and analysis.
Core Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Production Infrastructure β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. altsportsleagues.ai (Frontend - Vercel) β
β ββ Next.js 16 application β
β ββ User dashboard & league search β
β ββ Graph visualization β
β ββ /api/v1/* β api.altsportsleagues.ai/v1/* β
β β
β 2. api.altsportsleagues.ai (Backend - Cloud Run) β
β ββ FastAPI + Python 3.11 β
β ββ MCP server implementations β
β ββ AI agents & processing β
β ββ Clean URL pattern: /v1/* (no redundant /api/) β
β β
β 3. docs.altsportsleagues.ai (Docs - Vercel) β
β ββ Nextra 4 + Next.js 16 β
β ββ Interactive schema explorer β
β ββ Real-time schema injection β
β β
β 4. n8n.altsportsleagues.ai (Automation - Self-Hosted) β
β ββ n8n workflow automation β
β ββ League onboarding workflows β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββKey Components
1. Backend Services (apps/backend/)
- Platform: Google Cloud Run (containerized with Docker)
- URL:
https://api.altsportsleagues.ai - URL Pattern:
/v1/*(clean, industry-standard) - Technology: FastAPI + Python 3.11, FastMCP, Uvicorn
- Features:
- RESTful API endpoints
- MCP server implementations
- AI-powered analysis
- Real-time processing
2. Frontend Application (clients/frontend/)
- Platform: Vercel (edge network)
- URL:
https://altsportsleagues.ai - Technology: Next.js 16, React 18.2, TypeScript
- Features:
- League discovery and search
- Graph visualization (D3.js)
- Firebase authentication
- Responsive design
- Dark mode support
3. Documentation Site (clients/docs-site/)
- Platform: Vercel (separate deployment)
- URL:
https://docs.altsportsleagues.ai - Technology: Next.js 16 + Nextra 4
- Features:
- 150+ schema documentation
- Interactive schema explorer
- Auto-generated API docs
- Real-time schema injection
- Full-text search
4. Data Layer (data_layer/)
- Purpose: Unified data management
- Components:
- Schema definitions
- Data generators
- Utilities (Python, TypeScript, Neo4j)
- Triple index system
- Prompt retrieval system
5. n8n Automation (n8n_workflows/)
- Platform: Self-hosted n8n
- URL:
https://n8n.altsportsleagues.ai - Features:
- Gmail email processing
- League onboarding workflows
- Calendar integration
- Contact management
- Automated content creation
Data Flow & Processing
League Onboarding Pipeline
New League Discovery
β
Gmail Processing (n8n)
β
Document Extraction (Python + AI)
β
Data Validation & Normalization
β
Storage (Neo4j + Supabase + Firebase)
β
Graph Indexing
β
Available for Query & AnalysisDatabase Architecture
- Neo4j: Graph relationships (leagues, teams, players)
- Supabase: Relational data (PostgreSQL)
- Firebase: Authentication & real-time updates
- ChromaDB: Local embeddings (documentation search)
URL Strategy & Routing
Clean Backend URLs (Industry Standard)
β Correct Pattern:
api.altsportsleagues.ai/v1/leagues
api.altsportsleagues.ai/v1/teams
api.altsportsleagues.ai/v1/playersβ Avoid Redundancy:
# Don't do this:
api.altsportsleagues.ai/api/v1/leagues β Redundant "api"Frontend Proxy Pattern
// Frontend makes same-origin calls
const response = await fetch('/api/v1/leagues');
// Vercel rewrites to backend
// altsportsleagues.ai/api/v1/leagues
// β
// api.altsportsleagues.ai/v1/leaguesBenefits:
- β No CORS issues (same origin)
- β Clean, non-redundant URLs
- β SEO optimized
- β Industry standard pattern
Deployment Architecture
Production Deployment Flow
-
Backend to Cloud Run
cd apps/backend ./deploy-to-cloud-run.sh # 4-8 minutes deployment time -
Frontend to Vercel
cd clients/frontend vercel --prod # 2-5 minutes deployment time -
Docs to Vercel
cd clients/docs-site vercel --prod # 3-5 minutes deployment time
Local Development
# Backend (Docker sandbox)
cd apps/backend
./deploy-local-docker.sh # Port 8090
# Frontend
cd clients/frontend
npm run dev # Port 3031
# Docs
cd clients/docs-site
npm run dev # Port 3001MCP Integration
Available MCP Servers
-
n8n-mcp (Production)
- Endpoint:
https://altsportsdata.app.n8n.cloud - 525+ nodes, 263 AI-ready tools
- Workflow management
- Endpoint:
-
league-discovery-cross-comparison
- League discovery and analysis
- Cross-league comparison
- Supabase integration
-
atlassian (Jira & Confluence)
- Project management
- Issue tracking
- Documentation integration
-
Google Workspace
- Gmail, Calendar, Drive, Sheets
- Automated workflows
MCP Usage Patterns
# Example: Using MCP for league analysis
from fastmcp import FastMCP
mcp = FastMCP("league-analysis")
@mcp.tool()
def analyze_league(league_id: str) -> dict:
"""Analyze league data and return insights"""
# Implementation
passBusiness Intelligence
4-Stage Partnership Pipeline
-
Document Intelligence
- AI-powered document processing
- OCR and structured extraction
- Quality scoring
-
Partnership Scoring
- Automated evaluation
- AI analysis
- Risk assessment
-
League Analysis
- Market intelligence
- Opportunity identification
- Competitive analysis
-
Email Intelligence
- Gmail integration
- AI-powered classification
- Automated routing
API Endpoint Structure
api.altsportsleagues.ai/
ββ / # API info & version
ββ /health # Health check
ββ /docs # Swagger UI
ββ /openapi.json # OpenAPI 3.0 spec
ββ /v1/* # Version 1 API
ββ /leagues # League operations
ββ /teams # Team operations
ββ /players # Player operations
ββ /stats # Statistics
ββ /markets # Market data
ββ /predictions # AI predictions
ββ /rag # RAG queriesDevelopment Workflow
Frontend Development
-
Component Development
cd clients/frontend npm run dev # Components in: app/components/ -
State Management
- Zustand stores in
store/ - React Query for data fetching
- Zustand stores in
-
Styling
- Tailwind CSS
- shadcn/ui components
Backend Development
-
API Development
cd apps/backend uv run uvicorn server:app --reload -
MCP Server Development
# Location: apps/backend/mcp_servers/servers/ from fastmcp import FastMCP mcp = FastMCP("my-server") # Add tools and resources -
Testing
pytest tests/
Testing Strategy
E2E Testing (Frontend)
cd clients/frontend
npm run test:e2e # Playwright testsBackend Testing
cd apps/backend
pytest tests/Integration Testing
- n8n workflow testing
- MCP tool validation
- Database connectivity tests
Monitoring & Observability
Cloud Run Logs
gcloud run services logs tail altsportsleagues-backend \
--region us-central1Vercel Logs
vercel logsHealth Checks
- Backend:
https://api.altsportsleagues.ai/health - Frontend:
https://altsportsleagues.ai/ - Docs:
https://docs.altsportsleagues.ai/
Security
Authentication
- Firebase Authentication
- Google Sign-In
- JWT tokens
Authorization
- Role-based access control (RBAC)
- API key management
- Rate limiting
Data Protection
- HTTPS everywhere
- Environment variable encryption
- Secure credential storage
Performance Optimization
Frontend
- Next.js App Router for optimal routing
- Image optimization
- Code splitting
- Edge caching (Vercel)
Backend
- Async Python (uvloop)
- Connection pooling
- Query optimization
- Caching strategy
Database
- Neo4j query optimization
- Supabase connection pooling
- Firebase real-time optimizations
Troubleshooting
Common Issues
-
CORS Errors
- Use frontend proxy pattern
- Check vercel.json rewrites
-
Deployment Failures
- Check Cloud Run logs
- Verify environment variables
- Test Docker build locally
-
API Connection Issues
- Verify backend URL
- Check authentication
- Test health endpoints
Debug Tools
# Backend health
curl https://api.altsportsleagues.ai/health
# Test local Docker
cd apps/backend
./test-local-deployment.sh
# Check Vercel deployment
vercel inspect [deployment-url]Next Steps
- Getting Started Guide - Quick start for new developers
- API Reference - Complete API documentation
- Frontend Guide - Frontend development
- Integration Playbook - Integration patterns
- Developer Handbook - Development best practices
Resources
- Repository: GitHub (contact for access)
- Documentation: https://docs.altsportsleagues.ai (opens in a new tab)
- API Docs: https://api.altsportsleagues.ai/docs (opens in a new tab)
- Support: Contact team for assistance
Last Updated: November 2024 Version: 2.1.0