MLB Quick Recap: Making Baseball Accessible Globally 🌎

Introduction

As part of the "Google Cloud x MLB™ Hackathon – Building with Gemini Models" hackathon, I developed MLB Quick Recap, a web app that makes baseball digestible for everyone - yes, even for those who think baseball is just people standing around for 3 hours (spoiler alert: it's actually pretty interesting! 😅).

From "What's Baseball?" to "Oh, That's Baseball!" 🤔

Growing up in places where baseball was as foreign as pineapple on pizza is controversial, my only connection to the sport was thinking the ball looked cool (I know, I know... 🤦‍♂️). But through this project, I've actually started understanding why people spend hours watching this sport. While I'm not exactly ready to paint my face with team colors, I might actually watch a game or two now!

The Tech Stuff (Warning: Nerd Alert! 🤓)

Frontend Magic ✨

The frontend (check it out here) is built with React, Vite, and TypeScript - because apparently, regular JavaScript wasn't complicated enough! 😉 I used Tailwind CSS and shadcn components to make everything look pretty (and save myself from the CSS nightmare we all know and love).

A unique feature of the application is its multilingual game summaries, currently supporting English, Spanish, and Japanese, allowing users to switch between languages seamlessly.

Backend Wizardry 🧙‍♂️

The backend (peek here if you're curious) is powered by FastAPI. Let's just say the MLB Stats API and I had some... interesting conversations. Thank goodness for AI helping me decipher the documentation - they're like the tech equivalent of a baseball translator!

Making It Fast (Because Nobody Likes Waiting) ⚡

Initially, the app was so slow you could probably watch half an inning before getting your results (1.8 minutes - yikes!). Now? around 20 seconds! Here's what I did:

  • Threw some async magic at it (asyncio.gather())
  • Added Redis caching (because hitting APIs repeatedly is so 2010)
  • Optimized batch processing with fine-tuned batch sizes

Gemini: The MVP 🏆

After testing various models (and drinking way too much coffee), I settled on gemini-pro. Why? It's like the cleanup hitter of language models - reliable, powerful, and gets the job done.

  • Higher token limits (32k) enabling efficient batch processing
  • Consistent, high-quality summary generation
  • Better context understanding compared to flash models

Cloud Adventures ☁️

Google Cloud Platform turned out to be surprisingly friendly (who knew?). Deploying to Cloud Run was so easy, I thought I was doing something wrong! The Redis setup was particularly impressive - enable an API, add a few lines to the Docker file, and boom! The seamless integration of various Google services through a single console was a revelation that will definitely influence my future project decisions.

Challenges (AKA "Fun" Problems to Solve) 🎯

API Integration Challenges

  • Initially struggled with understanding MLB's API structure
  • Overcame through strategic use of LLMs for documentation comprehension
  • Implemented efficient error handling and rate limiting ### Performance Optimization
  • Addressed initial slow response times through concurrent processing
  • Implemented sophisticated caching strategies
  • Balanced API rate limits with parallel processing requirements ### Technical Decisions
  • Carefully selected Gemini model based on performance requirements
  • Implemented Redis caching with strategic key design and expiration policies
  • Developed robust error handling for API integrations

What's Next? 🚀

There's still plenty to do (because apparently, sleep is overrated):

  • Make the whole site multilingual
  • Add more stats (for the real baseball nerds out there)
  • Make it even faster (because 20 seconds is basically an eternity in internet time)
  • Add more languages (maybe even Klingon? 👽)

The Knowledge Gains 📚

This project has been transformative in several ways:

  • Deepened understanding of cloud-native development
  • Gained practical experience with modern web technologies
  • Developed expertise in API optimization and caching strategies
  • Learned about baseball and sports data management
  • Enhanced skills in full-stack development

Thank You Note 🙏

Huge thanks to the hackathon organizers and sponsors! You not only helped me level up my tech game but also got me interested in a sport I previously thought was just fancy catch. Who would've thought? 😄


P.S. No baseballs were harmed in the making of this application. The same cannot be said for my sleep schedule. 😴

Built With

Share this project:

Updates