How it works
System architecture
Tantalum keeps privileged operations in Electron main, exposes a narrow IPC surface
through preload, and lets the React renderer focus purely on user interface presentation.
Desktop process split
main.js owns file system access, Arduino CLI processes, serial ports, Appwrite API
calls, Git CLI operations, cloud sync, toolchain locks, notifications, and agent orchestration. The
renderer communicates through explicit preload APIs such as toolchain.compile,
toolchain.detectLocalBoards, git.getStatus, and
toolchain.restoreBoardCodeSnapshot.
Board detection pipeline
src/services/localBoardService.js merges arduino-cli board list JSON with
serialport results, normalizes physical ports, scores confidence, probes ESP chips
with esptool chip_id, then optionally calls the board-detection function for an
AI-assisted FQBN suggestion.
Runtime build injection
arduinoHandler.js creates a temporary sketch, wraps user setup() and loop(),
injects runtime macros, copies TantalumCloudRuntime.h, installs required libraries,
and verifies source markers are still present in compiled artifacts before upload.
Source snapshot recovery
Before upload, source files are zipped with tantalum-source-manifest.json. The build
embeds TANTALUM_SOURCE_SNAPSHOT_V1::<markerId>::<checksum>::END.
View Code reads firmware, finds that marker, downloads the matching snapshot, verifies
the checksum, validates identity, and restores files.
Latest two snapshots
Marker documents start as pending. After a successful flash, the new marker becomes
current, the previous current is demoted to previous, and older documents in the
same retention group are pruned.
OTA command path
board-admin updates desired firmware state and can publish an HMAC-signed MQTT
command. device-gateway validates board tokens, returns signed OTA commands, records
heartbeats, and accepts OTA result telemetry.
Cloud sync
cloudSyncService scans with .tantalumignore, copies allowed files into a shadow
repo, commits, rebases against Gitea, pushes, and applies remote tracked files back
into the Project Space. Existing Git projects are scanned read-only.
Direct Git support
Built-in source control uses the active workspace repository rather than the cloud-sync
shadow repo. IPC handlers wrap local Git commands for status, diffs, commits, remotes,
branches, history, initialization, publishing, and safe-directory repair.
AI gateway
agent-gateway resolves managed or custom OpenAI-compatible credentials, validates
public HTTPS base URLs, applies output policy, retries around provider parameter
incompatibilities, debits credits, and writes usage ledger entries.