Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,28 @@ localhost:8000/api
localhost:8000/api/{location}
localhost:8000/api/{location}/trends

### Messaging service
To run the messaging service locally you can do the following:
1. Make an account in HiveMQ and make a free cluster.
2. In the .env file, fill in the connection values from HiveMQ under "Connection Details"
3. Make a credential in HiveMQ under "Access Management" and fill these values in the .env file.
4. Run the Fire risk API
5. Go into terminal and run the publisher with command "python publisher.py"

You can now go into the Web Client in HiveMQ
![Alt text](images/ConnectHiveMQ.png)

Fill in with the credentials made earlier or autogenerate credentials in "Connections Settings". When the client is connected you can now use the interface to subscribe to different topics. The topics are "fireguard/updates/{location_name}" and the location has to be in the database to be able to subscribe to it. When it is published to a topic the message will show in the messages window.
Here is an example of topics:
![Alt text](images/subscribeHiveMQ.png)

<!-- TOC --><a name="background"></a>
## Background

<!-- TOC --><a name="overall-architecture"></a>
### Overall Architecture
![Alt text](images/Architecture.png)

This project is setup as containerized services orchastrated through tools such as Docker-Compose or Kubernetes. The following services are planned:
- API connectionpoint
- KeyCloak with database for persistent storage
Expand All @@ -109,9 +126,16 @@ This project is setup as containerized services orchastrated through tools such

<!-- TOC --><a name="databases"></a>
### Databases
The project uses a single MongoDB database (FireGuardProject) with a collection named location. Each document in the collection represents a location and its associated fire risk data. As well as coordinates and last time the fire risk for the location was calculated.
![Alt text](images/MongoDB.png)

<!-- TOC --><a name="messaging-system"></a>
### Messaging System
The publisher in this project is responsible for fetching fire risk data for various locations and publishing it to a specific MQTT topics using the HiveMQ Cloud broker.

It connects to the HiveMQ Cloud broker via secure MQTT communication over TLS and publishes fire risk updates to dynamically generated topics based on the location names (e.g., fireguard/updates/{location_name}). Location data is retrieved from the database, and the fire risk information is obtained via HTTP requests to our REST API.

To avoid redundant computations, the REST API checks wether fire risk data has already been calculated for the current day. If so, it returns the existing data from the database. As a result, it is natural that the publisher sends updates only once per day for each location.s

<!-- TOC --><a name="authentication-and-authorization"></a>
### Authentication and Authorization
Expand Down
Binary file added images/Architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ConnectHiveMQ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/MongoDB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/subscribeHiveMQ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading