csilk Documentation

Version: 0.2.5 | Last updated: 2026-05-29

csilk is a lightweight, high-performance HTTP web framework written in C, inspired by Gin (Golang) and built on top of libuv, llhttp, and cJSON.

Project Architecture Overview

graph TB
    subgraph Application
        H["Business Handlers"]
        APP["csilk_app_t (High-Level API)"]
    end

    subgraph Middleware Layer
        REC["Recovery"]
        LOG["Logger"]
        AUTH["Auth"]
        CORS["CORS"]
        RT["Rate Limit"]
        CSRF["CSRF"]
        ST["Static Files"]
        GZ["Gzip"]
        SSE["SSE"]
        MP["Multipart"]
    end

    subgraph Core Framework
        S["Server (libuv event loop)"]
        R["Router (Radix Tree)"]
        G["Group (prefix routing)"]
        C["Context (req/res lifecycle)"]
        AR["Arena Allocator"]
        WS["WebSocket"]
        CFG["Config (YAML)"]
        RF["Reflection Engine"]
        AI["AI Unified Engine"]
        end

        subgraph Dependencies
        UV["libuv (async I/O)"]
        LL["llhttp (HTTP parser)"]
        JSON["cJSON"]
        YAML["libyaml"]
        Z["zlib"]
        CURL["libcurl"]
        end
        S --> CFG
        S --> UV
        S --> LL
        RF --> JSON
        AI --> CURL
        AI --> JSON
        GZ --> Z
        C --> JSON

    CORS --> C
    RT --> C
    CSRF --> C
    ST --> C
    GZ --> C
    SSE --> C
    MP --> C
    S --> R
    S --> C
    G --> R
    C --> AR
    S --> WS
    S --> CFG
    S --> UV
    S --> LL
    RF --> JSON
    GZ --> Z
    C --> JSON

Key Resources

Document Description
Getting Started Build, install, and run your first server
Architecture High-level architecture and design principles
ARCH Whitepaper Detailed architecture whitepaper
Module Design Deep dives into core module internals: AI, Workflow, Reflection, Context, Router, Middleware, Crypto, Hooks
User Manual Configuration, middleware development, and advanced usage
API Reference Doxygen-generated API documentation
User Manual Configuration, middleware, and advanced usage
API Reference Doxygen-generated API documentation

Quick Start

#include "csilk/csilk.h"

void hello(csilk_ctx_t* c) {
    csilk_string(c, 200, "Hello World!");
}

int main() {
    csilk_router_t* r = csilk_router_new();
    csilk_router_add(r, "GET", "/hello", (csilk_handler_t[]){hello, NULL}, 1);

    csilk_server_t* s = csilk_server_new(r);
    csilk_server_run(s, 8080);

    csilk_router_free(r);
    csilk_server_free(s);
    return 0;
}