Skip to main content

Kiezbox Messages App to send emergency calls

Project description

Kiezbox Notruf-App

Tested with Python 3.11

Architecture

One main driver was the will to have something minimalistic while still modern. A first try to have a separate frontend using react and dynamic routes has proven to be problematic as installing node modules and having a running node instance on IoT devices isn't great. Thus we have server-side template rendering for the frontend. In these templates we use HTMX to handle the interactivity.

The backend is fastapi, using sqlmodel to unite sqlalchemy and pydantic. FastAPI is serving some static files as well as the Jinja2 templates using uvicorn. We use a HTML form to send the emergency calls. We use server-sent events (SSE) to trigger reloads on the inbox.

Backend Installation guide

Set your virtual environment

The following steps are not required but recommended. This will allow you to install packages in your isolated virtual environment instead of globally, reducing the risk of breaking system tools or other projects.

  1. Install pyenv and the pyenv-virtualenv plugin.
  2. Download the appropriate Python version with pyenv install 3.11 in the command line.
  3. Create a virtual environment with the appropriate Python version and name for your environment, for example pyenv virtualenv 3.11 kiezbox
  4. Activate the environment with pyenv activate kiezbox

Run the App

  1. Install the required libraries with the command line pip install -r requirements.txt
  2. Run the server with the command line uvicorn main:app --reload
  3. Your terminal should show something like:
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Open this URL with the /docs suffix in your server to access the Swagger documentation of the API. For this example: `http://127.0.0.1:8000/docs

Update the model

If you want to run an updated version of the API which introduces changes in the database models (for example, a new field), you will have to wipe the database clean first. To do this, simply delete the backend.db file.

Frontend

On the JS side, the interactivity is handled by HTMX, which is shipped locally as we are in a case where phones have no internet connectivity. Currently v1.9.10 is included. See https://github.com/bigskysoftware/htmx/releases.

We have a second JS file which is the SSE extension for HTMX. You can get the latest version from https://github.com/bigskysoftware/htmx/tree/master/dist/ext.

The frontend is simple Jinja2 server-rendered templates styled with TailwindCSS.

Run npm install.

To watch CSS updates, you may run npm run dev

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiezbox-messages-0.2.tar.gz (469.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kiezbox_messages-0.2-py3-none-any.whl (467.9 kB view details)

Uploaded Python 3

File details

Details for the file kiezbox-messages-0.2.tar.gz.

File metadata

  • Download URL: kiezbox-messages-0.2.tar.gz
  • Upload date:
  • Size: 469.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for kiezbox-messages-0.2.tar.gz
Algorithm Hash digest
SHA256 78927b2c163c7f211278f556de6b5e609fa6fc7622848cd63bd870a599a6a128
MD5 d51bf4f86d51010ab11c8e42920f9b07
BLAKE2b-256 395b00b82655e6fe36c4386bfedd9aee7da86f9c674e6d8d9cb6d31d2346221d

See more details on using hashes here.

File details

Details for the file kiezbox_messages-0.2-py3-none-any.whl.

File metadata

  • Download URL: kiezbox_messages-0.2-py3-none-any.whl
  • Upload date:
  • Size: 467.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for kiezbox_messages-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9627a95eb1359b7a98b18fc0a3720672537c64bd44474716d2da0d54b77f3ad6
MD5 185bff6c4dc9ed94fcb477aecad28d2d
BLAKE2b-256 f4c0268f00cacbb61101063d20d216f805b438e237ab9ca39cb29e2f7196efad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page