Skip to content

wolfbeacon/wolfbeacon-core-api

Repository files navigation

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

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 settings.py file from the settings.template.py file provided

    cp wolfbeacon/settings.template.py wolfbeacon/settings.py

  • 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 settings.py 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 manage.py migrate

  • Start development server

    python manage.py 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 settings.py 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/settings.py 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/settings.docker-compose.py wolfbeacon/settings.py

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

    # RUN /venv/bin/python manage.py migrate

  • sudo docker-compose up --build -d

  • sudo docker exec -it <wolfbeaconapi_container_id> sh

  • /venv/bin/python manage.py migrate

About

Core WolfBeacon API powering the Mobile and Dashboard apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages