Build the Multi-player Game Frontend


This tutorial assumes you are familiar with react and redux.

You will need to have these installed:

Have the Games API service running on http://localhost:8100/ and the div-model service running on http://localhost:8080.


In a separate terminal, create a new virtualenv called ‘div-ui’:

$ mkvirtualenv div-ui

Install the cookiecutter Python package:

$ pip install cookiecutter

Use cookiecutter to create the boilerplate for your game Frontend.

$ cookiecutter

For the game_slug value, enter div (the slug value you used in the modelservice tutorial). For all other values, you can use the default or choose your own.

For example,

project_name [Simulation UI]: Div UI	
repo_slug [div-ui]: 
project_slug [div_ui]: 
game_slug [div-ui]: div
modelservice_slug [div-model]:      
topic_root [world.simpl]: 
app_slug [frontend]: 
version [0.1.0]: 

After the project layout is created, install the requirements:

$ cd div-ui
$ pip install -r requirements.txt

In a separate terminal, install the project’s JavaScript node modules and run gulp to keep the web server’s Javascript updated as you work on the frontend:

$ npm install
$ npm start

To aid development, you can install the following Chrome DevTools Extensions:

It is also recommended you configure your editor to integrate with ESLint:


Like most websites, the frontend service will need a place where it can store information about sessions and their users. The user’s specific information will be fetched from the Simple Games API and kept in sync automatically.

NOTE For the purposes of this tutorial we’re going to use SQLite, but this can be changed to match whatever database backend you prefer. In a production environment, you’ll likely want to switch to something like PostgreSQL.

First, let’s create the necessary local tables:

$ ./ migrate

Then, start your frontend service with:

$ ./ runserver

In Chrome, head to http://localhost:8000/ and login as [email protected] with password s1. Once you are logged in, you should see the ‘Hello Player’ message of the skeleton app. Open Chrome’s DevTools, and select the ‘Redux’ tab. You will see a list of actions, and the current state of the store. Note that the state has a property named simpl. Expand the simpl property to see all the scope properties associated with the current user.

These properties will be updated as the model service adds, removes or updates scopes. You will connect your components to the properties and they will update accordingly.

Logout by going to localhost:8000/logout/ in your browser. Then login as [email protected] with password leader. Once you are logged in, you should see the ‘Hello Leader’ message of the skeleton app. If you look at the simpl state properties, information about all the run’s worlds has been loaded.

In a multi-player simulation, players are assigned to a world with other players. The cookiecutter template assumes you are implementing a multi-player simulation in which players see only their world’s information. By default, leaders can see the worlds and users in their subscribed runs, but not the scenarios of other users. To accomplish this, the template js/modules/Root.js sets the simpl decorator’s loadAllScenarios argument false to block access to scenarios of other users.


To implement your UI, you will write Container Components and Presentational Components.

The Presentational Components will provide the necessary markup to render UI elements, while the Container Components will wrap them providing the necessary data.

First, you will Build the Multi-player Game Player UI.

Finally, you will Build the Multi-player Game Leader UI.

This concludes our tutorial! We have barely scratched the surface. A completed example implementation is available at that uses the game slug simpl-div.

There’s much more that you can do with Simpl. For more informations, check out the service-specific documentation.