Core WolfBeacon API powering the Mobile and Dashboard apps
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

WolfBeacon Core API

WolfBeacon's Core API for Mobile and Analytics.

Written in Python 3, powered by Django, Django Rest Framework, PostgreSQL.

API Usage and Documentation

API Documentation:

Documentation is to be used with the WolfBeacon Core API Integration Guide which describes various crucial flows like Login, Signup etc.

Note: Docs are generated using apidoc with corresponding docstrings present in view files under the /api/views directory. Documentation is served separately by the wolfbeacon-apidoc-gen service.

Local Development Setup

  • Install virtualenv supporting Python 3.5 and activate it

    virtualenv venv && source venv/bin/activate

  • Make a file from the file provided

    cp wolfbeacon/ wolfbeacon/

  • Ensure you have PostgreSQL running. A quick way to setup Postgres is by running it as a docker container locally - docker run -p 5432:5432 -e POSTGRES_PASSWORD=Admin123 -d postgres

  • Add values in DATABASES (your database configuration) and AUTH0 keys in the file. Adding the AUTH0 configuration (used for Auth0 Token Validation) is optional. Hence for local testing, disable it by removing 'api.middleware.auth0.Auth0Middleware', from MIDDLEWARE.

  • Install requirements

    sudo pip install -r requirements.txt

  • Run database migrations

    python migrate

  • Start development server

    python runserver

Running in Production with Docker

Make sure Docker is installed on your system. We run this API a Dockerized application in production.

Assuming Postgres is already running in a separate container remotely accessible and the file is all configured, we are ready to go. Simply build a docker image for this application and run it.

  • sudo docker build -t wolfbeacon-core-api .
  • sudo docker run -p 8000:8000 wolfbeacon-core-api

This should have have your app up and running, accessible on port 8000.

AWS CodeDeploy Env Variables

CORE_S3_CONFIG_PATH - wolfbeacon/ S3 path

Simulating Production Environment Locally

For local testing purposes, a production environment can be simulated using the provided docker-compose file. It bundles the API and Postgres together. Currently, migrations are manually run after both the containers start.

  • cp wolfbeacon/ wolfbeacon/

  • Comment out line 38 from the Dockerfile which makes DB Migrations

    # RUN /venv/bin/python migrate

  • sudo docker-compose up --build -d

  • sudo docker exec -it <wolfbeaconapi_container_id> sh

  • /venv/bin/python migrate