
Cloud for developers: Achievement system designer BadgeKeeper - a service for developers
We continue to talk about the use of the Microsoft cloud for solution development companies (ISVs). In this issue, we present the story of Badge Keeper , which creates the designer of the achievement system. Please leave your feedback in the comments.
Hello everyone, in this post I want to tell you how we wanted to add the achievement system to our application, and instead made a separate service. What are “achievements” or “achievements”, what are they used in applications for, I think, there’s no need to tell so I’ll go straight to the story about the service and how we implemented its cloud version in Azure.
Where did the idea come from
It all started with the fact that we needed to add the mechanics of obtaining achievements to our application. The application was developed by only one person in his spare time, there were many development tasks, as is usually the case. I did not want to be distracted by adding achievements for two reasons: lack of time due to higher priority tasks and a lack of understanding of how much achievements will be claimed by users. The last doubt was because the application was not a game where everyone was usually used to seeing achievements, but a “serious” application for maintaining a family budget. I also did not want to devote too much time to the support of mechanics after its implementation and force users to update the application every time something changes in the conditions of receiving an achievement or a new achievement is added.
The search for ready-made solutions
Thoughts flowed towards the removal of the logic of achievements from the application to a separate module or service. After some thought, I wanted to see what ready-made solutions exist as a service. The search resulted in the following list (maybe the search was not ideal and I will be glad to receive information about other similar services):
- Google Achievements . It can be used for the application, even if it is not published on Google Play. What confused: a) Sharpening the achievements for the game, even when starting the application they are asked to indicate the "name of the game" and "category of the game." If a financial application is called a game, then the category is suitable only for “adventures” b) By the principle of using achievements, I didn’t like the moment that you need to operate the achievement ID everywhere, which is not always convenient. C) When you first sign up for Google Play and pay for a developer account, There was an incomprehensible problem with making a payment, which the support service resolved within a few days, which also played a role in continuing the search.
- Achievements Apple's . Inability to use on platforms other than iOS SDK. This moment was important because I planned to release a web interface to my application, and then it would be necessary to duplicate the logic of achievements manually.
- Steam achievements . Available for games published on Steam.
- Sony trophies . Available for games published on the Sony Playstation Store
- The Hydra . The service was interested in describing the available functionality, but is currently in a closed beta and could not be watched.
- App 24 . The service came up to the description, but the achievements were not its main functionality. Other services unnecessary to us were also provided, the interface is rather overloaded.
I also wanted to get some statistics on the use of the application at precisely those points on which the delivery of achievements was supposed to be put. This is an important point in implementing the achievement system.
We don’t want to do it ourselves, we want a service
As you probably already guessed, the desire to implement the mechanics of achievements in your project was combined with the desire of any normal developer to make your service. The main requirements were formulated:
- Platform independent. No matter what you design on - achievements connect the same way. You only need to use the ready-made SDK or work directly through the REST API;
- It does not depend on the type of application. It does not matter what you create - a game or some other application in which achievements will help organize the gamification of the process;
- The application should connect quickly, without having to re-read long pages of documentation;
- Easy to use. Adding new achievements should be as simple as possible and the application code should be as less dependent on the service.
Prototype in 2 months
In two months of free time, we managed to put together a working service and a demo site with several features.
- Creation of projects and achievements available in it ;
- Tracking events occurring in the application and determining the moment when it is necessary to issue an achievement. All logic is in the service and is determined by a simple condition. An application just needs to pass the updated value of the variable to the service. An example with pictures is below;
- The issuance of bonus points upon receipt of an achievement . The application independently decides what to do with the received bonuses. The service only knows how many and what bonuses to give out if a specific achievement happened;
- Sandbox mode . This functionality suggests itself, it is very convenient to first test how difficult the achievement will be, changing the conditions for its receipt and only then publish the project. After publication, changing the conditions of achievement is impossible.
It is worth noting that at the moment the service does not shine with ergonomics and design, since we devoted all our time to developing the internals, after which we decided to write this review in order to get feedback from our colleagues.
How the service is arranged
Now a few words about how we built the service.
They decided to develop a solution in the cloud. The choice fell in the direction of Microsoft Azure, and here's why:
- One solution working in Azure has already been successfully developed; accordingly, there was experience;
- We did not want to be distracted by administration; accordingly, taking PAAS was the best solution;
- Microsoft has a wonderful BizSpark program that provides both licensed software and some money for Microsoft Azure.
As for the architecture, we take into account that the service requires high performance, but to build a prototype we decided to limit ourselves to a basic solution that does not use a common cache (which, of course, will be done).
Total, you must:
- Backend running on the Asp.Net Web API;
- Azure WebJob, paired with Backend;
- Frontend running on Asp.Net MVC + AngularJS;
- SQL Database, for storing basic information about clients, as well as for providing statistics to users;
- Azure Table storage, for fast operations of data recording and selection (more on that below);
- Azure Queue storage, for deferred recording of analytic data by users.
And here’s the general outline in action:

Now a few words about why we started using Azure Storage (Table & Queue). First, we used SQL Database to write and read data. But after the stress tests we decided to see other solutions. The fact is that Azure SQL is limited by DTU (Database Throughput Unit), which was a critical moment for us. Azure Storage has completely different performance metrics for inserting and reading data. For this, of course, I had to think very well about the Partition Key & Row Key, however, after switching to Azure Storage, the results became much better.
Azure Queue Storage is used for the task of collecting and providing analytics. In our service, we plan to pay special attention to this issue and give customers the opportunity to receive such reports as “percentage of users with open / closed achievements”, “speed of achievement achievement”, “number of attempts to open achievement” and other useful statistics. Such reporting will allow you to check the specified conditions for obtaining achievements on the subject of their complexity and make corrections before exiting in combat mode. Alternatively, all this could also be added to the Azure Table, but building flexible queries is very problematic. Therefore, in Web Job, we catch the moment when data is being recorded in Azure Table storage and we add to the queue a task for writing data to SQL Database. Now we do not create additional delays for working in the main service, and the user receives the same statistics almost in real time. A small delay, of course, may be, depending on when the job will react, but this happens almost instantly, and there is no need to give the analyst in real time.
How the service works on the part of the client
For each achievement, you must set the condition for its receipt. We built the service so that the condition can be specified in the form of a formula, for example, scores > = 150 . Scores is what the POST application sends the request. The request also comes with a unique client key (application user). When we receive a request from the application, we check the value of the scores variable for this client, and if it is greater than the value specified in the condition of any achievement (one or more), the service will return a response about the achievement. More complex conditions can also be specified, such as:
level 5_ kills = 25 and level = 5 and( health > = 90 and health <= 100)
In this case, the achievement will open as soon as all the conditions in the formula are met. The values themselves can be sent in a bundle in one request, or you can send one at a time. In any case, the previously sent values of the variables are checked.
To ensure the security of data transfer and prevent possible falsification of data, we are working on the implementation of HMAC authentication.
What it looks like
When you enter the system there will be a list of “projects”. For each application connected to the service, you must create your own project.

This is how the project looks from the inside. In each project, you can create a set of achievements with your own conditions for obtaining.

And here is what one achievement looks like in edit mode.

On the demo page you can see how it works on the demo project. To do this, we took the game "Snake" in JavaScript and connected it to the service.
What about those who are not involved in game development?
Although this article discusses an example of use in the context of developing video games, it is worth noting that we see the use of the service in other areas. Here are just a few areas where our product can be successfully used:
Video games
Create an achievement system and use it in your projects on any device. Your customers can start using the iPhone application and continue on the iPad version while maintaining their open achievements.
Online Stores
Want to add “gamification” to better retain customers? Thinking about the opportunity to accrue bonus points to your customers? This is possible if your online store solution is integrated with the service.
Publishers
Planning to Create Another Kongregate.com Killer? Connect your platform to Badge Keeper and provide your customers with built-in tools to create a cross-platform achievement system.
Conclusion
Despite the availability of ready-made solutions, especially from giants such as Apple and Google, we believe that this service has the right to life due to more simple use, less connection of the business logic of achievements with your application, as well as advanced capabilities of the achievements themselves.
After this short stage of development, a list of "Wishlist" that we would like to see in the service. We are sure that we will find something to offer other teams, which also, like us, do not want to spend their precious time on auxiliary mechanics and focus on developing the basic functionality of their application.
Before continuing with the development, I would like to get feedback and understand what may still be in demand, perhaps we did not take into account something in our work. We are open to requests for adding features if this does not contradict the main ideology of the service. If the service interests you, but you did not find the necessary functionality in the description, we will be glad to hear about it in the comments to the article or in the message on the feedback form. If you liked the idea of the service and you would be interested to follow the news of the project, then join us on Twitter to keep abreast of what is happening.
Thanks for attention! Any feedback, questions or comments will be greatly appreciated.