Django Application for monitoring Bellboy devices, also provides a frontend for staff to monitor devices and interact with device users
This backend provides the following utilites for use by the Bellboy website and Bellboy devices:
- Registry for Bellboy devices
- Authentication for security users
The repository uses the following technology to ensure quality:
- PyUp.io monitors dependencies to ensure no vulnerabilities are present
- Github Workflows run pytest to ensure unit tests pass before a build on Heroku
- Workflows for linting tools ensure the code follows best practices for quality and style:
- Black enforces code style
- Flake8 checks for common errors
- MyPy adds type checking to Python
- iSort sorts imports to separate imports from stdlib, third party, and local sources
- An assortment of end-of-file, line-ending, and whitespace checks
To work on this repository, you'll need to download and install Pycharm and Docker Desktop.
Thanks to a convo with Sein, I've now included a collection of instructions for getting started and troubleshooting.
Generally, to run the development environment, type docker-compose -f development.yml up
Services API docs are hosted at https://bellboy-services.herokuapp.com/swagger/
These instructions are for Windows 10, which the majority of our team uses. If running on a better OS it is assumed that you are skilled enough to figure all this out by yourself.
- Install Docker Desktop from this link. Ensure that you install the WSL2 binaries.
- Ensure the WSL integrations are enabled, as seen in the screenshot below: You do not need to use the Windows Subsystem for Linux (WSL) on GNU/Linux or OSX.
- If you have problems with speed or stability in WSL, it's fine to use the Hyper-V backend.
- Ensure that everything works by running the following command:
If all the unit tests pass, you're good to go! Your system should now be ready to do basic development. Any changes you make will be hot-reloaded after running this:
docker-compose -f development.yml run django pytest
docker-compose -f development.yml up
git checkout -b <new branch name>
git push --set-upstream origin <new branch name>
When adding new features, please use the semantic commit labels so versioning is accurate:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
The database containers can also be accessed externally, allowing you to run manage.py
commands from outside the container, but on Windows 10, it may be difficult to successfully install all of the django dependencies, especially psycopg2
, and you should probably stick to running commands in the container like so:
docker-compose -f development.yml run django <your cmd here>
Within the Services project, functionality is organized into apps. For example, there could be an app to manage users, an app to run an endpoint to manage camera data, and an endpoint to continuously process incoming data from successful ultrasonic activations.
The filesystem is organized like so:
Services (root folder)
- services (application folder)
- users
- utils
- <your app here>
To add a new app, you'll need to do these things:
- Know what you want to name your new app.
- Right-click the 'services' folder and add a new python package.
- Inside the folder, there should exist a file called
__init__.py
, just make sure it's there. - Create a new python file in the folder called
apps.py
, and add the following:from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class <AppName>Config(AppConfig): name = "services.<appname>" verbose_name = _("<App Name>")
- Now the app needs to be added to the
LOCAL_APPS
list in config > settings >base.py
:LOCAL_APPS = [ "services.users.apps.UsersConfig", # Your stuff: custom apps go here "services.<appname>.apps.<AppName>Config" ]
- That's it, your new app will be loaded and run when Django starts.
- Enjoy a scoop of ice cream.
# Install requirements:
# (In admin console on windows)
pip install -r requirements.txt
# (Or on linux/OSX)
python3 -m pip install -r requirements.txt
# Set up pre-commit
pre-commit install
# Launch the Services component with docker
docker-compose -f development.yml up
# Run the unit tests
docker-compose -f development.yml run django pytest
# Branch and start hacking!
git checkout -b my-new-branch-name