{"id":33289531,"url":"https://github.com/im-ng/zero","last_synced_at":"2025-11-17T22:03:32.947Z","repository":{"id":324519787,"uuid":"1097490466","full_name":"im-ng/zero","owner":"im-ng","description":"Simple, opinionated web framework written in Zig","archived":false,"fork":false,"pushed_at":"2025-11-16T10:11:32.000Z","size":681,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-16T12:10:04.579Z","etag":null,"topics":["framework","web","zig","ziglang"],"latest_commit_sha":null,"homepage":"https://im-ng.github.io/zero-docs/","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":null,"dco":null,"cla":null}},"created_at":"2025-11-16T09:31:50.000Z","updated_at":"2025-11-16T10:12:37.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":1,"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":284964283,"owners_count":27091965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"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":["framework","web","zig","ziglang"],"created_at":"2025-11-17T22:01:37.445Z","updated_at":"2025-11-17T22:03:32.938Z","avatar_url":"https://github.com/im-ng.png","language":"Zig","readme":"![zero](./static/zero-fmk.png)\n\n`zero` is a strongly opinionated `Zig` web framework 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![mascot](./static/iguanax128.png)\n\n### What is available? \n\nCheck [feature parity](./feature_parity.md) file to know more upcoming and missing things.\n\n### Pre-requisite \n\n```bash\n❯ zig version\n0.15.1\n```\n\n### How to get started?\n\n[zero-docs](https://im-ng.github.io/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 services and solutions.\n\n- [Basic](https://im-ng.github.io/zero-docs/hello-zero.html)\n- [Authentications](https://im-ng.github.io/zero-docs/authentication.html)\n- [CRUD Operations](https://im-ng.github.io/zero-docs/htmx-crud.html)\n- [Scheduler](https://im-ng.github.io/zero-docs/cronz.html)\n- [Websockets](https://im-ng.github.io/zero-docs/websocket.html)\n- [OnStartup](https://im-ng.github.io/zero-docs/caching.html)\n- [Pub/Sub](https://im-ng.github.io/zero-docs/message-queue-publisher.html)\n- [Data Migrations](https://im-ng.github.io/zero-docs/migrations.html)\n\n### Installation\n\nAdd zero to your build.zig.zon:\n\n```\nzig fetch --save https://github.com/im-ng/zero/archive/refs/heads/main.zip\n```\n\n### Usage\n\n0. Create a new zero fmk application\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\n1. Update dependency to load `zero` module\n\n```zig\nconst target = b.standardTargetOptions(.{});\nconst optimize = b.standardOptimizeOption(.{});\n\nconst zero = b.dependency(\"zero\", .{});\n\nconst exe = b.addExecutable(.{\n    .name = \"basic\",\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\"));\n\nb.installArtifact(exe);\n\nconst run_cmd = b.addRunArtifact(exe);\nrun_cmd.step.dependOn(b.getInstallStep());\nif (b.args) |args| {\n    run_cmd.addArgs(args);\n}\n\nconst run_step = b.step(\"basic\", \"Run basic http server\");\nrun_step.dependOn(\u0026run_cmd.step);\n```\n\n2. Add service configrations `configs/.env` to attach to basic web-app\n\n```bash\ncd zero-web-app\nmkdir configs\ntouch configs/.env\n```\n\n```bash\nAPP_ENV=dev\nAPP_NAME=basic-app\nAPP_VERSION=1.0.0\nLOG_LEVEL=debug\n\n# DB_HOST=localhost\n# DB_USER=user1\n# DB_PASSWORD=password1\n# DB_NAME=demo\n# DB_PORT=5432\n# DB_DIALECT=postgres\n\n# REDIS_HOST=127.0.0.1\n# REDIS_PORT=6379\n# REDIS_USER=redis\n# REDIS_PASSWORD=password\n# REDIS_DB=0\n```\n\n2. Start writing your first zero web-app to serve requests\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    // create zero App\n    // internally it loads container with db, logs, metrics\n    const app = try App.new(allocator);\n\n    // register routes on app\n    try app.get(\"/json\", jsonResponse);\n\n    // register route to handle db queries\n    // try app.get(\"/user\", dbResponse);\n\n    // register route to handle redis queries\n    // try app.get(\"/redis\", redisResponse);\n\n    // try app.addHttpService(\"auth-service\", \"http://external-service:8081\");\n\n    // try app.get(\"/status\", serviceStatus);\n\n    // start the server by invoking run\n    try app.run();\n}\n\npub fn jsonResponse(ctx: *Context) !void {\n    try ctx.json(.{ .msg = \"hello json!\" });\n}\n\npub fn dbResponse(ctx: *Context) !void {\n    const User = struct {\n        id: i32,\n        name: []const u8,\n    };\n\n    var row = try ctx.SQL.row(ctx.allocator, \"select id, name from users limit 1\", .{}) orelse unreachable;\n    defer row.deinit() catch {};\n\n    const user = try row.to(User, .{});\n    try ctx.json(user);\n}\n\npub fn redisResponse(ctx: *Context) !void {\n    const reply = try ctx.Cache.sendAlloc([]u8, ctx.allocator, .{ \"GET\", \"msg\" });\n    defer ctx.allocator.free(reply);\n\n    try ctx.json(reply);\n}\n\nconst RemoteSvcResponse = struct {\n    msg: []u8,\n};\n\nfn serviceStatus(ctx: *Context) !void {\n    const service = ctx.GetService(\"auth-service\");\n\n    if (service) |basicSvc| {\n        const response = try basicSvc.Get(RemoteSvcResponse, \"/keys\", null, null);\n\n        try ctx.json(response);\n    }\n}\n```\n\n3. Run your new web app.\n\n```\n❯ zig build basic-web-app\n❯ zig build basic\n INFO [03:23:39] Loaded config from file: ./configs/.env\n INFO [03:23:39] config overriden from: ./configs/.dev.env\n INFO [03:23:39] generating database connection string for postgres\n INFO [03:23:39] connected to user1 user to demo database at 'localhost:5432'\n INFO [03:23:39] connecting to redis at '127.0.0.1:6379' on database 0\n INFO [03:23:39] ping status PONG\n INFO [03:23:39] connected to redis at '127.0.0.1:6379' on database 0\n INFO [03:23:39] container is being created\n INFO [03:23:39] basic-web-app app pid 181443\n INFO [03:23:39] warming up the cache entries\n INFO [03:23:41] cache prepared\n INFO [03:23:41] registered static files from directory ./static\n INFO [03:23:41] Starting server on port: 8080\n INFO [03:23:42] 0199d969-d541-7000-b7e6-8f6cc9c93ed4    200 0ms .GET /json\n INFO [03:23:43] 0199d96a-00ed-7000-994d-839cc86b1fdb    200 0ms .GET /metrics\n INFO [03:23:44] 0199d96a-1f88-7000-9dd4-4ed394ef5a68    200 0ms .GET /index.html\n INFO [03:23:44] 0199d96b-0873-7000-b391-28f26e5d963d    200 0ms .GET /test.txt\n INFO [03:23:45] 0199d96b-1412-7000-9eaf-f4f88888053e    200 0ms .GET /\n INFO [05:05:37] 019a149b-abca-7000-b307-fc04282cc334    200 1ms GET http://external-service:8081/json\n INFO [05:05:37] 019a149b-abc9-7000-ae1e-38847fb79210    200 1ms GET /status\n```\n\n### Simple Benchmark\n\nRunning the [zero-basic](./examples/zero-basic/) example with none as `log_level` to preview the framework baseline, but typically we don't use `none` in development environment :)\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### Attributions\n\nRefer to [Attribution](./attribution.md) file more details.\n\n### 📄 License\n\nThis project is licensed under the Apache License - see the LICENSE file for details.\n","funding_links":[],"categories":["Network \u0026 Web"],"sub_categories":["Web Framework"],"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"}