CS-505 / cs505-web-api

COVID-19 Tracking API
1 stars 0 forks source link

CS 505 Final Project

Table of Contents

  1. Dependencies
  2. Getting Started
  3. Commands
  4. Database
  5. Development
  6. Swagger

Dependencies

You will need docker and docker-compose.

Getting Started

First, clone the project:

$ git clone https://github.com/CS-505/cs505-web-api.git <my-project-name>
$ cd <my-project-name>

Then install dependencies and check that it works

$ make server.install      # Install the pip dependencies on the docker container
$ make server.start        # Run the container containing your local python server

If everything works, you should see the available routes here.

The API runs locally on docker containers. You can easily change the python version you are willing to use by fetching a docker image of the python version you want.

Commands

You can display availables make commands using make.

While developing, you will probably rely mostly on make server.start; however, there are additional scripts at your disposal:

make <script> Description
help Display availables make commands
server.install Install the pip dependencies on the server's container.
server.start Run your local server in its own docker container.
server.daemon Run your local server in its own docker container as a daemon.
server.upgrade Upgrade pip packages interactively.
database.connect Connect to your docker database.
database.migrate Generate a database migration file using alembic, based on your model files.
database.upgrade Run the migrations until your database is up to date.
database.downgrade Downgrade your database by one migration.

Database

Locally, you can connect to your database using :

$ make database.connect

This kit contains a built in database versioning using alembic. Once you've changed your models, which should reflect your database's state, you can generate the migration, then upgrade or downgrade your database as you want. See Commands for more information.

The migration will be generated by the container, it may possible that you can only edit it via sudo or by running chown on the generated file.

Development

To develop locally, here are your two options:

$ make server.start           # Create the containers containing your python server in your terminal
$ make server.daemon          # Create the containers containing your python server as a daemon

The containers will reload by themselves as your source code is changed. You can check the logs in the ./server.log file.

Swagger

The project is documented using Swagger. The API description will be available here. The Swagger UI will be available here.