Arrange the pieces of the world! You need to drag the shape of the territory to the right place. Just like in childhood we collected pictures piece by piece, so here you can collect a country from regions or whole continents from countries!
Furthermore second variation is the Quiz. In the Quiz you need find the country by flag, emblem or the capital.
This is just web application, so you need:
- nginx (as balancer)
- wsgi (gunicorn, for example)
- asgi (daphne, for example)
- supervisor (or run apps in docker compose)
- python >= 3.11 (with pdm)
- redis >= 5.0
- postgres >= 12
- nodejs >= 20.8
This extensions must be installed:
- postgis
- postgis_topology
- postgis_sfcgal
- fuzzystrmatch
- address_standardizer
- postgis_tiger_geocoder
For example:
create user geopuzzle with password 'geopuzzle';
create database geopuzzle owner geopuzzle;
create extension postgis;
Necessary for build frontend. npm commands:
test
- run test locallytestci
- run test on CI/CDanalyze
- analyze builddev
- run dev serverbuild
- build static for production
I use pdm for manage dependencies and run commands. Install pdm-django plugin via pdm plugin add pdm-django
.
Run management commands like pdm manage runserver
- to run dev server.
cache
- update/import/export and recalculate polygon cache (from postgres to redis)clearcache
- clear django decorators cachedeploystatic
- upload static to S3fix_infobox_links
- update wiki if any link is not validupdate_geometry
- update polygon and wiki data from external source (OSM and Wikidata)validate_infoboxes
- check that all required data in all infoboxes is filled and correct
Nginx requires for traffic balancer:
/
to wsgi app/ws
to asgi app
Example configuration is placed in deploy
directory.
Games work via websockets, so you have to run both wsgi and asgi server for production:
- wsgi -
gunicorn mercator.wsgi:application -b 0.0.0.0:8000
- asgi -
daphne mercator.asgi:application -b 0.0.0.0 -p 8001
./manage.py runserver
starts both of them at the same time. This project is a django application so envs are common.
All envs are placed in .env_template
file. Most of them have a default value, so you can copy .env_template
to .env
for the first run.
Describe some special variables:
OSM_KEY
- load polygons from OpenStreetMapGOOGLE_KEY
- production key for Google Maps API (not required)DISABLE_GOOGLE_KEY
- temporary disableGOOGLE_KEY
(empty or "True")AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
- AWS uses to deploy static and CDNSOCIAL_VK_KEY
/SOCIAL_VK_SECRET
- enable VK authorizationSOCIAL_FACEBOOK_KEY
/SOCIAL_FACEBOOK_SECRET
- enable Facebook authorizationSOCIAL_GOOGLE_KEY
/SOCIAL_GOOGLE_SECRET
- enable Google authorization
I find excellent service for load geojson files with polygons - https://osm-boundaries.com/. Just select the country (or many or with regions) and click 'Export'. URL must be like:
https://osm-boundaries.com/Download/Submit?apiKey=74ba654a378b8daf80f&db=osm20210531&osmIds=-5682946,-5682950&format=GeoJSON&srid=4326
And download content by that link. You've got zip archive with GeoJson files, unpack them into geojson
folder.
After that you can run management command (venv)$ ./manage.py update_regions
for load polygons into database.
Take into account - data from OSM is not perfect and some regions can have bad or recursive links to each other.
In most cases, restarting can help :)
You can download sample database.
Unpack archive into pgdata
directory.
Project has 2 Dockerfiles:
- /Dockerfile.backend - for server side (django tests and deploy)
- /Dockerfile.frontend - for client side (webpack build bundles and jest tests)
All images should be up to date with all installed dependencies. This allows you to significantly reduce the time to perform tasks CI. Command for update image (backend, by example):
$ docker build --build-arg GIT_REVISION=$(git rev-parse --short HEAD) -t tyvik/geopuzzle:backend --target backend -f Dockerfile.backend .