Architecture
FridgeBridge architecture can be summarized by the following diagram:
Workflow
- The Client makes a request to the system.
- The request is routed through the Nginx proxy, which forwards it to the appropriate Java backend service.
- The Java backend processes the request, interacts with the PostgreSQL database, and communicates with RabbitMQ for message handling.
- Metrics and performance data from the Java backend are collected by Prometheus and visualized using Grafana.
Components
-
Nginx Proxy: Acts as the entry point for client requests. Routes traffic to the appropriate Java backend services load balancing and reverse proxying for scalability and reliability. It also has routes to serve
documentation
and thegrafana
dashboard. -
Java Backend: The core business logic of the application resides here. It has 4 main processes:
- The API written with Javalin.
- Reporter: runs in the background and create periodic various reports of interest.
- Metrics: it exposes a metrics endpoint for prometheus to scrap.
-
RabbitMQ: A message broker for asynchronous communication. The Java backend uses RabbitMQ to manage tasks and message queues to synchronize the instances and handle the fridges sensors updates.
-
Prometheus: Collects metrics and data from the Java backend. It also scraps data from node_exporter a service we have running to collect metrics about the server usage (RAM, CPU, DISK, Network, etc).
-
Grafana: A data visualizer that supports prometheus as a data source. It queries prometheus for the data and shows it in different formats that allow us to get insights into the system performance and reliability.
-
Docs: Servers the static files for the documentation. Site was built using Docusaurus.
Deployment
The deployments are automated with Ansible. On prod, all the services run under systemd. For local development, Docker is used to simplify dependency management and the installation of all the tools.
We manage our DNS with freedns and SSL certificates are generated with LetsEncrypt. Finally, we are currently using Azure as our cloud provider.