@@ -11,23 +11,50 @@ specific functionality. The main components include:
1111- ** Data Ingestion Service** : Responsible for collecting data from various sensor endpoints.
1212- ** Data Processing Service** : Processes the ingested data, applying any necessary transformations
1313 or aggregations.
14- - ** API Gateway** : Exposes a REST API for clients to access the processed data.
14+ - ** REST API** : Exposes a REST API for clients to access the processed data.
15+ - ** Application** : Sample frontend application to visualize and interact with the data.
16+
17+ A technical overview of the architecture is shown below:
18+
19+ ![ Architecture Diagram] ( ./docs/architecture/architecture.png )
20+
21+ _ Components in grey are either optional or not implemented yet._
22+
23+ Legend:
24+
25+ - Purple blocks represent external services / devices.
26+ - Orange blocks represent services that are part of the system.
27+ - Blue blocks represent data storage and visualization components.
28+ - Green blocks represent user-facing applications.
29+
30+ > [ !NOTE] Kubernetes Autoscaling Kubernetes Autoscaling is an option, which can be implemented in
31+ > the future if the application scales up. This would allow the services to automatically adjust
32+ > their number of instances based on the current load and demand.
1533
1634## Folder Structure
1735
1836``` text
1937└── 📁ajdovscina-cloud-software
2038 └── 📁alertmanager
39+ └── 📁application
40+ └── 📁public
41+ ├── favicon.ico
42+ ├── index.html
43+ └── 📁src
44+ └── 📁components
45+ └── 📁services
46+ └── 📁types
47+ ├── Makefile
2148 └── 📁common
2249 └── 📁logging
2350 └── 📁dockerfiles
2451 └── 📁docs
2552 └── 📁architecture
26- ├── ajdovscina-architecture.drawio
2753 └── 📁images
2854 └── 📁grafana
2955 └── 📁dashboards
3056 └── 📁ingest_service
57+ └── 📁common
3158 └── 📁models
3259 └── 📁util
3360 ├── Makefile
@@ -36,11 +63,13 @@ specific functionality. The main components include:
3663 └── 📁mock
3764 └── 📁ingest_service
3865 └── 📁processor_service
66+ └── 📁common
3967 └── 📁src
4068 └── 📁util
4169 ├── Makefile
4270 └── 📁prometheus
4371 └── 📁rest_api
72+ └── 📁common
4473 └── 📁models
4574 └── 📁src
4675 └── 📁util
@@ -81,7 +110,61 @@ And to stop the production system:
81110make prod-down
82111```
83112
84- > [ !IMPORTANT] Each of the services can be deployed independently using their respective makefiles.
113+ > [ !IMPORTANT] Service local deployment Each of the services can be deployed independently locally
114+ > using their respective makefiles. See the documentation in each service's directory for more
115+ > details. This should be used in conjunction with the ` make dev-up ` command to start the
116+ > dependencies.
117+
118+ ## Building Blocks
119+
120+ The application is composed of several building blocks, each with its own purpose and functionality.
121+ These blocks are defined in the ` docker-compose ` files located in the root directory.
122+
123+ These are subject to change as the system evolves, but currently include:
124+
125+ - ** PostgreSQL with TimescaleDB** : The primary database for storing sensor data and application
126+ metadata.
127+ - ** Kafka** : A message broker used for decoupling the ingestion and processing services.
128+ - ** Prometheus** : A monitoring and alerting toolkit used for collecting and querying metrics.
129+ - ** Grafana** : A visualization tool used for creating dashboards and visualizing metrics collected
130+ by Prometheus.
131+ - ** Alertmanager** : A component of the Prometheus ecosystem used for handling alerts sent by
132+ Prometheus.
133+ - ** NodeRED** : A flow-based development tool for visual programming, used for wiring together
134+ hardware devices, APIs, and online services.
135+ - ** Ingest Service** : A FastAPI service responsible for receiving and validating incoming sensor
136+ data.
137+ - ** Processor Service** : A service that processes the ingested data and stores it in the database.
138+ - ** Frontend Application** : A React-based application for visualizing and interacting with the
139+ sensor data.
140+
141+ The [ dockerfiles] ( ./dockerfiles ) directory contains Dockerfiles for custom services:
142+
143+ - ` Dockerfile.ingest_service ` : Dockerfile for the Ingest Service.
144+ - ` Dockerfile.processor_service ` : Dockerfile for the Processor Service.
145+ - ` Dockerfile.rest_api ` : Dockerfile for the REST API.
146+ - ` Dockerfile.application ` : Dockerfile for the Frontend Application.
147+
148+ ## Service Accessibility
149+
150+ The services are accessible via the following ports when deployed:
151+
152+ | Service | Local Port | External Port Production | Description |
153+ | -------------------- | ---------- | ------------------------ | ------------------------------------------ |
154+ | PostgreSQL | 5432 | 13328 | Database service |
155+ | Prometheus | 9090 | 19290 | Monitoring and alerting toolkit |
156+ | Grafana | 3000 | 13201 | Visualization tool |
157+ | Alertmanager | 9093 | 19193 | Alert management |
158+ | NodeRED | 1880 | 11880 | Flow-based development tool |
159+ | Ingest Service | 5000 | 40005 | Data ingestion endpoint |
160+ | REST API | 5005 | 41005 | REST API for accessing sensor data |
161+ | Frontend Application | 3001 | 8004 | User interface for visualizing sensor data |
162+
163+ External ports are used to access the services from outside the Docker network, while local ports
164+ are used for communication between services within the Docker network.
165+
166+ If the services are run using their respective makefiles, the ports may differ. See the Makefile in
167+ each service's directory for more details.
85168
86169### Configuration and Constants
87170
@@ -110,3 +193,46 @@ DB_CONFIG = {
110193
111194API_KEY = " your-secret-api-key" # Replace with your actual key
112195```
196+
197+ Detailed descriptions of each constant:
198+
199+ - ` LOG_LEVEL ` : Sets the logging level for the application.
200+ - ` DB_CONFIG ` : A dictionary containing the database connection parameters:
201+ - ` dbname ` : The name of the PostgreSQL database. Set to ` ajdovscina ` by default; This is defined
202+ in the ` docker-compose ` files - ` POSTGRES_DB ` variable.
203+ - ` user ` : The username used to connect to the database. Set to ` ajdovscina-geospatial-user ` by
204+ default; This is defined in the ` docker-compose ` files - ` POSTGRES_USER ` variable.
205+ - ` password ` : The password for the database user. Set to ` password ` by default; This is defined in
206+ the ` docker-compose ` files - ` POSTGRES_PASSWORD ` variable.
207+ - ` host ` : The hostname or IP address of the database server. Set to ` localhost ` for local
208+ development or ` geospatial-data ` when using Docker Compose - that's the service name defined in
209+ the ` docker-compose ` files.
210+ - ` port ` : The port number on which the database server is listening. Set to ` 5432 ` for local
211+ deployment or ` 13328 ` for Docker Compose - this is defined in the ` docker-compose ` files -
212+ ` ports ` mapping in the ` geospatial-data ` service.
213+
214+ #### ingest_service/constants.py
215+
216+ The constants found in the ingest_service/constants.py file are specific to the Ingest Service.
217+
218+ ``` python
219+ import os
220+
221+ LOCALHOST = os.environ.get(" LOCALHOST" ) == " true"
222+
223+ KAFKA_HOST = " localhost:9992" if LOCALHOST else " kafka:9993" # Kafka broker to connect to and produce messages to
224+ # kafka:9993 is the service name defined in the docker-compose files
225+ ```
226+
227+ #### processor_service/constants.py
228+
229+ The constants found in the processor_service/constants.py file are specific to the Processor
230+ Service.
231+
232+ ``` python
233+ import os
234+
235+ LOCALHOST = os.environ.get(" LOCALHOST" ) == " true"
236+ KAFKA_HOST = " localhost:9992" if LOCALHOST else " kafka:9993" # Kafka broker to connect to and consume messages from
237+ # kafka:9993 is the service name defined in the docker-compose files
238+ ```
0 commit comments