The Django API behind the React dashboard frontend. This site receives MQTT data from the Data AcQuisition board on our Hydrogen powered car and stores it to a PostgreSQL database
Accessible via /admin, this allows direct access to the database
Accessible via /apidocs/schema/swagger-ui, this provides information on all accessible endpoints and their usage
Covered in depth in the documentation site and has root URL /api
- Requires PostgreSQL as backend, and can set in smvDashboard/settings.py
- Requires an MQTT server, set with the ip_address variable in smvDashboard/settings.py
- Please set DEBUG=False in smvDashboard/settings.py before deploying to production
- Please add secrets to .env file (contact SMV DAQ lead for access if required)
- NOTE: 3.13 > Python version > 3.10 is required, and libpq-dev is required (or Windows PostgreSQL equivalent)
apt get libpq-dev
- Create and activate a virtual environment,
virtualenv env && source env/bin/activate
- Install requirements,
pip install -r requirements.txt
- Collect static files,
python manage.py collectstatic
- Check DEBUG flag
- If any changes have been made to the database file, mqtt/models.py, make migrations and apply them to production database with
python manage.py makemigrations && python manage.py migrate
- Run server with
python manage.py runserver
- Assuming Ubuntu 22.04 LTS VM with all prerequisites installed (apache2, libapache2-mod-wsgi-py3, python3, python3-pip, python3-venv, libpq-dev) and with Apache config file 000-default.conf located at /etc/apache2/sites-available/000-default.conf
- Rename ~/SMV-API to ~/vX.XX
- Clone SMV-API repository
- Apply steps 2 through 5 from the bare metal steps above
- Run:
sudo chmod 774 ~/SMV-API && sudo chown :www-data ~/SMV-API
(may need to adjust chmod to 777) - Restart Apache with
sudo systemctl restart apache2
-Error logs available at /var/log/apache2/error.log or on Sentry
- docker build -t django-apache .
- docker run -p 443:443 -p 80:80 -d django-apache