# morgverd/sms-server architecture

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

- Interactive diagram: https://gitdiagram.com/morgverd/sms-server
- Repository: https://github.com/morgverd/sms-server
- Video tour (about a minute): https://gitdiagram.com/morgverd/sms-server/video

## Overview

SMS Server is a self-hosted gateway connecting a serial GSM modem to SMS persistence, modem controls, GNSS reporting, and client integrations. The main workflow starts in `src/main.rs`, where configuration is loaded and `src/app.rs` launches the modem and service tasks. Incoming modem messages are handled by the app and SMS receiver, then persisted and exposed through HTTP and event integrations; outbound HTTP SMS requests pass through the SMS manager to the modem. README capabilities are included, but some subsystem wiring is inferred only from documentation because its source was not sampled.

Main entry points: [`src/app.rs`](https://github.com/morgverd/sms-server/blob/main/src/app.rs) (App orchestration), [`src/sms/mod.rs`](https://github.com/morgverd/sms-server/blob/main/src/sms/mod.rs) (SMS manager), [`src/modem/worker.rs`](https://github.com/morgverd/sms-server/blob/main/src/modem/worker.rs) (Serial worker), [`src/http/routes.rs`](https://github.com/morgverd/sms-server/blob/main/src/http/routes.rs) (HTTP routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_entry["CLI entry<br/>[main.rs]"]
  node_configuration["Configuration<br/>[config.rs]"]
  node_application["App orchestration<br/>[app.rs]"]
end

subgraph group_modem["Modem and location"]
  node_modem_manager["Modem manager<br/>[mod.rs]"]
  node_modem_worker["Serial worker<br/>[worker.rs]"]
  node_modem_handlers["Command handlers<br/>[handlers.rs]"]
  node_modem_parsers["Response parsers<br/>[parsers.rs]"]
end

subgraph group_messaging["SMS and persistence"]
  node_sms_manager["SMS manager<br/>[mod.rs]"]
  node_multipart["Multipart assembly<br/>[multipart.rs]"]
  node_encryption["Message encryption<br/>[encryption.rs]"]
  node_database[("SMS database<br/>[database.rs]")]
end

subgraph group_interfaces["Client interfaces"]
  node_http_server["HTTP server<br/>[mod.rs]"]
  node_http_routes["HTTP routes<br/>[routes.rs]"]
  node_openapi["OpenAPI support<br/>[openapi.rs]"]
end

subgraph group_events["Event delivery"]
  node_event_broadcaster["Event broadcaster<br/>[events.rs]"]
  node_websocket["WebSocket stream<br/>[websocket.rs]"]
  node_webhooks["Webhook delivery<br/>[webhooks.rs]"]
end

node_operator(("Operator"))
node_http_client(("HTTP client"))
node_ws_client(("WebSocket client"))
node_gsm_modem{{"GSM modem"}}
node_webhook_target{{"Webhook receiver"}}
node_sqlite[("SQLite")]

node_operator -->|"starts gateway"| node_entry
node_entry -->|"loads settings"| node_configuration
node_entry -->|"starts runtime"| node_application
node_application -->|"uses settings"| node_configuration
node_application -->|"starts modem"| node_modem_manager
node_modem_manager -->|"spawns worker"| node_modem_worker
node_modem_worker -->|"reads and writes"| node_gsm_modem
node_modem_worker -->|"dispatches responses"| node_modem_handlers
node_modem_handlers -->|"parses responses"| node_modem_parsers
node_modem_worker -->|"forwards modem messages"| node_application
node_application -->|"handles incoming SMS"| node_sms_manager
node_sms_manager -->|"assembles segments"| node_multipart
node_sms_manager -->|"stores and queries"| node_database
node_database -->|"encrypts message content"| node_encryption
node_database -->|"persists records"| node_sqlite
node_application -->|"broadcasts events"| node_event_broadcaster
node_sms_manager -->|"publishes SMS events"| node_event_broadcaster
node_application -->|"starts server"| node_http_server
node_http_client -->|"calls API"| node_http_server
node_http_server -->|"dispatches requests"| node_http_routes
node_http_routes -->|"sends SMS"| node_sms_manager
node_http_routes -->|"reads message data"| node_database
node_http_routes -->|"requests modem data"| node_modem_manager
node_http_server -.->|"exposes API schema"| node_openapi
node_application -->|"provides event stream"| node_websocket
node_ws_client -->|"subscribes to events"| node_websocket
node_event_broadcaster -->|"streams events"| node_websocket
node_application -->|"starts delivery worker"| node_webhooks
node_event_broadcaster -->|"dispatches events"| node_webhooks
node_webhooks -->|"posts events"| node_webhook_target

click node_entry "https://github.com/morgverd/sms-server/blob/main/src/main.rs"
click node_configuration "https://github.com/morgverd/sms-server/blob/main/src/config.rs"
click node_application "https://github.com/morgverd/sms-server/blob/main/src/app.rs"
click node_event_broadcaster "https://github.com/morgverd/sms-server/blob/main/src/events.rs"
click node_modem_manager "https://github.com/morgverd/sms-server/blob/main/src/modem/mod.rs"
click node_modem_worker "https://github.com/morgverd/sms-server/blob/main/src/modem/worker.rs"
click node_modem_handlers "https://github.com/morgverd/sms-server/blob/main/src/modem/handlers.rs"
click node_modem_parsers "https://github.com/morgverd/sms-server/blob/main/src/modem/parsers.rs"
click node_sms_manager "https://github.com/morgverd/sms-server/blob/main/src/sms/mod.rs"
click node_multipart "https://github.com/morgverd/sms-server/blob/main/src/sms/multipart.rs"
click node_encryption "https://github.com/morgverd/sms-server/blob/main/src/sms/encryption.rs"
click node_database "https://github.com/morgverd/sms-server/blob/main/src/sms/database.rs"
click node_http_server "https://github.com/morgverd/sms-server/blob/main/src/http/mod.rs"
click node_http_routes "https://github.com/morgverd/sms-server/blob/main/src/http/routes.rs"
click node_openapi "https://github.com/morgverd/sms-server/blob/main/src/http/openapi.rs"
click node_websocket "https://github.com/morgverd/sms-server/blob/main/src/http/websocket.rs"
click node_webhooks "https://github.com/morgverd/sms-server/blob/main/src/webhooks.rs"

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_entry,node_configuration,node_application,node_http_client,node_ws_client toneBlue
class node_modem_manager,node_modem_worker,node_modem_handlers,node_modem_parsers,node_sqlite toneAmber
class node_sms_manager,node_multipart,node_encryption,node_database,node_webhook_target toneMint
class node_http_server,node_http_routes,node_openapi toneRose
class node_event_broadcaster,node_websocket,node_webhooks,node_operator,node_gsm_modem toneIndigo
```

## Components

### Runtime orchestration

- [CLI entry](https://github.com/morgverd/sms-server/blob/main/src/main.rs): `src/main.rs`
- [Configuration](https://github.com/morgverd/sms-server/blob/main/src/config.rs): `src/config.rs`
- [App orchestration](https://github.com/morgverd/sms-server/blob/main/src/app.rs): `src/app.rs`

### Modem and location

- [Modem manager](https://github.com/morgverd/sms-server/blob/main/src/modem/mod.rs): `src/modem/mod.rs`
- [Serial worker](https://github.com/morgverd/sms-server/blob/main/src/modem/worker.rs): `src/modem/worker.rs`
- [Command handlers](https://github.com/morgverd/sms-server/blob/main/src/modem/handlers.rs): `src/modem/handlers.rs`
- [Response parsers](https://github.com/morgverd/sms-server/blob/main/src/modem/parsers.rs): `src/modem/parsers.rs`

### SMS and persistence

- [SMS manager](https://github.com/morgverd/sms-server/blob/main/src/sms/mod.rs): `src/sms/mod.rs`
- [Multipart assembly](https://github.com/morgverd/sms-server/blob/main/src/sms/multipart.rs): `src/sms/multipart.rs`
- [Message encryption](https://github.com/morgverd/sms-server/blob/main/src/sms/encryption.rs): `src/sms/encryption.rs`
- [SMS database](https://github.com/morgverd/sms-server/blob/main/src/sms/database.rs): `src/sms/database.rs`

### Client interfaces

- [HTTP server](https://github.com/morgverd/sms-server/blob/main/src/http/mod.rs): `src/http/mod.rs`
- [HTTP routes](https://github.com/morgverd/sms-server/blob/main/src/http/routes.rs): `src/http/routes.rs`
- [OpenAPI support](https://github.com/morgverd/sms-server/blob/main/src/http/openapi.rs): `src/http/openapi.rs`

### Event delivery

- [Event broadcaster](https://github.com/morgverd/sms-server/blob/main/src/events.rs): `src/events.rs`
- [WebSocket stream](https://github.com/morgverd/sms-server/blob/main/src/http/websocket.rs): `src/http/websocket.rs`
- [Webhook delivery](https://github.com/morgverd/sms-server/blob/main/src/webhooks.rs): `src/webhooks.rs`

### Other components

- **Operator**
- **HTTP client**
- **WebSocket client**
- **GSM modem**
- **Webhook receiver**
- **SQLite**

## Connections

- Operator → CLI entry: starts gateway
- CLI entry → Configuration: loads settings
- CLI entry → App orchestration: starts runtime
- App orchestration → Configuration: uses settings
- App orchestration → Modem manager: starts modem
- Modem manager → Serial worker: spawns worker
- Serial worker → GSM modem: reads and writes
- Serial worker → Command handlers: dispatches responses
- Command handlers → Response parsers: parses responses
- Serial worker → App orchestration: forwards modem messages
- App orchestration → SMS manager: handles incoming SMS
- SMS manager → Multipart assembly: assembles segments
- SMS manager → SMS database: stores and queries
- SMS database → Message encryption: encrypts message content
- SMS database → SQLite: persists records
- App orchestration → Event broadcaster: broadcasts events
- SMS manager → Event broadcaster: publishes SMS events
- App orchestration → HTTP server: starts server
- HTTP client → HTTP server: calls API
- HTTP server → HTTP routes: dispatches requests
- HTTP routes → SMS manager: sends SMS
- HTTP routes → SMS database: reads message data
- HTTP routes → Modem manager: requests modem data
- HTTP server → OpenAPI support: exposes API schema
- App orchestration → WebSocket stream: provides event stream
- WebSocket client → WebSocket stream: subscribes to events
- Event broadcaster → WebSocket stream: streams events
- App orchestration → Webhook delivery: starts delivery worker
- Event broadcaster → Webhook delivery: dispatches events
- Webhook delivery → Webhook receiver: posts events
