How we built a multiplayer card game in 1 week

Thomas Recouvreux
May 9 · 4 min read

We recently launched Koala & Wine, a fun card game to play online with friends, available here. After the launch we got many questions about the technologies we used to build the platform, so we decided to share how it works.

The stack

We wanted to innovate and try something a bit different from what we are used to. Since this is a little project, we wanted as well something fast to develop with, cheap and with little maintenance. So we built the application based on Firestore, a real-time database, and Serverless Framework on AWS Lambda using Java. The frontend is a SPA built with Angular 9.

Firestore, the real-time beast

When we think of an online multiplayer game, our first question was how to interact with the different browsers of the clients. After evaluating multiple options, we ended going for Google Firestore, a very easy to use real-time database, with built-in authorizations and permissions.

Sure we could have gone for WebSocket or WebRTC, but this requires you to design, build, and host your architecture, which is not that easy. Firebase uses WebSockets internally and manages the whole architecture for you.

We hesitated as well for AWS AppSync, which is very similar to Google Firestore. But we found it harder to bootstrap, and since this is a newer project, the tooling and eco-system were smaller.

With Firestore, we can create an object in the database representing our game state, and the browsers can subscribe to this object and receive updates in real-time when modifications occur. This requires almost zero code using the SDK.

We still needed a backend to handle the business logic of the game. For this we used the Serverless Framework.

Serverless Framework, the no brainer backend

When you play a game, you sure not want to play a rigged game with cheaters. We wanted Koala & Wine to be a fair game you can play to have fun, so we needed a backend to handle all the user inputs and game logic.

We used the Serverless Framework since we already used it in the past. This framework allows you to easily build an API and deploy it on a serverless cloud provider like AWS Lambda or Google cloud functions.

A good point about serverless architecture, is that you don’t have to worry about servers, no need setup, and monitor one, this is done by the cloud provider.

Another good point, is that it’s incredibly cheap. AWS Lambda is pay-as-you-go, you pay based on the run time of your functions. Nobody was on your platform for the last 8 hours? Then no charges. Have a huge load after dinner? Fine, let’s pay a few cents per million of requests.

One of the biggest caveats, in my opinion, for serverless applications is that you need to upload your code to run it. During development this becomes very time consuming, so we used the plugin built by Bytekast to run our code locally during development.

Many languages are supported by the Serverless Framework, we used Java since my friend is more familiar with it. The support is very good and we did not notice any differences with the other supported languages like Javascript or Python.

Angular 9, the king of the kings

A game requires a lot of interactions from the user, dynamic content, animations, etc. We found it Angular to be a good candidate to help us in this matter.

At the end of the day, Angular was great to build the platform, user auth, game creation, etc. But for the game display itself, this was a bit short. Mainly Angular animations were very hard to understand and use.

If we had to build a new game, we would probably keep Angular for the platform, but embed something like Phaser for the game itself. We could have used React instead of Angular, no big deal, they are both as good as each other when it comes to productivity.

Conclusion

At the end of the day it took us, two developers, five days to develop and deploy our online multiplayer card game.

All of these techs are battery-included, they can handle a lot of things by themselves without the need for the developer to use too much brain-power re-inventing the wheel.

We already knew and used these techs in the past. Obviously if someone starts fresh with them it will take some time to understand and use them effectively. But once learned, they can help you shipping your projects fast.

Side note about the platform: it’s 100% serverless, not that it matters, but we are ready to handle thousands of concurrent players with the same architecture we have today. The elasticity provided by serverless architectures is one of their biggest strength.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store