Zero Web Framework: Introduction!

Hello members!

I’m Ng, a beginner to zig, and I’ve developed a little web framework to help the zig community. It wasn’t much, but I wanted to return a thing or two.

zero is a zig web framework designed to provide inspiration and a clear methodology for writing microservices for Kubernetes deployments.

zero is a highly opinionated framework designed to facilitate development while maintaining observability and performance. It strives for zero allocations and built on top of http.zig

The zero framework is fully customizable; you may use the 12 Factor App technique to isolate and attach best-in-class built-in solutions as you see appropriate.

The zero framework provides practical features like REST, authentication, and drop-in support for many databases, queuing systems, and external services.

Key features:

  • Build REST Standard out-of-box
  • Configuration Management
  • Well defined logging for better readability
  • Schedule tasks for one or more repetition
  • Track and expose application metrics for observability
  • Trace application performance with ease
  • In-built Auth middlewares
  • Http Service Client
  • Pub/Sub
  • Database seed and migrations
  • Cron Jobs
  • Websockets
  • Liveliness check

zero-docs covers all examples and documentations of the zero framework. Take a deep dive into the framework, usage, and outcomes of each built-in service and solution.

I’d really appreciate all the feedback on this work to create a viable and better framework for the community.

13 Likes

Can’t say anything about the code yet,
but the documentation is impressive!!!

I’m “struggling” with my own site right now, so I can appreciate the titanic effort.

Respect

4 Likes

Hello members,

I am excited to announce the release of the zero framework 0.5.0, expanding the features of the framework.

The zero framework wires REST, SQL, NoSQL, cache, pub/sub, auth, GraphQL, Protobuf, search, and metrics and tracing into one static binary, configured almost entirely through .env

Now zero framework targets Zig 0.16, moving to the new Module-based build/link API, adopting the new std.Io model, middleware updates, and observability capabilities

Data source updates

  • New unified, type-erased data source interface.
  • New data source supports: Cassandra, InfluxDB, Solr, DuckDB, SQLite, and S3-backed file store.
  • Type-erased KV store interface, supports Redis, NATS-JS, SQLite, and in-memory

PubSub

  • Additional support for Redis and NATS through a type-erased data source interface

HTTP

  • Now extended the server to handle the multi-source inbound requests
  • Experimental Protobuf-over-HTTP (incl. CRUD example).
  • Experimental GraphQL with CRUD operations and custom metrics port
  • Outbound HTTP client: auth (Basic / APIKey / OAuth), circuit breaker, retries, and x-correlation-id propagated to downstream calls.
  • Rate limiting based on fixed windows, IP, or custom headers (inbound and outbound).

Security

  • Configuration-based RBAC middleware through .env or JSON format

Observability

  • JSON structured logging (with local/custom time zone support)
  • Custom and per-endpoint metrics.
  • a benchmark harness for capturing throughput, latency percentiles, and RSS/leak signals.

Stability and memory

  • Decoupled httpz request-body buffer pool from request.max_body_size and the developer can customize with ZERO_HTTP_LARGE_BUFFER_SIZE.
  • To address the stability, there are few fixes targeted to the mem leaks on app shutdown on macOS and JSON formatting with allocPrint.

Breaking changes

This release is not backwards compatible with the stable-release branch. As it targets the new std.Io, the existing method signatures and supports are completely different.

Release Information

Transparency note: roughly 50% of the integration/test codes were written using the Hy3 model for this release.

Resubmitting this post again, as the previous post was flagged with AI policy, made the correction to look better.

3 Likes

I’m slightly confused about this. You say that you are using std.Io, but I see that your code is spawning many threads using std.Thread. Plus, you are using Karl’s http.zig, which also depends on std.Io.Threaded, even thought it accepts io parameter. So it’s not the best idea to advertise std.Io compatibility, as people might be thinking they can have it working with any std.Io implementation. You should probably mention that the io parameter needs to be std.Io.Threaded.

1 Like