From fbb2885e444e2ebb2d34343e74e9d23b7c7ddfd0 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Tue, 4 Apr 2023 13:47:12 +0200 Subject: [PATCH] hw7 done, please check --- .../0003-use-rdbms-as-databases.madr | 2 +- ...-homekit-and-mqtt-protocols-smart-dev.madr | 41 +++++++++++++++++++ .../decisions/0005-postgres-as-rdbms.madr | 37 +++++++++++++++++ src/sa/model/index.md | 10 ++--- 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/sa/model/decisions/0004-homekit-and-mqtt-protocols-smart-dev.madr create mode 100644 src/sa/model/decisions/0005-postgres-as-rdbms.madr diff --git a/src/sa/model/decisions/0003-use-rdbms-as-databases.madr b/src/sa/model/decisions/0003-use-rdbms-as-databases.madr index fa32b69..7b8fe01 100644 --- a/src/sa/model/decisions/0003-use-rdbms-as-databases.madr +++ b/src/sa/model/decisions/0003-use-rdbms-as-databases.madr @@ -1,4 +1,4 @@ -## ADR #0003: Use RDBMS as main choice for database technology +## ADR #0003: Use RDBMS as main choice for database technology 1. **What did you decide?** diff --git a/src/sa/model/decisions/0004-homekit-and-mqtt-protocols-smart-dev.madr b/src/sa/model/decisions/0004-homekit-and-mqtt-protocols-smart-dev.madr new file mode 100644 index 0000000..546bb04 --- /dev/null +++ b/src/sa/model/decisions/0004-homekit-and-mqtt-protocols-smart-dev.madr @@ -0,0 +1,41 @@ +## ADR #0004: HomeKit and MQTT are the supported protocols for smart devices + +1. **What did you decide?** + + HomeKit and MQTT are the protocols which shall be used to connect to user provided smart devices and sensors. Other protocols will be unsupported for the first release of SmartHut. + +2. **What was the context for your decision?** + + Due to SmartHut being an open ended system relying and integrating with user provided devices it is crucial to provide support to satisfy the userbase as much as possible. That being said, + the more protocols will be supported the higher the development cost in integration will be, and this can be especially hurtful in the MVP and hobbyist-oriented style SmartHut is currently being developed. + + The protocols chosen shall have a maintained Java open source client library for ease of integration with the existing users and devices backend, which is implemented using the Spring framework. + +3. **What is the problem you are trying to solve?** + + Which protocols will cover a satisfactorily large number of smart devices from the userbase and which libraries can be used to with them? + +4. **Which alternative options did you consider?** + + - MQTT protocol, via the Eclipse [paho.mqtt.java](https://github.com/eclipse/paho.mqtt.java) library; + - Apple HomeKit Accessory Protocol, via the [HAP-Java](https://github.com/hap-java/HAP-Java) library; + - other protocols (such as Google home, Zigbee, or Alexa), of which I did not find a suitable library. + +5. **Which one did you choose?** + + - MQTT protocol, via the Eclipse [paho.mqtt.java](https://github.com/eclipse/paho.mqtt.java) library; + - Apple HomeKit Accessory Protocol, via the [HAP-Java](https://github.com/hap-java/HAP-Java) library; + +6. **What is the main reason for that?** + + The MQTT protocol is standardized and has a simple specification, while being widely adopted in both commercial and industrial IoT settings. Supporting this protocol is a way to future-proof SmartHut and potentially diversify the market of applications in which it can be installed. + + The _HAP-Java_ library provides good support for HomeKit and it is well maintained, and supporting the protocol will provide an effective way to provide consumer devices which may be seldomly supported by using MQTT only. + + Pros: + - Wide coverage of different applications by providing support for both an industrial-oriented protocol and a consumer-oriented one; + - Free and open source libraries for both protocols with non copyleft licenses, providing ease of support for free and compatibility with a possible commercial distribution of SmartHut; + + Cons: + - Supporting two protocols instead of one has higher integration cost; + - HomeKit is not a widely-adopted standard when compared to Google home, Zigbee or Alexa, catering for a potentially smaller userbase. \ No newline at end of file diff --git a/src/sa/model/decisions/0005-postgres-as-rdbms.madr b/src/sa/model/decisions/0005-postgres-as-rdbms.madr new file mode 100644 index 0000000..99c6987 --- /dev/null +++ b/src/sa/model/decisions/0005-postgres-as-rdbms.madr @@ -0,0 +1,37 @@ +## ADR #0005: PostgreSQL is the database implementation to use + +_ADR depends on [ADR #0003: Use RDBMS as main choice for database technology](#adr0003)_ + +1. **What did you decide?** + + PostgreSQL is the RDBMS implementation to be used in all stateful components of SmartHut. + +2. **What was the context for your decision?** + + A suitable RDBMS implementation shall be found to store the data for all stateful components in the component diagram. The technology shall be as ANSI SQL compliant as possible, battle-tested and provide easy JDBC integration, as the users and devices backend is already implenented using the Java Spring framework. + +3. **What is the problem you are trying to solve?** + + Which RDBMS implementation is the best choice for all stateful components? + +4. **Which alternative options did you consider?** + + - MariaDB + - PostgreSQL (postgres) + - Microsoft SQL Server (mssql) + +5. **Which one did you choose?** + + - PostgreSQL (postgres) + +6. **What is the main reason for that?** + + PostgreSQL is the only RDBMS technology in the list to be fully ANSI SQL compliant while also being widely adopted in industry. Additionally, PostgreSQL provides additional support for features like JSON-aware string queries and direct support for hierarchies, which may come handy when designing the schema of each component's database. + + Pros: + - FOSS technology; + - Battle-tested; + - ANSI SQL compliance + additional advanced features. + + Cons: + - Using advanced features may lock-in this choice more than necessary and make a future switch to another technology harder. \ No newline at end of file diff --git a/src/sa/model/index.md b/src/sa/model/index.md index 8dc6e67..be463ad 100644 --- a/src/sa/model/index.md +++ b/src/sa/model/index.md @@ -779,17 +779,17 @@ Exceed: Redesign based on >3 reused components (1 Logical View, >1 Process View, ## Component selection process ADRs -TBD HAP-java + paho.mqtt.java +![Architectural Decision Record 4](./decisions/0004-homekit-and-mqtt-protocols-smart-dev.madr) -TBD postgres (cite ADR #3 - reational DBs) +![Architectural Decision Record 5](./decisions/0005-postgres-as-rdbms.madr) ## Chosen components | **Name** | **Version** | **Description** | **Price** | **Sources** | | -------- | ----------- | --------------- | --------- | - | -| HAP-Java | 2.0.4 (2022-11-23) | Java implementation of the HomeKit Accessory Protocol | free (MIT license) | https://github.com/hap-java/HAP-Java/tree/hap-2.0.4 | -| Eclipse Paho Java MQTT client | 1.2.5 SR (2020-07-15) | Java client for the MQTT protocol | free (EPL 2.0 license) | https://github.com/eclipse/paho.mqtt.java/tree/v1.2.5 | -| PostgreSQL | 15.2 (2023-02-06) | Relational DBMS | free (PostgreSQL license) | https://github.com/postgres/postgres/tree/REL_15_2 | +| HAP-Java | 2.0.4 (2022-11-23) | Java implementation of the HomeKit Accessory Protocol | free (MIT license - non copyleft) | https://github.com/hap-java/HAP-Java/tree/hap-2.0.4 | +| Eclipse Paho Java MQTT client | 1.2.5 SR (2020-07-15) | Java client for the MQTT protocol | free (EPL 2.0 license - non copyleft) | https://github.com/eclipse/paho.mqtt.java/tree/v1.2.5 | +| PostgreSQL | 15.2 (2023-02-06) | Relational DBMS | free (PostgreSQL license - non copyleft) | https://github.com/postgres/postgres/tree/REL_15_2 | ## Logical View