Zuno Architecture
π§ Zuno Architecture
Section titled βπ§ Zuno ArchitectureβZuno is designed as a modern, modular, high-performance HTTP framework for C++20. Its architecture is built around a middleware pipeline, an efficient routing engine, and direct integration with Asio for asynchronous operations.
π§© Core Components
Section titled βπ§© Core Componentsβ[HTTP Client] β βΌβββββββββββββββββ Server β ββ TCP socket (Asio)ββββββββββββββββ β βΌβββββββββββββββββββββββββββββββ Middleware Pipeline βββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββ Routing Engine βββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββ Route Handler βββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββ HTTP Response βββββββββββββββββββββββββββββββ
βοΈ 1. HTTP Server (Asio)
Section titled ββοΈ 1. HTTP Server (Asio)βZuno uses Asio as its networking backend to handle TCP connections efficiently and asynchronously. Each incoming connection is processed through an event loop without blocking threads.
π§΅ 2. Middleware Pipeline
Section titled βπ§΅ 2. Middleware PipelineβEvery request flows through a chain of middleware before reaching the final handler. This enables:
- Authentication
- Logging
- CORS
- Compression
- Rate limiting
Example:
app.use(logging());app.use(cors());app.use(rateLimit({ .max = 10 }));
Each middleware receives (Request&, Response&, Next)
and can choose to continue or short-circuit the flow.
π§ 3. Routing Engine
Section titled βπ§ 3. Routing EngineβZuno implements a hierarchical router that supports:
- Static routes (
/about
) - Dynamic routes (
/users/:id
) - Query parameters (
?q=value
) - Modular route grouping
The router maps the URL to an efficient match tree and dispatches to the appropriate handler.
π§ 4. Route Handlers
Section titled βπ§ 4. Route HandlersβHandlers are lambdas that implement your business logic:
app.get("/hello/:name", [](Request& req, Response& res) {res.send("Hello, " + req.params["name"]);});
They can return plain text, JSON, files, or any custom response.
π€ 5. HTTP Response
Section titled βπ€ 5. HTTP ResponseβZuno provides a fluent API for building responses:
res.status(200).json({{ "message", "Success" }});
You can also send files, redirects, or custom headers.
π§± Internal Modularity
Section titled βπ§± Internal ModularityβZuno is organized into reusable modules:
Module | Purpose |
---|---|
core/ | Server, routing, base types |
extensions/ | Optional middleware (CORS, TLS, etc.) |
examples/ | Ready-to-run use cases |
zuno/zuno.hpp | Unified entry point for users |
π Secure by Design
Section titled βπ Secure by DesignβZuno promotes secure defaults:
- Native TLS support
- Authentication middleware
- Configurable rate limiting
- Safe headers by default
π§ Whatβs Next?
Section titled βπ§ Whatβs Next?β- Learn how to write custom middleware
- Explore TLS & security
- Review the recommended project structure
Zuno combines simplicity and power in a modern architectureβbuilt for developers who want full control without sacrificing productivity.