1B Group Project (Group Charlie)
The Cambike sensor measurements are stored in a PostgreSQL database, whilst the REST endpoint is written using Flask. These are each wrapped in their own Docker containers - to run them, run
docker-compose build and
The bootstrap procedure initialises the database with the measurements in any CSV files in the
database-server/src/backups repository (these have not been committed to the repo).
The database schema can be found in the
database-server/src/db_connection.py file, along with an interface for the common database operations.
The unit tests are in the
database-server/src/tests directory - for each commit pushed to the repo, the Travis CI automatically builds an image from the testing Dockerfile and deploys the container (details of which are in the
test container, Docker runs
pytest for the database and endpoint unit tests. These tests also have
Coverage.py so the overall test coverage for each of the python files can be seen.
analytics container runs
gradle build (using JUnit) for the analytics unit tests and for the integration tests.
To run the tests locally, run
docker-compose -f docker-tests.yml build followed by
docker-compose -f docker-tests.yml run test to run the database unit tests and
docker-compose -f docker-tests.yml run analytics to run the analytics tests. You will need to supply the
POSTGRES_PASSWORD environment variables in
test.env in the
You can visualise the test coverage by clicking
Production - hosting on AWS
Use an EC2 instance, SSH into and copy across files and install Docker and Docker-Compose on the instance. You'll need to supply a
database.env file in the
database-server directory, containing the
POSTGRES_PASSWORD environment variables. You'll also need to ensure any database backup CSV files are copied across in
docker-compose build and
docker-compose up to run the production server. (Endpoint is on port 5000 although this can be changed by altering the forwarded port in the
At this stage of the project, one EC2 instance should be sufficient, though in future AWS ECS or EKS (Kubernetes) could be used to orchestrate the Docker containers in production.
Code Style Guide
The code is written so as to conform to the Google Python style guide.
YAPF is used in a pre-commit hook to ensure consistent formatting.
To enforce high code quality, Travis CI will run
pylint as well as
yapf --diff - these will pass if the code is rated as 10.00/10 for
pylint and if the code in the commit has been
This folder contains the code that is run on the arduino
This folder contains functions that can be used to encode and decode the messages for sending via LoRaWAN