Project description

A simple company review system that allows users to create/update/delete/retrieve their reviews. While the companies can be listed and retrieved from API calls, they can only be added/changed/deleted from Admin.

The company models were kept very simple, with only the company's name. This model were create because it will be easier when company metadata needs to be added. I didn't create a Reviewer model because I chose to use Django's User built-in models for that.

The API docs can be seen at https://reviewer-api.herokuapp.com/.

Tech:

  • Python 3.6.5
  • Django 2.0.5
  • Django Rest Framework 3.8.2

Ops:

  • Heroku: to host the app
  • Travis: makes CI/CD from github to Heroku
  • Docker: container of a PostgreSQL instance for local development/testing
  • Sentry: creates a helpful database of uncaught exceptions in the app

Libs:

  • dj-database-url: to process Heroku's database URL
  • drf-nested-routers: to have things like /api/v1/company/1/review/
  • gunicorn: to act as an HTTP server for the app on Heroku
  • psycopg2: driver for connecting to PostgreSQL
  • whitenoise: to serve static files on production
  • django-dotenv: to load config variables from a .env file

Docs:

  • swagger: creating a structured API doc
  • spectacle: consumes the JSON generated by swagger to create a nice doc

Run locally (Mac OS):

  1. Download the repo's content
  2. Create a virtual environment with python 3.6, something like: $ virtualenv --python=/usr/bin/python3.6 venv
  3. Activate this venv $ source venv/bin/activate
  4. Install dependencies $ pip install -r requirements.txt
  5. Copy the file .env.example to .env $ cp .env.example .env
  6. If you set POSTGRES_ON_DEV to True in your .env file, make sure you have an PostgreSQL instance running. If you don't want to install it in your machine you can use the Docker composer file for that. $ docker-compose up
  7. Run the app's migrations $ python manage.py migrate
  8. Run the app itself $ python manage.py runserver

Important: You're gonna need to create a super user for Django Admin: $ python manage.py createsuperuser

That's because all API endpoints are protected with tokens (or API keys). You can copy the token generated to your super user and use it in your requests as Bearer token in the requests header.