agentleFS
sparcklessparckles/Robyn/llms.txt

Robyn

llms.txt7.4k starsChanged 17 months agoBSD-2-ClauseView on GitHub

Robyn is a high-performance, community-driven, and innovator-friendly async web framework for Python with a Rust runtime. It combines Python's ease of use with Rust's performance.

  • Installs packages

We split this llms.txt into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Middlewares: Before/after request middlewares

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 3,225 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
llms.txt
# Robyn

> Robyn is a high-performance, community-driven, and innovator-friendly async web framework for Python with a Rust runtime. It combines Python's ease of use with Rust's performance.

## Quick Facts

- Version: 0.79.0
- Python: >= 3.10
- License: BSD 2.0
- Repository: https://github.com/sparckles/robyn
- Documentation: https://robyn.tech/documentation
- Discord: https://discord.gg/rkERZ5eNU8

## Installation

```bash
pip install robyn
```

## Basic Usage

```python
from robyn import Robyn

app = Robyn(__file__)

@app.get("/")
async def index(request):
    return "Hello, World!"

app.start(port=8080)
```

## Key Features

- **Rust Runtime**: Core server written in Rust using actix-web for high performance
- **Async/Sync Support**: Both async and sync route handlers supported
- **Multi-Process Scaling**: Built-in multiprocess execution via `--processes` and `--workers`
- **WebSockets**: Native WebSocket support
- **Middlewares**: Before/after request middlewares
- **Dependency Injection**: Built-in DI system
- **OpenAPI/Swagger**: Automatic OpenAPI documentation generation
- **Hot Reloading**: Development mode with `--dev` flag
- **AI Agents**: Built-in AI agent routing via `robyn.ai`
- **MCP Support**: Model Context Protocol server capabilities via `app.mcp`
- **Templating**: Jinja2 templating support (optional)
- **CORS**: Built-in CORS helper via `ALLOW_CORS()`
- **Authentication**: AuthenticationHandler base class for custom auth
- **Static Files**: Directory serving via `app.serve_directory()`
- **SSE**: Server-Sent Events support via `SSEResponse`
- **Easy Access Parameters**: Typed path/query params with automatic coercion in handler signatures
- **Direct Rust Integration**: Embed Rust code directly in routes

## Project Structure

```
robyn/
├── src/                    # Rust source code
│   ├── lib.rs              # PyO3 module entry point
│   ├── server.rs           # Main HTTP server implementation
│   ├── types/              # Request, Response, Headers, Cookie types
│   ├── routers/            # HTTP, WebSocket, middleware routers
│   ├── executors/          # Route execution handlers
│   └── websockets/         # WebSocket implementation
├── robyn/                  # Python package
│   ├── __init__.py         # Main Robyn and SubRouter classes
│   ├── router.py           # Python router implementation
│   ├── authentication.py   # AuthenticationHandler
│   ├── dependency_injection.py
│   ├── openapi.py          # OpenAPI generation
│   ├── mcp.py              # MCP protocol support
│   ├── ai.py               # AI agent support
│   ├── responses.py        # Response helpers (serve_file, html, SSE)
│   ├── ws.py               # WebSocket class
│   └── robyn.pyi           # Type stubs
├── integration_tests/      # Integration test suite
├── unit_tests/             # Unit test suite
├── docs_src/               # Documentation (Next.js)
├── granian/                # Bundled Granian server (fork)
└── examples/               # Example applications
```

## Core Classes

### Robyn / SubRouter
Main application class and sub-router for modular routes.

```python
from robyn import Robyn, SubRouter

app = Robyn(__file__)
api = SubRouter(__file__, prefix="/api")

@api.get("/users")
def get_users(request):
    return {"users": []}

app.include_router(api)
```

### Request Object
```python
request.method      # HTTP method
request.url         # Url object (scheme, host, path)
request.headers     # Headers dict-like
request.query_params # QueryParams
request.path_params  # Dict of URL params
request.body        # Raw bytes
request.json()      # Parse JSON body
request.form_data   # Multipart form data
request.ip_addr     # Client IP
request.identity    # Identity (if authenticated)
```

### Response Object
```python
from robyn import Response

Response(
    status_code=200,
    headers={"Content-Type": "application/json"},
    description="body content"  # or body bytes
)
```

### Decorators
```python
@app.get("/path")
@app.post("/path")
@app.put("/path")
@app.delete("/path")
@app.patch("/path")
@app.head("/path")
@app.options("/path")

@app.before_request("/path")  # Middleware before
@app.after_request("/path")   # Middleware after

@app.startup_handler         # Server startup
@app.shutdown_handler        # Server shutdown
```

### WebSockets
```python
from robyn import WebSocketDisconnect

@app.websocket("/ws")
async def handler(websocket):
    try:
        while True:
            msg = await websocket.receive_text()
            await websocket.send_text(f"Echo: {msg}")
    except WebSocketDisconnect:
        pass

@handler.on_connect
def on_connect(websocket):
    return "Connected"

@handler.on_close
def on_close(websocket):
    return "Closed"
```

### Easy Access Parameters
Declare typed path and query parameters directly in handler signatures. Works for both HTTP and WebSocket handlers.

```python
from typing import List, Optional

# HTTP: path params + query params with type coercion
@app.get("/items/:id")
async def get_item(id: int, q: str, page: int = 1):
    return {"id": id, "q": q, "page": page}

# Optional, List, and bool params
@app.get("/search")
def search(name: str, tags: List[str], active: bool = False, age: Optional[int] = None):
    return {"name": name, "tags": tags, "active": active, "age": age}

# WebSocket: typed query params on handler and callbacks
@app.websocket("/ws")
async def handler(websocket, room: str = "default", page: int = 1):
    while True:
        msg = await websocket.receive_text()
        await websocket.send_text(f"room={room} page={page} msg={msg}")

@handler.on_connect
def on_connect(websocket, room: str = "default"):
    return f"connected to {room}"
```

### MCP (Model Context Protocol)
```python
@app.mcp.resource("time://current")
def get_time():
    return datetime.now().isoformat()

@app.mcp.tool(name="calc", description="Calculate", input_schema={...})
def calculate(args):
    return eval(args["expression"])

@app.mcp.prompt(name="explain", description="Explain code", arguments=[...])
def explain_prompt(args):
    return f"Please explain: {args['code']}"
```

## CLI Commands

```bash
python app.py                     # Start server
python app.py --dev               # Development mode (hot reload)
python app.py --processes 4       # Multi-process
python app.py --workers 2         # Workers per process
python app.py --log-level DEBUG   # Log level
python app.py --open-browser      # Open browser on start
python app.py --create            # Create new project scaffold
python app.py --docs              # Open documentation
```

## Development Setup

```bash
# Clone
git clone https://github.com/sparckles/robyn.git
cd robyn

# Virtual environment
python3 -m venv .venv && source .venv/bin/activate

# Install tools
pip install pre-commit poetry maturin

# Install dependencies
poetry install --with dev --with test

# Build Rust extension
maturin develop

# Run tests
pytest
```

## Key Dependencies

- **PyO3**: Rust-Python bindings
- **actix-web**: Rust HTTP server (via cookie crate)
- **orjson**: Fast JSON serialization
- **multiprocess**: Multi-process support
- **uvloop**: Fast event loop (non-Windows)
- **watchdog**: File watching for hot reload

## Configuration

Environment variables:
- `ROBYN_HOST`: Server host (default: 127.0.0.1)
- `ROBYN_PORT`: Server port (default: 8080)
- `ROBYN_DEV_MODE`: Enable dev mode
- `ROBYN_BROWSER_OPEN`: Open browser on start
- `ROBYN_CLIENT_TIMEOUT`: Client timeout seconds
- `ROBYN_KEEP_ALIVE_TIMEOUT`: Keep-alive timeout

## Documentation Structure

Main docs at `docs_src/src/pages/documentation/`:
- `api_reference/getting_started.mdx` - Quick start guide
- `api_reference/request_object.mdx` - Request handling
- `api_reference/middlewares.mdx` - Middleware usage
- `api_reference/websockets.mdx` - WebSocket guide
- `api_reference/authentication.mdx` - Auth patterns
- `api_reference/openapi.mdx` - OpenAPI docs
- `api_reference/agents.mdx` - AI agent integration
- `api_reference/mcps.mdx` - MCP server guide
- `example_app/` - Full example application tutorial

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about sparckles/Robyn

The biggest 5 of 55 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 55

Talked about on GitHub, Hacker News and Bluesky (55 times).

On GitHub · 50

45 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.