Skip to content

Hypern Documentation

Welcome to the Hypern documentation! Hypern is an Express.js-style Python web framework powered by Rust (Axum/Tokio) for maximum performance.

Quick Start

from hypern import Hypern

app = Hypern()

@app.get("/")
def home(req, res, ctx):
    res.json({"message": "Hello, World!"})

if __name__ == "__main__":
    app.start(host="0.0.0.0", port=8000)

Documentation

Topic Description
Getting Started Installation and basic setup
Routing Route definitions, parameters, and router groups
Request & Response Request handling and response methods
Middleware Built-in and custom middleware
SSE & Streaming Server-Sent Events and streaming responses
Zero-Downtime Reloads Graceful/hot reloads with health probes
Validation Request validation and schema definition
Dependency Injection Compiled providers and marker-based parameter binding
SQLAlchemy SQLAlchemy engine, session, transaction, and connection lifecycle
Authentication JWT, API keys, and RBAC authorization
WebSocket Real-time WebSocket connections and rooms
Background Tasks Background job processing
Task Scheduling Cron, intervals, retry, and monitoring
Error Handling Exception handling and error responses
File Uploads Multipart file handling
Best Practices Performance tips and patterns
User Guide Comprehensive user guide

Performance Features

Hypern achieves high performance through:

  • Rust Core: The HTTP server, routing, and middleware chain are implemented in Rust using Axum/Tokio
  • Pure Rust JSON: JSON serialization/deserialization using SIMD-optimized parsers
  • Zero-Copy Parsing: Request parsing with minimal memory allocations
  • Thread-Local Arenas: Memory arena allocation for request-scoped allocations
  • Rust Middleware: High-performance middleware (CORS, Rate Limiting, etc.) in pure Rust

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Python Application                        │
│  (Route handlers, Business logic, Middleware callbacks)      │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                    PyO3 Bindings                             │
│  (Request/Response objects, Context, SSE, Tasks)             │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                    Rust Core (Axum/Tokio)                    │
│  - HTTP Server       - Middleware Chain    - JSON Parser     │
│  - Radix Router      - Memory Pools        - SSE Streaming   │
│  - Arena Allocator   - Task Executor       - Pub/Sub          │
└─────────────────────────────────────────────────────────────┘

License

MIT License