How we've build mobile app with Deform

Sometime it happens

Sometimes it happens when you had a long hard day. In the end of this day some useful thoughts can emerge from your overdrained brain.

(҂⌣̀_⌣́)

A few months ago my brother got an idea about mobile app which counts steps better than others.

This App is related to World of Warcraft. Because I play WoW.

The Problem

Playing games takes a lot of time without active movement. Our bodies are the laziest organisms on the Earth. Body built to save energy for unexpected situations. If it has a choice to waste or keep the energy - it always will keep it.

In normal circumstances human body should walk 10 000 Steps per day. Average WoW player like me does ~4000-4500 steps every day.

That means: app must have a leaderboard. Leaderboards makes people to participate contests. Leaderboards with Prizes does it better.

So, if a man wants to win a prize he must walk... a lot.

Now we have a problem with tools to achieve the target - Leaderboard

Requirements

The leaderboard should use:

  • simple storage
  • query language
  • access tokens
How did Deform help?

We decided to use a Deform as a backend for this app. The reasons are:

More details

I have a Python script which syncs initial data using python-deform client.

Initialize python-deform

from pydeform import Client  
deform = Client(  
    host='deform.io'
).auth(
    'token', 
    'MYTOKEN', 
    project_id='MYPROJECT'
)

Create a collection to store rewards documents.

deform.collection.save(  
    data={
        "_id": "rewards",
        "name": "Rewards",
        "schema": {
            "title": "Rewards schema",
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "required": True
                },
                "icon": {
                    "type": "file",
                    "required": True
                },
                "link": {
                    "type": "string",
                    "required": True,
                    "format": "uri"
                },
                "description": {
                    "type": "string",
                    "required": True
                },
                "heading": {
                    "type": "string",
                    "required": True
                }
            }
        }
    }
)

Save the document

resp = deform.document.save(  
    collection='rewards',
    data={
        "name": "Brightpaw",
        "link": "https://us.battle.net/shop/en/product/world-of-warcraft-pet-brightpaw",
        "icon": open("images/brightpaw.jpg", 'rb'),
        "description": "This radiant kitty has so much extra energy ...",
        "heading": "The purr-fect companion"
    }
)

Yes, you can attach files to your documents

Now we can select a document using a query

documents = deform.documents.find(  
    collection='rewards',
    filter='{"name":{$in:{"Brightpaw","Argi"}}}'
)

This is an example of selection using simple mongo like query.

What's now?

You should try to create a project. Use these tools:

  • python-deform - python client
  • cli-deform - bash client. In case if you want to see what's going on in your project without script creation.

This will be easy :D