fabbr@site:~/projects/magellan$

magellan

// ~/projects/magellan.rs
let magellan = Project {
    status: Status::Active,
    started: "2026-09-19",
    tags: &["rust", "typescript", "cloudflare", "grafana", "opentofu", "ansible"],
};

Magellan mission patch: an embroidered spiral galaxy, a sensor at its edge, ringed by “Edge-to-cloud sensor pipeline”

An edge-to-cloud sensor pipeline. A device, today a Raspberry Pi reading a solar inverter’s logger over the LAN, keeps its readings in a buffer until the cloud takes them. The cloud stores them and serves them to clients such as Grafana.

The inverter’s own app loses the detail of any stretch when the internet is down. The inverter is the one link in the chain I don’t control: it keeps its own totals and drops the detail, and nothing I write changes that. So the Pi reads it over the LAN, keeps polling while the internet is down, and uploads the backlog once the link returns. It has run nonstop since 2026-09-25, through several revisions of its code.

Pieces

pollcontractinverterdevicebuffer onflashingestworkerR2 archiveD1 readingsAPI workerGrafana

ls ~/projects/magellan/

activecloudTwo Cloudflare Workers over D1 and R2. One takes the readings magellan-device uploads, the other serves them to Grafana.#typescript #cloudflare #d1 #r2
activecontractThe seam between magellan-device and magellan-cloud, and the only thing the two repositories share.#typescript #zod #openapi
activedeviceA Rust binary on a Raspberry Pi. It reads a solar inverter over the LAN and keeps every reading while the internet is down.#rust #tokio #modbus
activegrafanaThe client that reads Magellan back. Three dashboards and an alert per device, provisioned from files, over the cloud's read API.#grafana #infinity #ansible
activeinfraOpenTofu and Ansible run Magellan's hosts. A Raspberry Pi 2 B reads the inverter, and an Oracle VM serves Grafana behind Cloudflare.#opentofu #ansible #grafana #oracle-cloud

magellan-device, magellan-cloud and the contract between them are the software. magellan-infra and Grafana are what run and read it, and they’re the two pieces that have to know the whole project: infra deploys magellan-device’s binary, provisions both hosts and builds Grafana’s dashboards, and Grafana, as the client, has to know the cloud’s contract and what each metric means.

The path of a reading

  1. Poll. magellan-device reads each source on its own cadence; today that’s the inverter, over the LAN, every five minutes in daylight. One poll is one reading: a timestamp and the source’s values, each an integer with a declared decimal exponent.
  2. Buffer. Readings gather into a batch, and the batch is written to flash before anything leaves the board, so a reboot or a power cut loses nothing already queued.
  3. Upload. The binary sends the oldest batch first, and the cloud’s answer decides what happens next: on a commit the batch leaves the buffer; while the internet is down or the cloud declines, the binary backs off and tries again, and the buffer holds up to a week of batches.
  4. Store. The ingest-worker archives the raw batch to R2, then commits its readings to D1 in one write. A batch that arrives twice collides with the first copy row by row, so it isn’t stored twice; that’s the design, and I haven’t yet seen a replay collide.
  5. Read. The api-worker serves series, latest values and device health, and Grafana reads them into its dashboards and its alert.

How it’s built

What a source is lives on the device. A device describes its sources and metrics in a manifest, and the cloud stores readings by what that manifest declares, so a new kind of source is work on the device side, and the cloud serves any of them the same way. The cloud was still redeployed several times since 2026-09-25, for changes to the contract and its tooling, and readings kept arriving through every deploy.

magellan-device and magellan-cloud are built, tested and deployed apart, and the contract is all they share. Until it reached 1.0.0 on 2026-09-30, I designed each change on both sides and deployed them together; since then, a breaking change means a new major version. On 2026-09-25 I also decided the project would be headless, a proxy between devices and whatever reads them: the cloud has no UI, and Grafana is one client of the read API, which a script or another dashboard could read the same way.

Both code repositories follow their own adaptation of TigerStyle, with the goals in a different order: safety, then performance, then developer experience in magellan-device; a correct record, then cost, then developer experience in the cloud. What they share is that everything has a stated bound and a programmer error fails loudly: it crashes the binary on the device, and fails the request in the cloud. The device and cloud pages say where each one departs from TigerStyle.

Scope

Magellan grew by the rule written into each of its repositories: defer building until it’s needed, and revise decisions as issues surface. I didn’t start from a generic design. At first I only knew I wanted to build something on Cloudflare with the Raspberry Pi 2 B I had, and each piece was built as I discovered what it needed, tied to what I had at hand. The exceptions were what is expensive to reverse, the contract and what gets written to D1 and R2, which were decided before the code that uses them.

Even so, I kept the interfaces forward looking: the source seam in magellan-device, the contract and the read API name no inverter, and the Sofar driver is only the first one written behind that seam. So nothing locks Magellan to my setup; it just hasn’t outgrown its first confines yet. The next piece, magellan-node, is meant to bring in other sources that speak Modbus TCP, starting with an ESP32, which could be reading almost anything.

While building it, I cut Magellan down to what matters to me and what I do best: the backend, from a register on the wire to a row in the store. Everything else is off the shelf, and each piece’s page says where its cut happened.

What’s next

Three things wait. magellan-device can already read a second kind of source, an ESP32 node on the LAN, but the node itself isn’t started. In the cloud, the jobs-worker waits until computing rollups as they’re read gets too slow, and the rebuild of D1 from the R2 archive has never had to run.