License: MIT
- Table of contents
- Description
- Architecture
- Dashboard website
- Technology stack
- Documentation
- Start locally
- Setup GCP
- Define sensors
- API docs
The task was to design and implement an application that can deal with various different challenges related to fog computing.
- The application must comprise a local component that runs on a local machine, and a component running in the Cloud, e.g., on GCE.
- The local component must collect and make use of (simulated) environmental information. For this purpose, a minimum of two virtual sensors should be designed and used that continuously generate realistic data.
- Data has to be transmitted regularly (multiple times a minute) between the local component and the Cloud component in both directions.
- When disconnected and/or crashed, the local and Cloud component have to keep working while preserving data for later transmission. Upon reconnection, the queued data needs to be delivered.
- The application can be implemented in any standard programming language
- It is not allowed to use any Cloud services or frameworks that take care of resolving fog-specific challenges, e.g., regarding reliable message delivery
- (messaging libraries such as ZeroMQ are fine).
- The goal of the prototype is to build a fog application and to manually implement the reliable delivery of messages.
Diagram was created with diagrams.net.
Website: Dashboard
Main page | Settings |
---|---|
In the Settings you can set the URL for the API.
You can only usehttps
endpoints! Default value is:http://127.0.0.1:8000
.
Because the website hosted on GitHub pages uses https
, only https API endpoints can be called there.
Because our default scripts use only http
to connect to the GCP instance, use the manual way or start the docker-compose
file in ./dashboard/docker-compose.yaml
. See: section: Frontend - Docker compose. Then you can reach the GCP compute engine over http
.
- Local app:
- Dashboard website:
- Cloud app:
- Documentation PDF:
- Demonstration Video:
Component | Name | Default | Description |
---|---|---|---|
Local | LOCAL_CLOUD_ENDPOINT_URL |
tcp://localhost:5556 |
The cloud component ZeroMQ endpoint url |
LOCAL_LISTENER_ENDPOINT_URL |
tcp://*:5557 |
The local component ZeroMQ endpoint to bind to | |
Cloud | CLOUD_LOCAL_ENDPOINT_URL |
tcp://localhost:5557 |
The local component ZeroMQ endpoint url |
CLOUD_LISTENER_ENDPOINT_URL |
tcp://*:5556 |
The cloud component ZeroMQ endpoint to bind to |
Use -d
to start it in the background.
Run:
# Run service
docker compose up -d
Description | URL |
---|---|
Dashboard address | http://localhost/ |
Cloud API | http://localhost:8000 |
Cloud API docs | http://localhost:8000/docs |
Cloud API: GET sensor data | http://localhost:8000/sensor-data |
Cloud API: GET sensor data (ordered) | http://localhost:8000/sensor-data/ordered |
Go into the: local/
folder.
Use -d
to start it in the background.
Run:
# Run service
docker compose up -d
Run:
# Install dependencies
poetry install
# Run service
poetry run python -m local.main
Go into the: cloud/
folder.
Use -d
to start it in the background.
Run:
# Run service
docker compose up -d
Run:
# Install dependencies
poetry install
# Run service
poetry run uvicorn cloud.main:app
Description | URL |
---|---|
Cloud API | http://localhost:8000 |
Cloud API docs | http://localhost:8000/docs |
Cloud API docs | http://localhost:8000/docs |
Cloud API: GET sensor data | http://localhost:8000/sensor-data |
Cloud API: GET sensor data (ordered) | http://localhost:8000/sensor-data/ordered |
Go into the: dashboard/
folder.
Use -d
to start it in the background.
Run:
# Run service
docker compose up -d
Run:
# Install dependencies
pnpm install
# Run service
pnpm run dev
Description | URL |
---|---|
Dashboard address | http://localhost/ |
- Follow the steps in section Credentials/Variables to setup the required variables.
- Edit the variables (or use the given values) in
gcp-00-settings.sh
. - Setup the resources on GCP (GCP project, GCP compute engine, firewall settings):
- Execute script
gcp-01-initial-setup.sh
- To execute it use:
sh ./gcp-01-initial-setup.sh
- Execute script
- Setup Python and Poetry on the previously created GCP compute instance:
- Execute script:
gcp-02-install-python.sh
- Execute script:
- Upload the cloud files to the GCP compute instance:
- Execute script:
gcp-03-upload-files.sh
- Execute script:
- Start the app in the cloud:
- Execute script:
gcp-04-start-cloud-app.sh
- Execute script:
- You can use
gcp-all.sh
to execute all scripts above at once. - You can use
gcp-instance-01-start.sh
to start the GCP compute instance andgcp-instance-02-stop.sh
to stop it.
Copy template file template.credentials.sh
, rename it to credentials.sh
and fill out the variables.
Variable name | Description | Example |
---|---|---|
CREDENTIALS_PATH |
Path to SSH folder | /home/<username>/.ssh |
CREDENTIAL_NAME |
Name of the SSH key | fogcomputing |
SSH_PW |
Password for the SSH key | |
COMMENT_SSH |
Comment for the SSH key | fog-computing |
PROJECT_ID |
Project ID on GCP | fogcomputing |
PROJECT_NAME |
Project name on GCP | |
USER_NAME |
Username of the GCP instance |
You can define multiple sensors in the /local/sensors.yaml
file.
You can choose between two types of sensors temperature_sensors
and humidity_sensors
.
Below is an example of such a file:
temperature_sensors:
# Recommended name schema: <sensor_type>-<location>-<number>
- name: temperature-kitchen-01
interval: 5 # in seconds
- name: temperature-livingroom-01
interval: 5
humidity_sensors:
- name: humidity-bedroom-01
interval: 5
Description | HTTP Verb | CRUD | Endpoint |
---|---|---|---|
Cloud API docs | GET | Read | /docs |
Cloud API: GET sensor data | GET | Read | /sensor-data |
Cloud API: GET sensor data (ordered) | GET | Read | /sensor-data/ordered |