add redis and cleanup
- add doc/global_settings.md - docker_database.md - update dependency.md - extrack hlaeja from development-compose.yml to hlaeja-compose.yml - rename compose.yml to development-compose.yml - extract text from readme.md - databases to doc/docker_database.md - hlaeja service to doc/docker_hlaeja.md - move and rename structure.md to doc/dependency.md - move and rename identity.md to doc/rsa_key.mk - move and rename certificate.md to doc/keystore.md
This commit is contained in:
99
doc/dependency.md
Normal file
99
doc/dependency.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# Hlæja dependency
|
||||
|
||||
## Service dependency
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
;
|
||||
subgraph BE[Backend Services]
|
||||
subgraph HDR[Hlæja Device Registry]
|
||||
HDRS[Service] --> HDRD[(Postgres)]
|
||||
end
|
||||
subgraph HDD[Hlæja Device Data]
|
||||
HDDS[Service] --> HDDD[(InfluxDB)]
|
||||
end
|
||||
subgraph HDC[Hlæja Device Configuration]
|
||||
HDCS[Service] --> HDCD[(Cassandra)]
|
||||
end
|
||||
subgraph HAR[Hlæja Account Registry]
|
||||
HARS[Service] --> HARD[(Postgres)]
|
||||
end
|
||||
end
|
||||
subgraph HDA[Hlæja Device API]
|
||||
HDAS[Service] --> HDAD[(Redis)]
|
||||
end
|
||||
subgraph HRA[Hlæja Registry API]
|
||||
HRAS[Service]
|
||||
end
|
||||
subgraph HM[Hlæja Management]
|
||||
HMS[Service]
|
||||
end
|
||||
|
||||
HDA --> HDR
|
||||
HDA --> HDC
|
||||
HDA --> HDD
|
||||
HRA --> HDR
|
||||
HRA -.-> HAR
|
||||
HM -.-> HDC
|
||||
HM -.-> HDR
|
||||
HM -.-> HAR
|
||||
```
|
||||
|
||||
## Library and Gradle plugin dependency
|
||||
|
||||
```mermaid
|
||||
graph RL
|
||||
;
|
||||
CP[Core Plugin]
|
||||
subgraph SCP [Common Plugin]
|
||||
PL[Plugin Library]
|
||||
PLM[Plugin Library Manifest]
|
||||
PLP[Plugin Library Publish]
|
||||
PCo[Plugin Common]
|
||||
PCoD[Plugin Common Detekt]
|
||||
PCoK[Plugin Common Ktlint]
|
||||
PS[Plugin Service]
|
||||
PSC[Plugin Service Container]
|
||||
PSIT[Plugin Service Integration Test]
|
||||
PSPR[Plugin Service Process Resource]
|
||||
PCe[Plugin Certificate]
|
||||
end
|
||||
PCo --> PL
|
||||
PLM --> PL
|
||||
PLP --> PL
|
||||
CP --> PCo
|
||||
PCoD --> PCo
|
||||
PCoK --> PCo
|
||||
PCo --> PS
|
||||
PSC --> PS
|
||||
PSIT --> PS
|
||||
PSPR --> PS
|
||||
CML[Common Messages Library]
|
||||
PL --> CML
|
||||
DRS[Device Registry Service]
|
||||
CML --> DRS
|
||||
PS --> DRS
|
||||
PCe --> DRS
|
||||
DDS[Device Data Service]
|
||||
CML --> DDS
|
||||
PS --> DDS
|
||||
DCS[Device Configuration Service]
|
||||
CML --> DCS
|
||||
PS --> DCS
|
||||
DAS[Device API Service]
|
||||
CML --> DAS
|
||||
PS --> DAS
|
||||
PCe --> DAS
|
||||
RAS[Registry API Service]
|
||||
CML --> RAS
|
||||
PS --> RAS
|
||||
PCe --> RAS
|
||||
AS[Account Service]
|
||||
CML -.-> AS
|
||||
PS -.-> AS
|
||||
PCe -.-> AS
|
||||
MUS[Management UI Service]
|
||||
CML -.-> MUS
|
||||
PS -.-> MUS
|
||||
PCe -.-> MUS
|
||||
```
|
||||
48
doc/docker_database.md
Normal file
48
doc/docker_database.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Hlæja databases
|
||||
|
||||
## InfluxDB
|
||||
|
||||
InfluxDB is a high-performance time series database designed to handle large volumes of time-stamped data. It is commonly used for monitoring, analytics, and IoT applications, where data points are associated with timestamps (e.g., sensor readings, system metrics).
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
DOCKER_INFLUXDB_INIT_MODE: setup
|
||||
DOCKER_INFLUXDB_INIT_USERNAME: influx
|
||||
DOCKER_INFLUXDB_INIT_PASSWORD: password
|
||||
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: influxdbToken==
|
||||
DOCKER_INFLUXDB_INIT_ORG: hlaeja_ltd
|
||||
DOCKER_INFLUXDB_INIT_BUCKET: device-data
|
||||
```
|
||||
|
||||
## PostgreSQL
|
||||
|
||||
PostgreSQL is a powerful, open-source relational database management system (RDBMS). Known for its reliability and advanced features, it supports SQL for querying and managing data, along with extensive functionality for scalability and extensibility.
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD : password
|
||||
```
|
||||
|
||||
## Apache Cassandra
|
||||
|
||||
Apache Cassandra is a distributed NoSQL database designed for handling large amounts of data across many commodity servers with no single point of failure. It is optimized for high availability, scalability, and fault tolerance.
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
CASSANDRA_USER: cassandra
|
||||
CASSANDRA_PASSWORD: password
|
||||
```
|
||||
|
||||
## Redis
|
||||
|
||||
Redis is an in-memory data store that can be used as a database, message broker, or cache layer. It is designed for high performance and low latency, making it suitable for real-time web applications.
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
REDIS_PASSWORD: password
|
||||
```
|
||||
75
doc/docker_hlaeja.md
Normal file
75
doc/docker_hlaeja.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Hlæja Services
|
||||
|
||||
## Device Data
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
INFLUXDB_TOKEN: influxdbToken==
|
||||
```
|
||||
|
||||
## Device Registry
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
SPRING_R2DBC_URL: r2dbc:postgresql://localhost:5432/device_registry
|
||||
SPRING_R2DBC_USERBAME: services
|
||||
SPRING_R2DBC_PASSWORD: password
|
||||
JWT_PRIVATE_KEY: cert/private_key.pem
|
||||
```
|
||||
|
||||
### Volume
|
||||
|
||||
Mount a local private key into the container. Read [`rsa_key.md`](./rsa_key.md) for how to generate.
|
||||
|
||||
```text
|
||||
volumes:
|
||||
- ./cert/device_private_key.pem:/app/resources/cert/private_key.pem
|
||||
```
|
||||
|
||||
## Device API
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
```
|
||||
|
||||
### Volume
|
||||
|
||||
Mount a local public key into the container. Read [rsa_key.md](./rsa_key.md) for how to generate.
|
||||
|
||||
Mount a local keystore into the container. Read [keystore.md](./keystore.md) for how to generate.
|
||||
|
||||
```text
|
||||
volumes:
|
||||
- ./cert/device_public_key.pem:/app/resources/cert/public_key.pem
|
||||
- ./cert/device_api_keystore.p12:/app/resources/cert/keystore.p12
|
||||
```
|
||||
|
||||
## Device Configuration
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
```
|
||||
|
||||
## Registry API
|
||||
|
||||
### Environment
|
||||
|
||||
```text
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
```
|
||||
|
||||
### Volume
|
||||
|
||||
Mount a local keystore into the container. Read [keystore.md](./keystore.md) for how to generate.
|
||||
|
||||
```text
|
||||
volumes:
|
||||
- ./cert/registry_api_keystore.p12:/app/resources/cert/keystore.p12
|
||||
```
|
||||
26
doc/global_settings.md
Normal file
26
doc/global_settings.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Global settings
|
||||
|
||||
Hlaeja services utilize Gradle options or environment variables to configure development settings, ensuring our configurations remain organized and secure.
|
||||
|
||||
## Overview
|
||||
|
||||
By using these methods, we can easily manage access to restricted resources and maintain a consistent configuration across our services. This approach enables us to keep sensitive information separate from our codebase.
|
||||
|
||||
## Gradle properties
|
||||
|
||||
To access repositories that require authentication, we set `repository.user` and `repository.token` properties in the `gradle.properties` file. To do this:
|
||||
|
||||
1. Open or create the `gradle.properties` file in your Gradle user home directory:
|
||||
|
||||
- On Unix-like systems (Linux, macOS), this is typically located at `~/.gradle/`.
|
||||
- On Windows, this is typically located at `C:\Users\<YourUsername>\.gradle\`.
|
||||
|
||||
2. Add the following settings to the `gradle.properties` file:
|
||||
```properties
|
||||
repository.user=your_user
|
||||
repository.token=your_token_value
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
|
||||
Alternatively, you can use `REPOSITORY_USER` and `REPOSITORY_TOKEN` environment variables to pass credentials to the application. These variables can be set in your system environment or through your IDE.
|
||||
46
doc/keystore.md
Normal file
46
doc/keystore.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Generate Keystore
|
||||
|
||||
### Generate Keystores
|
||||
|
||||
To generate a keystore for our API's and web manager, which is used to enable HTTPS, you can use the following command:
|
||||
|
||||
```shell
|
||||
keytool -genkeypair -alias <service> -keyalg RSA -keysize 2048 -validity 3650 -dname "CN=<domain>" -keypass <password> -keystore ./cert/<keystore>.p12 -storetype PKCS12 -storepass <password>
|
||||
```
|
||||
|
||||
This command generates a keystore with the following properties:
|
||||
|
||||
* \<service>: The alias for the service (e.g. device-api)
|
||||
* \<domain>: The domain name for the service (e.g. deviceapi)
|
||||
* \<password>: The password for the keystore and private key
|
||||
* ./cert/\<keystore>.p12: The file path and name for the generated keystore
|
||||
|
||||
### Export the public certificate
|
||||
|
||||
Once you have generated a keystore, you can export the public certificate using the following command:
|
||||
|
||||
```shell
|
||||
keytool -export -alias <service> -keystore ./cert/<keystore>.p12 -storepass <password> -file ./cert/<domain>.cer -rfc
|
||||
```
|
||||
|
||||
This command exports the public certificate with the following properties:
|
||||
|
||||
* \<service>: The alias for the service (e.g. device-api)
|
||||
* \<keystore>: The keystore file containing the private key and certificate (e.g. ./cert/deviceapi.p12)
|
||||
* \<password>: The password for the keystore
|
||||
* \<domain>: The domain name for the exported certificate file (e.g. deviceapi.cer)
|
||||
* ./cert/\<domain>.cer: The file path and name for the exported public certificate
|
||||
|
||||
The exported public certificate is then used on devices to establish a secure connection to our API. Specifically, the certificate is installed on devices to enable them to trust our API's SSL/TLS connection, allowing for encrypted communication between the device and our API.
|
||||
|
||||
Note: Make sure to update your hosts file with an entry for the domain name (e.g. 127.0.0.1 deviceapi) to enable local development.
|
||||
|
||||
1. Open `hosts` file:
|
||||
|
||||
* On Unix-like systems (Linux, macOS), this directory is typically `/etc/hosts`.
|
||||
* On Windows, this directory is typically `%SystemRoot%\System32\drivers\etc\hosts`.
|
||||
|
||||
2. Add the following lines to the `hosts` file:
|
||||
```text
|
||||
127.0.0.1 deviceapi # Hlæja Device API
|
||||
```
|
||||
16
doc/rsa_key.md
Normal file
16
doc/rsa_key.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Generate Private and Public RSA Key
|
||||
|
||||
OpenSSL Project is dedicated to providing a simple installation of OpenSSL for Microsoft Windows.
|
||||
[Download](https://slproweb.com/products/Win32OpenSSL.html)
|
||||
|
||||
Generate an RSA private key, of size 2048, and output it to a file named `identity_private_key.pem` in to `./cert`
|
||||
|
||||
```shell
|
||||
openssl genrsa -out identity_private_key.pem 2048
|
||||
```
|
||||
|
||||
Extract the public key from `identity_private_key.pem` from `./cert`, and output it to a file named `identity_public_key.pem` in to `./cert`
|
||||
|
||||
```shell
|
||||
openssl rsa -in identity_private_key.pem -pubout -out identity_public_key.pem
|
||||
```
|
||||
Reference in New Issue
Block a user