# vysocan/ohs_2-gateway architecture

> Architecture diagram of the GitHub repository vysocan/ohs_2-gateway, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vysocan/ohs_2-gateway
- Repository: https://github.com/vysocan/ohs_2-gateway

## Overview

Open Home Security GW is firmware for an STM32-based home-security gateway. Its user-facing workflow is browser or MQTT command → gateway handler → security state/configuration, with status and alerts presented through the interface or messaging integrations. The tree also identifies radio, RS-485, modem, sensor, timer, trigger, logging, and service subsystems. The excerpts confirm HTTP page dispatch and MQTT group-control calls, but omit much of startup and task wiring; uncertain runtime links are therefore left out.

Main entry points: [`ohs_httpd_handler.h`](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_httpd_handler.h) (HTTP page dispatch), [`ohs_conf.h`](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_conf.h) (Persistent configuration), [`httpd/httpd_handler_group.h`](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_group.h) (Group controls), [`mqtt_cmd_handler.h`](https://github.com/vysocan/ohs_2-gateway/blob/master/mqtt_cmd_handler.h) (MQTT commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_http["HTTP page dispatch"]
  node_webgroups["Group controls"]
  node_websettings["Settings pages"]
  node_webtriggers["Trigger editor"]
  node_webtimers["Timer editor"]
  node_webscripts["Script editor"]
end

subgraph group_security["Security domain"]
  node_groups["Alarm groups<br/>[ohs_th_alarm.h]"]
  node_zones["Zones<br/>[ohs_th_zone.h]"]
  node_triggers["Trigger evaluation<br/>[ohs_th_trigger.h]"]
  node_timers["Scheduled actions<br/>[ohs_th_alarm.h]"]
  node_tcl["Tcl scripts<br/>[tcllib.c]"]
end

subgraph group_connectivity["Connectivity"]
  node_mqtt["MQTT integration"]
  node_mqttcmd["MQTT commands<br/>[mqtt_cmd_handler.h]"]
  node_radio["Radio link<br/>[ohs_th_radio.h]"]
  node_rs485["RS-485 link<br/>[ohs_th_rs485.h]"]
  node_modem["Cellular modem<br/>[ohs_th_modem.h]"]
end

subgraph group_runtime["Runtime services"]
  node_main["Firmware entry<br/>[main.c]"]
  node_logger["Event logging<br/>[ohs_th_logger.h]"]
  node_service["System service<br/>[ohs_th_service.h]"]
  node_config[("Persistent configuration<br/>[ohs_conf.h]")]
end

node_operator(("Operator"))
node_broker(("MQTT broker"))

node_operator -->|"requests pages"| node_http
node_http -->|"dispatches pages"| node_webgroups
node_http -->|"dispatches pages"| node_websettings
node_http -->|"dispatches pages"| node_webtriggers
node_http -->|"dispatches pages"| node_webtimers
node_http -->|"dispatches pages"| node_webscripts
node_webgroups -->|"reads settings"| node_config
node_webgroups -->|"disarms group"| node_groups
node_websettings -->|"reads settings"| node_config
node_webtriggers -->|"reads trigger config"| node_config
node_webtimers -->|"reads timer config"| node_config
node_webscripts -->|"manages scripts"| node_tcl
node_broker -.->|"exchanges messages"| node_mqtt
node_mqtt -.->|"dispatches commands"| node_mqttcmd
node_mqttcmd -->|"arms or disarms"| node_groups
node_mqttcmd -->|"requests refresh"| node_zones
node_main -->|"includes handler"| node_http
node_main -->|"includes integration"| node_mqtt

click node_main "https://github.com/vysocan/ohs_2-gateway/blob/master/main.c"
click node_http "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_httpd_handler.h"
click node_webgroups "https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_group.h"
click node_websettings "https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_setting.h"
click node_webtriggers "https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_trigger.h"
click node_webtimers "https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_timer.h"
click node_webscripts "https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_tcl.h"
click node_mqtt "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_mqtt_functions.h"
click node_mqttcmd "https://github.com/vysocan/ohs_2-gateway/blob/master/mqtt_cmd_handler.h"
click node_groups "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_alarm.h"
click node_zones "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_zone.h"
click node_triggers "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_trigger.h"
click node_timers "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_alarm.h"
click node_tcl "https://github.com/vysocan/ohs_2-gateway/blob/master/source/tcllib.c"
click node_radio "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_radio.h"
click node_rs485 "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_rs485.h"
click node_modem "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_modem.h"
click node_logger "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_logger.h"
click node_service "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_service.h"
click node_config "https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_conf.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_http,node_webgroups,node_websettings,node_webtriggers,node_webtimers,node_webscripts toneBlue
class node_groups,node_zones,node_triggers,node_timers,node_tcl toneAmber
class node_mqtt,node_mqttcmd,node_radio,node_rs485,node_modem toneMint
class node_main,node_logger,node_service,node_config toneRose
class node_operator,node_broker toneIndigo
```

## Components

### Web interface

- [HTTP page dispatch](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_httpd_handler.h): `ohs_httpd_handler.h`
- [Group controls](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_group.h): `httpd/httpd_handler_group.h`
- [Settings pages](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_setting.h): `httpd/httpd_handler_setting.h`
- [Trigger editor](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_trigger.h): `httpd/httpd_handler_trigger.h`
- [Timer editor](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_timer.h): `httpd/httpd_handler_timer.h`
- [Script editor](https://github.com/vysocan/ohs_2-gateway/blob/master/httpd/httpd_handler_tcl.h): `httpd/httpd_handler_tcl.h`

### Security domain

- [Alarm groups](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_alarm.h): `ohs_th_alarm.h`
- [Zones](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_zone.h): `ohs_th_zone.h`
- [Trigger evaluation](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_trigger.h): `ohs_th_trigger.h`
- [Scheduled actions](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_alarm.h): `ohs_th_alarm.h`
- [Tcl scripts](https://github.com/vysocan/ohs_2-gateway/blob/master/source/tcllib.c): `source/tcllib.c`

### Connectivity

- [MQTT integration](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_mqtt_functions.h): `ohs_mqtt_functions.h`
- [MQTT commands](https://github.com/vysocan/ohs_2-gateway/blob/master/mqtt_cmd_handler.h): `mqtt_cmd_handler.h`
- [Radio link](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_radio.h): `ohs_th_radio.h`
- [RS-485 link](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_rs485.h): `ohs_th_rs485.h`
- [Cellular modem](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_modem.h): `ohs_th_modem.h`

### Runtime services

- [Firmware entry](https://github.com/vysocan/ohs_2-gateway/blob/master/main.c): `main.c`
- [Event logging](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_logger.h): `ohs_th_logger.h`
- [System service](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_th_service.h): `ohs_th_service.h`
- [Persistent configuration](https://github.com/vysocan/ohs_2-gateway/blob/master/ohs_conf.h): `ohs_conf.h`

### Other components

- **Operator**
- **MQTT broker**

## Connections

- Operator → HTTP page dispatch: requests pages
- HTTP page dispatch → Group controls: dispatches pages
- HTTP page dispatch → Settings pages: dispatches pages
- HTTP page dispatch → Trigger editor: dispatches pages
- HTTP page dispatch → Timer editor: dispatches pages
- HTTP page dispatch → Script editor: dispatches pages
- Group controls → Persistent configuration: reads settings
- Group controls → Alarm groups: disarms group
- Settings pages → Persistent configuration: reads settings
- Trigger editor → Persistent configuration: reads trigger config
- Timer editor → Persistent configuration: reads timer config
- Script editor → Tcl scripts: manages scripts
- MQTT broker → MQTT integration: exchanges messages
- MQTT integration → MQTT commands: dispatches commands
- MQTT commands → Alarm groups: arms or disarms
- MQTT commands → Zones: requests refresh
- Firmware entry → HTTP page dispatch: includes handler
- Firmware entry → MQTT integration: includes integration
