/map-kit-backend

The backend service for the Map Kit, a service allowing Romanian diaspora communities to build their own POI map applications on the web

Primary LanguagePythonApache License 2.0Apache-2.0

The Romanian Diaspora Map Kit

This project is created by DCB and aims to facilitate the creation of community maps by and for Romanian diaspora communities across the globe.

The Map Kit allows members of these communities to create their own map based application to manage and share POIs around a certain region. Its goal is to provide clear information on places of interest and services in demand among the Romanian diaspora in the city and its surroundings.

Requirements

Install

  1. Clone the repo
  2. Create Docker containers
docker compose up

Run

Endpoints are reachable on port 8000.

Configure Django

Superuser

Will be injected per script with the following info:

user: god password: god email: god@dcb.berlin

Log into the admin panel with those credentials.

Create working user

When you create a new username (google login, Auth0), make sure you set it to 'approved' in Django's admin section, otherwise none of the api endpoints that require a jwt token (i.e. /my-communities/*) will work.

Populate Database

Run

docker exec -t map-kit-api python src/manage.py loaddata src/locations/fixtures/*

Authentication

We use token based auth and authenticate users with OIDC via Auth0.

The backend just uses tokens that it receives, it does not do anything else (issuing, refreshing tokens etc.). The frontend will have to prompt the user to start the social login flow via Auth0, get a token, and then use that token in any subsequent requests to the backend.

We use Auth0 because it makes managing multiple authentication providers (Google, Facebook etc.) much easier. We can add new ones or remove one without touching the application configuration.

Set-up

  1. Adjust Auth0 variables (prefixed OIDC_) in .env.
  2. Use an exising Mapbox token or create a new one, and add it as MAPBOX_TOKEN to .env.
  3. Build your containers again.

TODO

  • Expand this section.

Test

docker exec -it map-kit-api pytest src/tests/

You can still profit from full interactivity with the debugger in this testing setup, if needed.

Lint

docker exec -it map-kit-api black src

In the future we will add pre-commit hooks to simplify this.

Troubleshoot

Django User Conflict

Problem Admin and working user are the same.

Solution Remove the user and registering it again. The 2 users with the same email will be merged.