FastAPI relay setup

Run the Python relay that polls upstream Arduino JSON and exposes a stable HTTPS endpoint.

A small FastAPI service on a home server or VPS can poll the Arduino over HTTP on the LAN, then expose a stable HTTPS URL to the internet. That keeps TLS and authentication off the microcontroller while preserving the JSON your dashboard already understands.

Minimal architecture

  1. Scheduler or on-demand fetch hits http://arduino.local/... on the LAN.
  2. FastAPI route returns the latest cached body with correct Content-Type.
  3. Reverse proxy (Caddy, nginx) terminates TLS on a public hostname.

Configuration tips

  • Set reasonable timeouts—garage uplink is slower than datacenter RTT.
  • Log upstream errors separately from client 404s.
  • Version the relay when JSON schema changes.

Caching layer

Add Redis cache so Cloudflare Workers and the Astro site do not hammer your home IP on every page view. Security: relay security.