# fujr/qmodem architecture

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

- Interactive diagram: https://gitdiagram.com/fujr/qmodem
- Repository: https://github.com/fujr/qmodem

## Overview

QModem is an OpenWrt cellular-modem management stack. The documented user workflow is to manage a modem in LuCI, pass control requests through rpcd/ubus to QModem control and dialing, and reach the modem through AT or data-interface layers; status and SMS are additional user-facing workflows. The README documents discovery and several dialing protocols, while the supplied tree also exposes SMS, VoIP, firmware-download, and vendor connection components. Some central QModem and LuCI backend paths are absent from this tree, so those documented subsystems have no asserted source path; source excerpts are partial.

Main entry points: [`application/ubus_at_daemon/src/main.c`](https://github.com/fujr/qmodem/blob/main/application/ubus_at_daemon/src/main.c) (AT port daemon), [`application/qmodem_smsd/src/main.c`](https://github.com/fujr/qmodem/blob/main/application/qmodem_smsd/src/main.c) (SMS service), [`application/tom_modem/src/main.c`](https://github.com/fujr/qmodem/blob/main/application/tom_modem/src/main.c) (AT / SMS client), [`luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/overview.js`](https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/overview.js) (LuCI modem UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Management UI"]
  node_luci["LuCI modem UI<br/>[overview.js]"]
  node_voip_ui["LuCI VoIP UI<br/>[call.js]"]
  node_sms_ui["SMS UI<br/>[sms.js]"]
end

subgraph group_control["Modem control"]
  node_rpc["rpcd / ubus"]
  node_qmodem_core["QModem control and dialer"]
  node_discovery["Modem discovery<br/>[modem_scand.c]"]
  node_atd["AT port daemon<br/>[main.c]"]
  node_tom_modem["AT / SMS client<br/>[main.c]"]
end

subgraph group_connectivity["Connectivity"]
  node_cm["Quectel connection manager<br/>[main.c]"]
  node_drivers["Cellular kernel drivers<br/>[qmi_wwan_q.c]"]
  node_mhi["MHI transport driver<br/>[mhi_main.c]"]
end

subgraph group_services["Modem services"]
  node_smsd["SMS service<br/>[main.c]"]
  node_sms_db[("SMS database<br/>[sms_db.c]")]
  node_forwarder["SMS forwarding<br/>[main.c]"]
  node_voipd["VoIP daemon<br/>[main.c]"]
  node_sipd["SIP service<br/>[sip_control.c]"]
  node_firehose["Firmware downloader<br/>[qfirehose.c]"]
end

node_operator(("Router operator"))
node_modem{{"USB / PCIe modem"}}

node_operator -->|"manages"| node_luci
node_luci -->|"sends requests"| node_rpc
node_rpc -->|"dispatches control"| node_qmodem_core
node_qmodem_core -->|"uses discovery"| node_discovery
node_qmodem_core -->|"AT access"| node_atd
node_tom_modem -->|"ubus AT"| node_atd
node_qmodem_core -->|"starts data sessions"| node_cm
node_cm -->|"uses interfaces"| node_drivers
node_drivers -->|"transfers data"| node_modem
node_mhi -->|"transports data"| node_modem
node_sms_ui -->|"requests SMS"| node_rpc
node_rpc -->|"dispatches SMS"| node_smsd
node_smsd -->|"reads / writes"| node_sms_db
node_smsd -->|"modem operations"| node_tom_modem
node_forwarder -->|"reads modem SMS"| node_tom_modem
node_voip_ui -->|"controls calls"| node_rpc
node_rpc -->|"dispatches calls"| node_voipd
node_voipd -->|"subscribes AT events"| node_atd
node_sipd -->|"uses AT service"| node_atd
node_firehose -->|"downloads firmware"| node_modem

click node_luci "https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/overview.js"
click node_voip_ui "https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-voip/htdocs/luci-static/resources/view/qmodem-voip/call.js"
click node_discovery "https://github.com/fujr/qmodem/blob/main/application/modem_scan/src/modem_scand.c"
click node_atd "https://github.com/fujr/qmodem/blob/main/application/ubus_at_daemon/src/main.c"
click node_tom_modem "https://github.com/fujr/qmodem/blob/main/application/tom_modem/src/main.c"
click node_cm "https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/main.c"
click node_drivers "https://github.com/fujr/qmodem/blob/main/driver/quectel_QMI_WWAN/src/qmi_wwan_q.c"
click node_mhi "https://github.com/fujr/qmodem/blob/main/driver/quectel_MHI/src/core/mhi_main.c"
click node_sms_ui "https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/sms.js"
click node_smsd "https://github.com/fujr/qmodem/blob/main/application/qmodem_smsd/src/main.c"
click node_sms_db "https://github.com/fujr/qmodem/blob/main/application/qmodem_smsd/src/sms_db.c"
click node_forwarder "https://github.com/fujr/qmodem/blob/main/application/sms_forwarder/src/main.c"
click node_voipd "https://github.com/fujr/qmodem/blob/main/application/voipd/src/main.c"
click node_sipd "https://github.com/fujr/qmodem/blob/main/application/qmodem_sipd/src/sip_control.c"
click node_firehose "https://github.com/fujr/qmodem/blob/main/application/qfirehose/src/qfirehose.c"

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_luci,node_voip_ui,node_sms_ui toneBlue
class node_rpc,node_qmodem_core,node_discovery,node_atd,node_tom_modem toneAmber
class node_cm,node_drivers,node_mhi,node_operator toneMint
class node_smsd,node_sms_db,node_forwarder,node_voipd,node_sipd,node_firehose toneRose
class node_modem toneIndigo
```

## Components

### Management UI

- [LuCI modem UI](https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/overview.js): `luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/overview.js`
- [LuCI VoIP UI](https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-voip/htdocs/luci-static/resources/view/qmodem-voip/call.js): `luci/luci-app-qmodem-voip/htdocs/luci-static/resources/view/qmodem-voip/call.js`
- [SMS UI](https://github.com/fujr/qmodem/blob/main/luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/sms.js): `luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/sms.js`

### Modem control

- **rpcd / ubus**
- **QModem control and dialer**
- [Modem discovery](https://github.com/fujr/qmodem/blob/main/application/modem_scan/src/modem_scand.c): `application/modem_scan/src/modem_scand.c`
- [AT port daemon](https://github.com/fujr/qmodem/blob/main/application/ubus_at_daemon/src/main.c): `application/ubus_at_daemon/src/main.c`
- [AT / SMS client](https://github.com/fujr/qmodem/blob/main/application/tom_modem/src/main.c): `application/tom_modem/src/main.c`

### Connectivity

- [Quectel connection manager](https://github.com/fujr/qmodem/blob/main/application/quectel_CM_5G_M/src/main.c): `application/quectel_CM_5G_M/src/main.c`
- [Cellular kernel drivers](https://github.com/fujr/qmodem/blob/main/driver/quectel_QMI_WWAN/src/qmi_wwan_q.c): `driver/quectel_QMI_WWAN/src/qmi_wwan_q.c`
- [MHI transport driver](https://github.com/fujr/qmodem/blob/main/driver/quectel_MHI/src/core/mhi_main.c): `driver/quectel_MHI/src/core/mhi_main.c`

### Modem services

- [SMS service](https://github.com/fujr/qmodem/blob/main/application/qmodem_smsd/src/main.c): `application/qmodem_smsd/src/main.c`
- [SMS database](https://github.com/fujr/qmodem/blob/main/application/qmodem_smsd/src/sms_db.c): `application/qmodem_smsd/src/sms_db.c`
- [SMS forwarding](https://github.com/fujr/qmodem/blob/main/application/sms_forwarder/src/main.c): `application/sms_forwarder/src/main.c`
- [VoIP daemon](https://github.com/fujr/qmodem/blob/main/application/voipd/src/main.c): `application/voipd/src/main.c`
- [SIP service](https://github.com/fujr/qmodem/blob/main/application/qmodem_sipd/src/sip_control.c): `application/qmodem_sipd/src/sip_control.c`
- [Firmware downloader](https://github.com/fujr/qmodem/blob/main/application/qfirehose/src/qfirehose.c): `application/qfirehose/src/qfirehose.c`

### Other components

- **Router operator**
- **USB / PCIe modem**

## Connections

- Router operator → LuCI modem UI: manages
- LuCI modem UI → rpcd / ubus: sends requests
- rpcd / ubus → QModem control and dialer: dispatches control
- QModem control and dialer → Modem discovery: uses discovery
- QModem control and dialer → AT port daemon: AT access
- AT / SMS client → AT port daemon: ubus AT
- QModem control and dialer → Quectel connection manager: starts data sessions
- Quectel connection manager → Cellular kernel drivers: uses interfaces
- Cellular kernel drivers → USB / PCIe modem: transfers data
- MHI transport driver → USB / PCIe modem: transports data
- SMS UI → rpcd / ubus: requests SMS
- rpcd / ubus → SMS service: dispatches SMS
- SMS service → SMS database: reads / writes
- SMS service → AT / SMS client: modem operations
- SMS forwarding → AT / SMS client: reads modem SMS
- LuCI VoIP UI → rpcd / ubus: controls calls
- rpcd / ubus → VoIP daemon: dispatches calls
- VoIP daemon → AT port daemon: subscribes AT events
- SIP service → AT port daemon: uses AT service
- Firmware downloader → USB / PCIe modem: downloads firmware
