Code Monkey home page Code Monkey logo

cleancycle's Introduction

CleanCycle

Build Status

1B Group Project (Group Charlie)

Database Server

Technologies used

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 docker-compose up.

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.

Testing

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 docker-tests.yml file).

Inside 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.

The 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_DB, POSTGRES_USER and POSTGRES_PASSWORD environment variables in test.env in the database-server/ directory.

You can visualise the test coverage by clicking database-server/tests/htmlcov/index.html.

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_DB, POSTGRES_USER and POSTGRES_PASSWORD environment variables. You'll also need to ensure any database backup CSV files are copied across in database-server/src/backups.

Then run 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 docker-compose.yml file.)

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 yapf formatted.

arduino:

This folder contains the code that is run on the arduino

communication

This folder contains functions that can be used to encode and decode the messages for sending via LoRaWAN

cleancycle's People

Contributors

mukul-rathi avatar ivanmgribeiro avatar maxcampman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.