Skip to content
Open source · MIT License

The C framework for web

Affordable, productive and versatile platform for creating web resources

HTTP/1.1 WebSocket PostgreSQL
Quick Start

Run the server in a couple of commands

Clone the repository, build the project with the database drivers you need and launch the server with a single command.

bash
git clone https://github.com/fraxer/C-web-framework.git
cd C-web-framework/backend

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
  -DINCLUDE_POSTGRESQL=yes \
  -DINCLUDE_MYSQL=yes \
  -DINCLUDE_REDIS=yes \
  -DINCLUDE_SQLITE=yes
cmake --build . -j$(nproc)

./exec/cpdy -c /path/to/config.json
Route — config.json
{
  "/": {
    "GET": {
      "file": "handlers/libindexpage.so",
      "function": "index"
    }
  }
}
Handler — handlers/indexpage.c
#include "http.h"

void index(httpctx_t* ctx) {
  ctx->response->send_data(
    ctx->response,
    "Hello world!"
  );
}

A handler is just a function — Each route loads a handler from a .so library. Read the request, build the response — nothing else to wire up.

Build & run guide →
Capabilities

Everything you need in one framework

A complete toolkit for modern web services — protocols, databases, security and utilities out of the box.

HTTP/1.1

A complete HTTP/1.1 server and client — routing, virtual hosts, middleware and TLS.

  • Full HTTP/1.1 support
  • Flexible routing with dynamic parameters
  • Virtual hosts with regex domains and IDN support
  • Middleware and filters: gzip, range, chunked, cache control
  • Cookies with secure, httpOnly, sameSite
  • multipart/form-data parsing and file uploads
  • Automatic gzip compression for supported content types
  • Redirects with regular expressions and capture groups
  • Built-in HTTP client: TLS 1.2+, keep-alive pool, redirects
Learn more

WebSocket

Bidirectional real-time channels with broadcasting and named recipient groups.

  • Full WebSocket protocol support
  • Broadcasting system for groups of clients
  • Named channels with recipient filtering
  • Built-in JSON message support
  • Middleware for WebSocket requests
Learn more

Databases

PostgreSQL, MySQL, SQLite and Redis behind one unified API with ORM and migrations.

  • PostgreSQL — native support with prepared statements
  • MySQL — native support with SQL injection protection
  • SQLite — embedded database without a separate server
  • Redis — for caching and sessions
  • ORM models for working with tables
  • Migrations — database schema versioning
  • Query Builder — safe SQL query construction
  • Transactions and connection pool
Learn more

Security

Authentication, sessions, RBAC, rate limiting and modern password hashing.

  • Built-in registration and authorization system
  • Sessions in files, Redis and the database
  • Session secrets protected with AES-256-GCM
  • Password hashing with PBKDF2-HMAC-SHA256
  • Validators for email, passwords and other data
  • RBAC — role-based access control
  • Rate Limiting — DDoS protection
Learn more

Storage & Email

Local and S3 storage plus transactional email with DKIM.

  • Local file storage
  • S3-compatible services
  • CRUD operations on files
  • multipart uploads saved to storage
  • SMTP client for sending email
  • DKIM signatures for sender authentication
  • Email templates
Learn more

Tooling

Template engine, i18n, JSON, JWT, task scheduler and the str_t / HashMap toolkit.

  • Template engine: variables, loops, model integration
  • i18n on gettext: pluralization, language auto-detection, fallback
  • High-performance JSON parser and serialization
  • JWT, UUID, Base64, SHA-1/256
  • Task scheduler: interval, daily, weekly, monthly
  • AES-256-GCM, random number generator
  • str_t with SSO, Array, HashMap/Map, ordered queue
Learn more
Use Cases

What you can build

REST API

High-performance APIs for mobile and web applications

Real-time

Chats, notifications and live updates via WebSocket

Microservices

Microservices and monolithic applications

API Gateway

Request routing and proxying between services

Admin panels

Authentication, RBAC and CRUD operations

File uploads

Local and S3-compatible cloud storage

Email services

Transactional email sending with DKIM

i18n

Multilingual content with gettext and pluralization

Get started

Build fast web services in C

Read the introduction, browse the examples, or open the source on GitHub.

Released under the MIT License.