{"id":33289531,"url":"https://github.com/im-ng/zero","last_synced_at":"2026-06-15T17:31:31.621Z","repository":{"id":324519787,"uuid":"1097490466","full_name":"im-ng/zero","owner":"im-ng","description":"Simple and opinionated web framework written in zig","archived":false,"fork":false,"pushed_at":"2026-05-31T05:45:43.000Z","size":2235,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-31T07:13:56.128Z","etag":null,"topics":["api","http","microservices","rest-api","web","webframework","zero","zig","zig-lang","zig-library","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"http://zerofmk.in","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/im-ng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-11-16T09:31:50.000Z","updated_at":"2026-05-31T05:45:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/im-ng/zero","commit_stats":null,"previous_names":["im-ng/zero"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/im-ng/zero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-ng%2Fzero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-ng%2Fzero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-ng%2Fzero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-ng%2Fzero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/im-ng","download_url":"https://codeload.github.com/im-ng/zero/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/im-ng%2Fzero/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34374146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","http","microservices","rest-api","web","webframework","zero","zig","zig-lang","zig-library","zig-package","ziglang"],"created_at":"2025-11-17T22:01:37.445Z","updated_at":"2026-06-15T17:31:31.615Z","avatar_url":"https://github.com/im-ng.png","language":"Zig","funding_links":[],"categories":["Network \u0026 Web"],"sub_categories":["Web Framework"],"readme":"\u003cimg src=\"./static/zero-framework-backdrop.png\"\u003e\n\u003cbr/\u003e\n\u003cp align=\"center\"\u003e\n    \u003ctable\u003e\n    \u003ctr style=\"background-color: #f8f8f8; text-align: center;\"\u003e\n        \u003cth style=\"padding: 12px; border: 1px solid #ddd;\"\u003eDocumentation\u003c/th\u003e\n        \u003cth style=\"padding: 12px; border: 1px solid #ddd;\"\u003eDeepWiki\u003c/th\u003e\n        \u003cth style=\"padding: 12px; border: 1px solid #ddd;\"\u003eCoverage\u003c/th\u003e\n        \u003cth style=\"padding: 12px; border: 1px solid #ddd;\"\u003eBuild Status\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr style=\"text-align: center;\"\u003e\n        \u003ctd style=\"padding: 12px; border: 1px solid #ddd;\"\u003e\u003ca href=\"https://zerofmk.in\"\u003ezerofmk.in\u003c/a\u003e\u003c/td\u003e\n        \u003ctd style=\"padding: 12px; border: 1px solid #ddd;\"\u003e\u003ca href=\"https://deepwiki.com/badge.svg\"\u003e\u003cimg src=\"https://deepwiki.com/badge.svg\" alt=\"Ask DeepWiki\"\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd style=\"padding: 12px; border: 1px solid #ddd;\"\u003e\u003cimg src=\"https://img.shields.io/badge/Coverage-95-green\" alt=\"Coverage\"\u003e\u003c/td\u003e\n        \u003ctd style=\"padding: 12px; border: 1px solid #ddd;\"\u003e\u003ca href=\"https://github.com/im-ng/zero/workflows/CI/badge.svg\"\u003e\u003cimg src=\"https://github.com/im-ng/zero/workflows/CI/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003c/table\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n**Zero** is a strongly opinionated web framework written in Zig, built on top of http.zig that aims for zero allocations and created to make development easier while keeping performance and observability in mind.\n\n**Zero** framework is completely configurable, you may isolate and attach best-in-class built-in solutions as you see fit using the 12 Factor App methodology.\n\n**Zero** framework has useful features like drop-in support for numerous `databases`, `queuing systems`, and external services, as well as `REST`, `authentication`, `logging`, `metrics`, `observability`, and `scheduling`.\n\n### Zero mascot\n\n\u003cp\u003e\n\u003cimg src=\"./static/zero-mascot-1.webp\" alt=\"zero mascot\" width=\"128\"\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Project Structure](#project-structure)\n- [Configuration](#configuration)\n- [Examples](#examples)\n- [Testing](#testing)\n- [Benchmark](#benchmark)\n- [Zig Version Compatibility](#zig-version-compatibility)\n- [Known Gotchas](#known-gotchas)\n- [Attributions](#attributions)\n- [License](#license)\n\n## Features\n\n| Category        | Status | Details                                    |\n| --------------- | ------ | ------------------------------------------ |\n| REST / CRUD     | ✅     | Build standard REST endpoints out-of-box   |\n| Configuration   | ✅     | `.env` with per-environment overrides      |\n| Logging         | ✅     | Structured, UTC timestamps                 |\n| Metrics         | ✅     | App, HTTP, SQL, KV + process/memory stats  |\n| Tracing         | ✅     | TraceID middleware, request-level tracing  |\n| Auth Middleware | ✅     | Basic, API Key, OAuth 2.0                  |\n| CORS            | ✅     | Configurable CORS middleware               |\n| Panic Recovery  | ✅     | Automatic panic recovery                   |\n| Databases       | ✅     | PostgreSQL, SQLite, Redis                  |\n| Pub/Sub         | ✅     | MQTT, Kafka (via librdkafka)               |\n| Migrations      | ✅     | DB migrations + seed on startup            |\n| HTTP Client     | ✅     | Register multiple external services        |\n| Cron Jobs       | ✅     | `* * * * *` + second-level + range support |\n| WebSockets      | ✅     | Built-in WebSocket support                 |\n| Static Files    | ✅     | Serve static assets + Swagger UI           |\n| Health Checks   | ✅     | Liveness + status endpoints                |\n\nSee [feature_parity.md](./feature_parity.md) for the full roadmap and upcoming features.\n\n## Requirements\n\n- **Zig 0.15.1** (tested and production baseline)\n- **librdkafka** — required for Kafka support:\n  ```bash\n  sudo apt install librdkafka-dev   # Linux\n  brew install librdkafka           # macOS\n  ```\n\n## Installation\n\nAdd zero to your project:\n\n```bash\nzig fetch --save https://github.com/im-ng/zero/archive/refs/heads/main.zip\n```\n\n## Quick Start\n\n### 1. Initialize your project\n\n```bash\nmkdir zero-web-app \u0026\u0026 cd zero-web-app\nzig init\nzig fetch --save https://github.com/im-ng/zero/archive/refs/heads/main.zip\n```\n\n### 2. Configure `build.zig`\n\n```zig\nconst zero = b.dependency(\"zero\", .{});\n\nconst exe = b.addExecutable(.{\n    .name = \"myapp\",\n    .root_module = b.createModule(.{\n        .root_source_file = b.path(\"src/main.zig\"),\n        .target = target,\n        .optimize = optimize,\n    }),\n});\n\nexe.root_module.addImport(\"zero\", zero.module(\"zero\"));\nb.installArtifact(exe);\n```\n\n### 3. Create config directory\n\n```bash\nmkdir configs\ntouch configs/.env\n```\n\n### 4. Write your app\n\n```zig\nconst std = @import(\"std\");\nconst zero = @import(\"zero\");\n\nconst App = zero.App;\nconst Context = zero.Context;\n\npub const std_options: std.Options = .{\n    .logFn = zero.logger.custom,\n};\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    const allocator = gpa.allocator();\n\n    const app = try App.new(allocator);\n    try app.get(\"/json\", jsonResponse);\n    try app.run();\n}\n\npub fn jsonResponse(ctx: *Context) !void {\n    try ctx.json(.{ .msg = \"hello from zero!\" });\n}\n```\n\n### 5. Run\n\n```bash\nzig build run\n```\n\n```\n INFO [03:23:39] Loaded config from file: ./configs/.env\n INFO [03:23:39] Starting server on port: 8080\n```\n\nSee [full documentation](https://zerofmk.in/) for detailed guides on authentication, databases, cron jobs, websockets, and more.\n\n## Project Structure\n\n| Directory         | Purpose                                  |\n| ----------------- | ---------------------------------------- |\n| `src/datasource/` | PostgreSQL (`SQL`), Redis (`Cache`)      |\n| `src/pubsub/`     | MQTT and Kafka publishers/subscribers    |\n| `src/cronz/`      | Cron scheduler and job execution         |\n| `src/migration/`  | Database migrations and seeding          |\n| `src/mw/`         | Middleware: auth, tracing, websocket     |\n| `src/service/`    | HTTP client for external services        |\n| `src/http/`       | Error types and HTTP utilities           |\n| `src/zsutil/`     | System utils: memory, CPU, process, host |\n| `src/static/`     | Embedded Swagger UI assets               |\n\nKey entry points:\n\n- `src/zero.zig` — re-exports all public types\n- `src/app.zig` — main `App` struct (`App.new()`, `app.run()`)\n- `src/context.zig` — request context with `.SQL`, `.Cache`, `.GetService()`\n\n## Configuration\n\nZero loads config from `configs/.env` at startup, with per-environment overrides (e.g. `configs/.dev.env` when `APP_ENV=dev`).\n\n```bash\n# Application\nAPP_NAME=myapp\nAPP_VERSION=1.0.0\nAPP_ENV=dev\n\n# Logging\nLOG_LEVEL=debug\n\n# PostgreSQL\n# DB_HOST=localhost\n# DB_USER=user1\n# DB_PASSWORD=password1\n# DB_NAME=mydb\n# DB_PORT=5432\n# DB_DIALECT=postgres\n\n# Redis\n# REDIS_HOST=127.0.0.1\n# REDIS_PORT=6379\n# REDIS_USER=redis\n# REDIS_PASSWORD=password\n# REDIS_DB=0\n# REDIS_TLS_ENABLED=false\n\n# Kafka\n# KAFKA_BROKER=localhost:9092\n\n# MQTT\n# MQTT_HOST=localhost\n# MQTT_PORT=1883\n\n# Authentication\n# AUTH_MODE=Basic\n```\n\nAll keys are commented out by default; features activate only when uncommented. See [config.md](./config.md) for the full list.\n\n## Examples\n\n14 example applications are available in the `examples/` directory:\n\n| Example                 | Description                            |\n| ----------------------- | -------------------------------------- |\n| `zero-basic`            | Minimal HTTP server                    |\n| `zero-auth`             | Authentication (Basic, API Key, OAuth) |\n| `zero-cronz`            | Cron job scheduling                    |\n| `zero-kafka-publisher`  | Kafka message publishing               |\n| `zero-kafka-subscriber` | Kafka message consumption              |\n| `zero-mqtt-publisher`   | MQTT message publishing                |\n| `zero-mqtt-subscriber`  | MQTT message consumption               |\n| `zero-redis`            | Redis cache operations                 |\n| `zero-sqlite`           | SQLite database usage                  |\n| `zero-migration`        | Database migrations                    |\n| `zero-service-client`   | External HTTP service client           |\n| `zero-stream`           | Streaming responses                    |\n| `zero-todo-htmx`        | HTMX-powered CRUD app                  |\n| `zero-websocket`        | WebSocket connections                  |\n\nEach example has its own `build.zig` and `build.zig.zon`.\n\n## Testing\n\n```bash\nzig build test              # run all unit tests (52 tests)\nzig build --release=fast    # release build\nmake clean                  # remove build artifacts\n```\n\n## Benchmark\n\n| Configuration                              | Requests/sec |\n| ------------------------------------------ | ------------ |\n| Metrics + logging + tracing + info logging | ~16,500      |\n| Metrics + logging + tracing                | ~29,800      |\n| Metrics + logging (no tracing)             | ~31,000      |\n| No metrics                                 | ~31,200      |\n\nBaseline (`none` log level): **~83,000 req/s** over 100s with 100 concurrent connections.\n\n```bash\n❯ go-wrk -c 100 -d 100 http://localhost:8080/json\nRunning 100s test @ http://localhost:8080/json\n  100 goroutine(s) running concurrently\n8344879 requests in 1m39.643117619s, 1.39GB read\nRequests/sec:\t\t83747.67\nTransfer/sec:\t\t14.30MB\nOverall Requests/sec:\t83430.16\nOverall Transfer/sec:\t14.24MB\nFastest Request:\t84µs\nAvg Req Time:\t\t1.193ms\nSlowest Request:\t19.669ms\nNumber of Errors:\t0\n10%:\t\t\t124µs\n50%:\t\t\t150µs\n75%:\t\t\t164µs\n99%:\t\t\t175µs\n99.9%:\t\t\t176µs\n99.9999%:\t\t176µs\n99.99999%:\t\t176µs\nstddev:\t\t\t743µs\n```\n\n## Zig Version Compatibility\n\n| Version | Compiles | Tests | Runtime | Notes                    |\n| ------- | -------- | ----- | ------- | ------------------------ |\n| 0.15.1  | ✅       | 52/52 | ✅      | Production baseline      |\n| 0.15.2  | ✅       | 52/52 | ✅      | Production               |\n| 0.16.0  | ❌       | N/A   | N/A     | Build system API changed |\n\n## Known Gotchas\n\n- **`rdkafka`** is linked as a weak system library — builds fail without `librdkafka-dev`\n- **Always `rm -rf .zig-cache zig-out zig-pkg/`** before switching Zig versions\n- `src/cronz/scheduler.zig` and `src/mw/authProvider.zig` use `@import(\"../zero.zig\")` (relative path), not `@import(\"zero\")`\n\n## Attributions\n\nSee [attribution.md](./attribution.md) for details.\n\n## License\n\n[Apache License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-ng%2Fzero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-ng%2Fzero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-ng%2Fzero/lists"}