Skip to main content

Top level navigation menu

A drawn image of Fredrik Bergqvist in a blue shirt

MAG Interactive: Leonardo API

About MAG Interactive

MAG Interactive, founded in 2010, is a Swedish mobile game developer and publisher specializing in casual social games for iOS and Android. With offices in Stockholm and Brighton, their portfolio has surpassed 350 million downloads, engaging more than 10 million monthly active players. Known for hits like Ruzzle, WordBrain, and QuizDuel, the company’s mission is to create games that are easy to learn but challenging to master, fostering social interaction and competition worldwide.

Background

Leonardo is a large internal application supporting player information, products, purchases, in-game offers, A/B testing, and server configuration. Originally, we extended it with API routes in Next.js, but over time the server features became increasingly unreliable outside Vercel hosting. I led the initiative to move the backend to a more scalable and maintainable solution.

Technology

I re-implemented the API in Go, using the Echo framework for routing. Firestore remained our database, which allowed us to migrate without disrupting data models. Go proved an excellent fit for performance and maintainability, especially for APIs with high traffic and strict latency requirements.

Best Practices

From the start, I established a set of engineering practices:

  • Swagger/OpenAPI for well-defined contracts, documentation, and code generation.
  • Consistent error handling with a standardized response format.
  • Correct HTTP status codes to improve client reliability and debuggability.

I later summarized these practices in a blog post.

Features

  • API documentation and stubs are generated with oapi-codegen.
  • The Leonardo frontend consumes the same Swagger file to auto-generate TypeScript types and React hooks, ensuring frontend-backend consistency.
  • Introduced memory caching to reduce Firestore lookups and speed up frequent requests.

Hosting and CI/CD

The service runs on Google Cloud Run, built and deployed via GitHub Actions. I set up an environment strategy matching our frontend:

  • develop branch → test server
  • main branch → production

This setup streamlined deployments and improved confidence in releases.

Impact

The migration delivered a backend that is faster, more reliable, and easier to extend. It reduced operational issues tied to Next.js server hosting, improved developer experience with generated types, and provided a clear, documented API surface for multiple teams to build on.

This site is built with Eleventy and hosted on Vercel.

Icons are from Flaticon.

Web components from Nidhugg Web components

Performance stats can be found here: Speedlify