# Meshtastic Stack

## Overview
Self-hosted Meshtastic monitoring and management stack running on PlausibleDeniability.

Related NOMAD-side bridge note: a separate MeshCore-to-MQTT relay is running on N.O.M.A.D. as Docker container `mctomqtt` (`mctomqtt:latest`), with config bind-mounted from `/etc/mctomqtt`. The package also includes a systemd unit under `/opt/mctomqtt`, but that is not the active runtime on this host.

## Stack Location
`/mnt/docker-ssd/docker/compose/meshtastic/`

## Containers

| Container | Image | Port | Purpose |
|-----------|-------|------|---------|
| meshmonitor | ghcr.io/yeraze/meshmonitor:4.2.0 | 8081→3001 | Main UI + backend |
| meshmonitor (virtual node) | — | 4404 | TCP virtual node server |
| meshmonitor-tileserver | maptiler/tileserver-gl-light | 8082→8080 | Offline map tiles |
| meshmonitor-mqtt-proxy | ghcr.io/ln4cy/mqtt-proxy:master | — | MQTT→TCP bridge |
| meshmonitor-upgrader | docker:latest | — | Auto-upgrade watchdog |

## Architecture
```
Meshtastic Node (10.5.1.172)
        ↓ MQTT
meshmonitor-mqtt-proxy
        ↓ TCP (port 4404)
meshmonitor virtual node server
        ↓
meshmonitor backend
        ↓
PostgreSQL (shared-postgres, db: meshmonitor)
```

## Node Connection
- Node IP: `10.5.1.172`
- Connection type: MQTT via mqtt-proxy (not direct TCP)
- mqtt-proxy connects to meshmonitor's virtual node server on port 4404

## Storage
- Appdata: `/mnt/tank/docker/appdata/meshmonitor/data` → `/data`
- Scripts: `./scripts` → `/data/scripts` (must be pre-created on host)
- Tiles: `./tiles` (gitignored — large .mbtiles files)

## Auto-Upgrade
`AUTO_UPGRADE_ENABLED=true` — meshmonitor checks for new images and triggers self-upgrade.

**Important:** The upgrader mounts the compose directory as `/compose` inside the container. All relative bind mount paths (e.g. `./scripts`) resolve to `/compose/scripts` on the host when the upgrader re-runs compose. Since TrueNAS root filesystem is read-only, these directories must be pre-created:

```bash
mkdir -p /mnt/docker-ssd/docker/compose/meshtastic/scripts
```

## Networks
- `default` (internal stack network)
- `ix-databases_shared-databases` (meshmonitor only)
- `pangolin` (meshmonitor + tileserver)

## Public URL
`https://meshmonitor.paccoco.com`

## Known Warnings
- Node `!dd972536` has a low-entropy public key — this is a device configuration issue, not a meshmonitor bug
- Frequent connect/disconnect cycles in logs are normal when the MQTT proxy reconnects

## Tiles
Map tiles stored in `./tiles/`. Currently includes `zurich_switzerland.mbtiles` (34MB).
Tiles directory is gitignored. To add new tiles, download `.mbtiles` files and place in the `tiles/` directory.

## TODO
- [ ] Document all running meshtastic-map container config
- [ ] Document meshtastic-map-mosquitto and meshtastic-mqtt containers
- [ ] Add healthcheck to meshmonitor container
