Inspiration
As a lifelong NBA fan, I've always wondered "what if" - What if the Warriors kept Kevin Durant? What if Miami had better rebounding against Boston? These hypothetical trades fascinate fans but require deep knowledge of salary caps, player stats, and team chemistry. I wanted to improve existing tools to perform NBA trade analysis by building an AI-powered system that could instantly evaluate any trade scenario with the expertise of a professional GM, grounded in real 2023-24 playoff data.
What it does
NBA Trade Consigliere is an AI-powered webapp that transforms natural language questions into expert NBA trade analysis. Users can ask questions like "What if Dallas traded Luka for Jayson Tatum?" and receive comprehensive analysis covering:
Trade Feasibility: Complete CBA compliance checking with salary cap, luxury tax, and apron restrictions Team Impact: How the trade affects each team's roster composition, strengths, and weaknesses
Player Analysis: Statistical comparisons and fit analysis within new team systems
Legality: Would this work considering salaries of teams and players under the current CBA
The AI acts as your personal NBA GM advisor, providing instant expertise on any hypothetical trade scenario.
How I built it
I architected a microservices solution on Google Cloud Run with three core components:
Frontend: React + TypeScript with Material-UI, featuring an intuitive chat interface that makes complex NBA analysis accessible to any fan.
AI Engine: Node.js + Express backend powered by Google Gemini 2.5 Flash.
My custom 3-step AI pipeline:
Query Classification - Parse natural language to identify player/team/trade intent Data Retrieval - Query MongoDB through my MCP server for relevant NBA data AI Analysis - Inject real data into dynamic prompts, ensuring fact-based responses Data Layer: MongoDB Atlas with complete 2023-24 season data (213 players, 99.5% salary coverage) optimized with 15 strategic indexes for sub-100ms queries. I used a custom MongoDB Controller Protocol (MCP) for seamless database integration. Infrastructure: Docker containerization with health checks, Google Secret Manager for security, and auto-scaling Cloud Run deployment supporting thousands of concurrent trade analyses.
Challenges I ran into
Gathering Data: Since I wanted to look only at the 2023-2024 playoff range APIs and Kaggle were a bit restrictive. Using the Gemini Pro research model with google search grounding I was able to make custom JSON documents for use in my MongoDB collection, and even build a pretty tight and optimized schema.
AI Hallucination Prevention: My biggest challenge was ensuring the AI never invented fake stats or trades. I solved this by building a data-grounded architecture where every AI response is backed by real MongoDB queries - no hallucinations, only facts.
Complex CBA Rules: Implementing NBA salary cap compliance was incredibly complex, with luxury tax thresholds, trade exceptions, and apron restrictions. I built a comprehensive rule engine that validates every trade scenario for legal compliance.
Performance at Scale: With 213 players and complex statistical queries, I needed sub-100ms response times. I optimized MongoDB with 15 strategic indexes and implemented efficient caching strategies. Microservices Orchestration: Coordinating three services (React client, AI server, MCP server) across Docker containers and Cloud Run required careful network configuration and health check implementation.
Natural Language Understanding: Teaching the AI agent to distinguish between "show me Lakers trades" vs "what if Lakers traded LeBron" required sophisticated query classification and context management.
Accomplishments that I'm proud of
Zero-Hallucination AI: Built an AI system that never invents fake data - every response is grounded in real NBA statistics and salary information, custom to a playoff range (when NBA games tend to be most competitive).
Lightning Performance: Achieved sub-100ms database queries across 213 players with 15 optimized MongoDB indexes, making complex trade analysis feel instant.
Complete NBA Accuracy: Implemented the full 2023 NBA Collective Bargaining Agreement with salary cap, luxury tax, and apron restrictions - every trade suggestion is legally compliant.
Production Architecture: Deployed a professional microservices system on Google Cloud Run with auto-scaling, health monitoring, and zero-downtime deployments.
Comprehensive Data: Curated complete 2023-24 season data with 99.5% salary coverage, enabling analysis of virtually any trade scenario.
Intuitive UX: Created a natural language interface that makes complex NBA analysis accessible to casual fans while providing GM-level insights.
What I learned
Custom API Design: Building my own MCP server to abstract database complexity from AI logic, learning the importance of separation of concerns in microservices architecture.
AI + Real Data = Magic: I discovered that combining large language models with structured, real-time data creates incredibly powerful applications. The key is preventing hallucinations through data-grounded prompts.
MongoDB Performance Optimization: Learned advanced indexing strategies that reduced query times from 2+ seconds to under 100ms. Strategic compound indexes on player names, salaries, and team combinations were game-changers.
Microservices Complexity: Building distributed systems taught us the importance of health checks, proper error handling, and service communication patterns. Docker networking and Cloud Run orchestration became second nature.
Sports Data Challenges: NBA data is surprisingly complex - salary cap rules, trade exceptions, and CBA compliance require deep domain knowledge and careful validation logic. Utilizing Google pro models to do research and make this data usable in our schema was a big win over costly APIs or Kaggle data.
Natural Language Processing: Learned that effective AI applications require sophisticated query classification and context management, not just raw LLM power.
What's next for NBA Trade Consigliere
🔮 Multi-Player Trades: Expand beyond 1-for-1 trades to complex 3-team, multi-player scenarios with draft picks and trade exceptions.
📈 Historical Analysis: Add "time machine" functionality to analyze trades from any NBA season, not just 2023-24.
🏆 Fantasy Integration: Connect with fantasy basketball platforms to analyze how trades affect fantasy team performance.
📊 Advanced Analytics: Integrate advanced metrics like PER, VORP, and BPM for even deeper statistical analysis.
🎯 Team-Specific Insights: Personalized dashboards for each NBA team with tailored trade recommendations and roster optimization.ccomplishments that I'm proud of

Log in or sign up for Devpost to join the conversation.