language

Neutron Zig

Embedded SDK for systems that measure binary size in kilobytes. Zero heap allocations on the hot path, comptime SQL validation, all 14 Nucleus data models — in 12 KB.

Twelve kilobytes. Zero heap. All of Nucleus.

Available
12 KBRelease Binary
0Heap Allocs Hot Path
307Inline Tests
40+Target Architectures

Small enough to ship in firmware.

Most database clients assume you have a megabyte of RAM and a garbage collector. Neutron Zig assumes neither. The whole SDK — HAL, wire protocol, all 14 Nucleus model clients, JWT, compression, SSE — compiles to a 12 KB release binary with zero heap allocations on the hot path. It runs on your server, on your Raspberry Pi Pico, and on your mechanical keyboard.

src/main.zig
const std = @import("std");
const neutron = @import("neutron");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();

    var db = try neutron.connect(gpa.allocator(), .{
        .url = "postgres://localhost/app",
    });
    defer db.deinit();

    // SQL is validated at comptime. This fails to compile if the
    // schema changes and the columns don't match.
    const rows = try db.sql(
        "SELECT id, title FROM articles WHERE views > $1",
        .{1000},
        struct { id: i64, title: []const u8 },
    );
    defer rows.deinit();

    for (rows.items) |row| {
        std.debug.print("{d}: {s}\n", .{ row.id, row.title });
    }
}
Comptime-validated SQL. Zero allocations at runtime.
Four-layer architecture
wire → HAL → protocols → app. Strip the layers you don't need at comptime. A pure KV client without SQL is under 4 KB.
Comptime SQL
SQL strings are parsed at compile time. Return types are inferred from the query. Column drift breaks the build, not production.
Zero heap hot path
All buffers are caller-provided or stack-allocated. The hot path never calls malloc. Allocator is explicit, injected at call sites.
All 14 Nucleus models
SQL, KV, Vector, Graph, Documents, TimeSeries, FTS, Geo, Blob, Streams, Columnar, Datalog, CDC, PubSub — each a comptime-optional module.
JWT + compression + SSE
Auth middleware, gzip compression, and server-sent events are in-tree. Compiled out of your binary if you don't import them.
307 inline tests
Zig's test blocks live next to the code they exercise. Run zig build test and the whole SDK verifies in seconds.

Binary size, at rest.

ReleaseSmall with link-time optimization, stripped. Measured on x86_64-linux. Same ballpark on aarch64, wasm32, and RISC-V.

Binary footprint

KV only
3.9 KB — just Nucleus KV client
KV + SQL
7.2 KB — add comptime SQL
Full SDK
12 KB — all 14 models + JWT + gzip + SSE
Rust client
~2.1 MB — for reference
Go client
~8.4 MB — for reference

What it's for

Firmware that needs to write telemetry straight into Nucleus. Edge devices where every kilobyte matters. CLI tools that want a real database client without shipping a JVM. WASM modules running in a serverless edge. Anything where you'd reach for C but would rather have Zig's safety and comptime.

Why Zig?

Because comptime replaces macros, codegen, and half the reasons you reach for C++. Because the allocator-by-reference convention makes memory explicit instead of implicit. Because there's no hidden control flow — if it allocates, you wrote the allocator. For a database client that has to be small and predictable, it's the right tool.

Part of a bigger system

Stream telemetry from a Zig edge device into the Nucleus streams model. Serve dashboards from Neutron TypeScript. Train models in Neutron Mojo. Orchestrate in Go. Same contract, same database, same source of truth — from a microcontroller to a cluster.