# SA1 architecture (detail) :id=top

------

> _Doc Ver:_ 1.2  
_App Ver:_ 2.6.6.53  
_Date:_ 09/14/2026

------

This page is the **field architecture** for SA1 2.x. Summary: [Architecture](architecture.md). It is not SA2 `architecture_v2` (no EMQX / Influx / `sa_run`).

SA1 and SA2 are **mutually exclusive** (UDP **8190** and 7090 / 7094 / 80 / 8080 / 81).

------

## 1. Data and control :id=flow

<img src="_images/architecture-flow.png" alt="SA1 flow" width="100%">

- The browser talks **only HTTP** to sa-web (including `/ws`).
- sa-web translates old page commands through `hostcmd` into typed SCPI on **127.0.0.1:7090**.
- `:CMD?` shell and `*CHS!` / `*CHW!` stay denied.
- Ops programs use `/api/info`, `/api/ops/health`, `/api/ops/action`, and the SCPI whitelist (`tcpclient.php`). They do **not** open 7090 on the LAN.
- Optional Modbus TCP **1502** is **inside sa-di** (off until Addon → Modbus Configure). Masters poll FC03 on the LAN; this is not a sa-web HTTP API. [Modbus TCP slave](modbus_tcp_slave.md).
- On-disk save may use SA2 v1.7 (`DS_SAVE_PROTO`). Live UDP **8190** stays original. [Save protocol and integration](data-save-proto.md).

HTTP ops JSON: [API §8](api.md).

------

## 2. Init :id=init

| Platform | How SA1 stays up |
|----------|------------------|
| Debian systemd | `sa-di.service` + `sa-web.service` + `csdfu.service` (user `debian`) |
| BusyBox / armv7l | `/etc/init.d/sa1` → `sa1-supervise` (**not** 3.x `sa_run`) |

Start: `sudo systemctl start sa-di sa-web csdfu`. Do not `killall -9`. Do not start a second `sa-di`.

<img src="_images/architecture-runtime.png" alt="runtime tree" width="100%">

`persist/conf` is site config (sensors, users, `sa.conf` IDN/SN). Upgrades keep persist; they do not ship a second copy of the upgrader inside the business tar.

------

## 3. Package vs ops :id=bins

Business tar `bin/`:

- daemons: `sa-di`, `sa-web`
- CLI: `sa-file`, `sa-doctor`, `sa-cli`, `sa-mcp`
- BusyBox helper: `sa1-supervise`

Always outside the tar: `/usr/local/bin/sa1-upgrader`.

------

## 4. HTTP surface (sa-web) :id=http

| Path | Use |
|------|-----|
| `/login` | Factory users in `web-users.json` (default `temppwd`, public) |
| `/` and `/m/*` | Field UI |
| `/help/` | This Docsify Handbook |
| `/ws` | Spectrum / live (auth) |
| `/api/info` | Public name, IDN, dotted `2.6.x` |
| `/api/ops/health` | Signed-in checkup JSON |
| `/api/ops/action` | Operator `reload` / `time` / `upgrade` with `confirm:true` |

JSON login returns `token`; `Authorization: Bearer` equals the session cookie.

------

## 5. What SA1 is not :id=not

| SA2 / 3.x | SA1 |
|-----------|-----|
| `sa_daq` / `sa_daq_c` | `sa-di` |
| `sa_web` embed + MQTT | `sa-web` HTTP/WS only |
| `sa_run` | systemd or `sa1-supervise` |
| `sa_doctor` / `sa_tui` / `sa_mcp` / `sax` | `sa-doctor` / `sa-cli` / `sa-mcp` (no TUI, no sax) |
| cluster `sa_control` :8090 | not present |

Pointing SA2 `sa_doctor` at SA1 is wrong. Pointing SA1 `sa-doctor` at a machine still running SA2 fails the mutex check.

------

## 6. Related pages :id=see

- [Architecture (summary)](architecture.md)
- [Start, check, upgrade](operate.md)
- [Ops tools](ops.md) · [sa-doctor](sa-doctor.md) · [sa-cli](sa-cli.md) · [sa-mcp](sa-mcp.md)
- [Install](install.md) · [Upgrade](upgrade.md) · [API](api.md) · [Modbus TCP slave](modbus_tcp_slave.md)

------

### [Top](#top)
