The server repository contains the APIs for the other components (mobile app, hardware payload) as well as the pricing module to determine the correct prices for each rental. This server provides a range of endpoints that facilitate all the functionality of the app from rental bookings to admin management.
This project depends on a geospatial database. If you wish to use sqlite, you will need spatialite. On macOS:
brew install libspatialite
Installing the server is easy. Assuming you have a recent version of python (3.6 or above) then
> git clone https://github.com/dragorhast/server.git
> cd server
> pipenv install
Alternatively, for development,
> pipenv install --dev
Running the server, once the requirements are installed, is simple:
> pipenv run server
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Then, simply navigate to the API docs to get started.
The server is equipped for testing with a range of tools:
- pytest: unit testing
- flake8: simple PEP8 violation checker
- pylint: more in-depth bug checking
- mypy: static type checking
- safety: dependency vulnerability warnings
- bandit: security warnings
You can run the lot like so:
pipenv run test
pylint server
mypy server
safety check
bandit -r server
All code submitted to the repo will have to pass all the tests on Travis CI before being deployed.
In addition to the CI / CD above, the repository is monitored by a number of tools to automate the development process. As well as being able to know the build status of any pull request at a glance, we use codecov, hound, and codeclimate to track various metrics about the history of the codebase such as general code quality, unit test coverage, and design errors or antipatterns.
- codecov takes reports generated from the CI process and displays the total coverage as well as the change in coverage. This is a good way to tell if someone adds a feature with minimal unit testing.
- codeclimate scans the codebase for code smells, complex functions, and other high level problems assigning a score to the project. We can tell, based on the report generated, if there are any issues with a branch before it is merged into master.
- hound does automated code review on pull requests to automatically highlight the most obvious errors without human intervention allowing us to focus on the content itself.
Documentation is included. You may build it by installing the dev dependencies and running sphinx-autobuild
.
pipenv install --dev
pipenv run docs