Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 18 additions & 21 deletions docs_src/src/pages/documentation/en/api_reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,43 @@ Once upon a time in the city of Gotham, there was a powerful superhero named Rob

One day, Batman approached Robyn for help with building a web application. Batman had heard about Robyn's powerful features and wanted to harness them to create a remarkable application. Batman was looking for an ally and in Robyn, he found the best one!


## Installing Robyn


Robyn is a Python library that you can install using `pip` or `conda`

<CodeGroup title="installation">

```bash {{ title: 'pip' }}
pip install robyn
```
```bash {{ title: 'pip' }}
pip install robyn
```

```bash {{ title: 'conda' }}
conda install robyn -c conda-forge
```

```bash {{ title: 'conda' }}
conda install robyn -c conda-forge
```
</CodeGroup>

While there are other more extensions of Robyn like
Robyn also ships optional extras for templating, Pydantic validation, project scaffolding with `robyn-config`, and a combined `all` bundle:

<CodeGroup title="installation">

```bash {{ title: 'pip' }}
pip install "robyn[templating]"
```

```bash {{ title: 'conda' }}
conda install "robyn[templating]" -c conda-forge
```
</CodeGroup>
```bash {{ title: 'pip' }}
pip install "robyn[templating]"
pip install "robyn[pydantic]"
pip install "robyn[robyn-config]"
pip install "robyn[all]"
```

```bash {{ title: 'conda' }}
conda install "robyn[templating]" -c conda-forge
```

</CodeGroup>

It is recommended to install the base package first and then install the extensions as needed.

## What's next?

Now, we can start using Robyn to build our application.


- [Getting Started](/documentation/en/api_reference/getting_started)



61 changes: 32 additions & 29 deletions docs_src/src/pages/documentation/en/api_reference/testing.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const description =
'On this page, we'll explore Robyn\'s built-in TestClient for fast, in-process unit testing without starting a server.'
'On this page, we\'ll explore Robyn\'s built-in TestClient for fast, in-process unit testing without starting a server.'

## Testing

Expand Down Expand Up @@ -35,6 +35,7 @@ Import `TestClient` from `robyn.testing`, pass your app to it, and start making
assert response.text == "Hello, World!"
```
</CodeGroup>

</Col>
</Row>

Expand All @@ -45,13 +46,13 @@ Every request method returns a `TestResponse` with the following properties:
<Row>
<Col>

| Property | Type | Description |
| --- | --- | --- |
| `status_code` | `int` | HTTP status code |
| `text` | `str` | Response body as a decoded string |
| `content` | `bytes` | Raw response body |
| `headers` | `Headers` | Response headers |
| `ok` | `bool` | `True` if status is 2xx |
| Property | Type | Description |
| ------------- | --------- | --------------------------------- |
| `status_code` | `int` | HTTP status code |
| `text` | `str` | Response body as a decoded string |
| `content` | `bytes` | Raw response body |
| `headers` | `Headers` | Response headers |
| `ok` | `bool` | `True` if status is 2xx |

`TestResponse` also has a `.json()` method that parses the body as JSON.

Expand All @@ -73,6 +74,7 @@ Every request method returns a `TestResponse` with the following properties:
assert data[0]["name"] == "Batman"
```
</CodeGroup>

</Col>
</Row>

Expand Down Expand Up @@ -100,6 +102,7 @@ Use `json_data` to send JSON payloads — the client automatically sets `Content
assert response.json()["name"] == "Batarang"
```
</CodeGroup>

</Col>
</Row>

Expand All @@ -122,10 +125,10 @@ You can also send raw string or bytes bodies, custom headers, query parameters,
assert response.ok
```
</CodeGroup>

</Col>
</Row>


### Path Parameters

Routes with path parameters work exactly as they do in production. The `TestClient` matches the route pattern and extracts parameters automatically.
Expand All @@ -148,10 +151,10 @@ Path parameters are resolved from the URL and passed to your handler through the
assert response.json()["user_id"] == 42
```
</CodeGroup>

</Col>
</Row>


### Testing Middleware

The `TestClient` replicates the full request pipeline — before middlewares, the handler, global response headers, and after middlewares — in the same order as the Rust runtime.
Expand Down Expand Up @@ -185,10 +188,10 @@ Middlewares that modify the request or response are executed just like in produc
assert response.headers.get("X-Server") == "Robyn"
```
</CodeGroup>

</Col>
</Row>


### Using as a Context Manager

`TestClient` implements the context manager protocol. When used with `with`, the internal event loop is automatically cleaned up:
Expand All @@ -208,10 +211,10 @@ Middlewares that modify the request or response are executed just like in produc
# event loop is closed here
```
</CodeGroup>

</Col>
</Row>


### Running Tests with pytest

Since `TestClient` doesn't start a server, tests run as fast as regular unit tests. Use `pytest` directly — no special plugins or fixtures required.
Expand Down Expand Up @@ -262,6 +265,7 @@ A typical test file:
assert response.status_code == 404
```
</CodeGroup>

</Col>
</Row>

Expand All @@ -271,25 +275,24 @@ Run with:
pytest test_app.py -v
```


### Available Methods

| Method | Signature |
| --- | --- |
| `client.get(path, **kw)` | GET request |
| `client.post(path, json_data=None, **kw)` | POST request |
| `client.put(path, json_data=None, **kw)` | PUT request |
| `client.patch(path, json_data=None, **kw)` | PATCH request |
| `client.delete(path, json_data=None, **kw)` | DELETE request |
| `client.head(path, **kw)` | HEAD request |
| `client.options(path, **kw)` | OPTIONS request |
| Method | Signature |
| ------------------------------------------- | --------------- |
| `client.get(path, **kw)` | GET request |
| `client.post(path, json_data=None, **kw)` | POST request |
| `client.put(path, json_data=None, **kw)` | PUT request |
| `client.patch(path, json_data=None, **kw)` | PATCH request |
| `client.delete(path, json_data=None, **kw)` | DELETE request |
| `client.head(path, **kw)` | HEAD request |
| `client.options(path, **kw)` | OPTIONS request |

All methods accept these keyword arguments:

| Argument | Type | Description |
| --- | --- | --- |
| `body` | `str \| bytes` | Raw request body |
| `headers` | `dict` | Request headers |
| `query_params` | `dict` | Query string parameters |
| `form_data` | `dict` | Form data fields |
| `files` | `dict` | File uploads (name → bytes) |
| Argument | Type | Description |
| -------------- | -------------- | --------------------------- |
| `body` | `str \| bytes` | Raw request body |
| `headers` | `dict` | Request headers |
| `query_params` | `dict` | Query string parameters |
| `form_data` | `dict` | Form data fields |
| `files` | `dict` | File uploads (name → bytes) |
166 changes: 166 additions & 0 deletions docs_src/src/pages/documentation/en/plugins.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export const description =
'Robyn plugins, including rate limiting and robyn-config for project scaffolding, admin panels, and observability.'

export const sections = [
{ title: 'Rate Limit Plugin', id: 'rate-limit-plugin' },
{ title: 'Robyn Config', id: 'robyn-config' },
]

## Plugins

Robyn is a versatile and extensible web framework that allows anyone to make plugins over the top of Robyn.
Expand Down Expand Up @@ -34,6 +42,164 @@ In this example, robyn-rate-limits is used to enforce a rate limit of 3 requests

The plugin integrates seamlessly with the Robyn web framework, enhancing the security and stability of your application by preventing excessive requests from a single client.

### Robyn Config

- Description: A CLI companion for bootstrapping and maintaining production-ready Robyn applications. It can create new projects, add business entities, scaffold an admin panel, and wire an observability stack into an existing app.
- GitHub repository: [robyn-config](https://github.com/Lehsqa/robyn-config)
- Installation:
`python -m pip install robyn-config`

Or as a Robyn optional dependency:
`python -m pip install robyn[robyn-config]`

- Python support: Python 3.11 or newer.

#### Create a Project

```bash
# DDD + SQLAlchemy with uv dependency locking (default)
robyn-config create my-service --design ddd --orm sqlalchemy ./my-service

# MVC + Tortoise ORM with poetry dependency locking
robyn-config create newsletter --design mvc --orm tortoise --package-manager poetry ./newsletter

# Interactive project setup
robyn-config create -i
```

`robyn-config create` gives you explicit choices for the two main architecture branches:

- **DDD** for domain, application, infrastructure, and presentation layers.
- **MVC** for views, repositories, models, and URL routing.

It also lets you choose the database layer and package manager:

- **SQLAlchemy** or **Tortoise ORM** for persistence.
- **uv** by default, or **poetry** with `--package-manager poetry`.

#### Add Business Logic

Inside a generated project, add a new entity and let `robyn-config` place the files in the correct design-specific layers:

```bash
cd my-service
robyn-config add product
```

This generates the model, repository, route/controller code, and application wiring for the selected architecture. Custom generation paths can be configured in `[tool.robyn-config.add]` inside the generated project's `pyproject.toml`.

#### Add an Admin Panel

```bash
cd my-service
robyn-config adminpanel

# Override the default admin/admin bootstrap credentials
robyn-config adminpanel --username superadmin --password super-secret-password ./my-service
```

The admin panel scaffolding adds an ORM-aware admin module, registers it with the application, discovers available project models, and exposes CRUD views for those models.

<div className="not-prose my-8 grid gap-4 md:grid-cols-2">
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/admin/login.png"
alt="Robyn Config admin login screen"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Admin login
</figcaption>
</figure>
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/admin/home.png"
alt="Robyn Config admin home dashboard"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Admin dashboard
</figcaption>
</figure>
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/admin/model_list.png"
alt="Robyn Config admin model table"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Model listing
</figcaption>
</figure>
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/admin/model_edit.png"
alt="Robyn Config admin model editor"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Model editor
</figcaption>
</figure>
</div>

#### Add Monitoring

```bash
cd my-service
robyn-config monitoring

# Start the application stack and observability stack
docker compose up -d
docker compose -f docker-compose.monitoring.yml up -d
```

The monitoring command adds a `/metrics` endpoint, installs `prometheus-client`, and provisions Docker Compose assets for Grafana Alloy, Loki, Prometheus, and Grafana. Grafana is available at `http://localhost:3000` with dashboards for logs and process metrics.

<div className="not-prose my-8 grid gap-4 md:grid-cols-2">
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/monitoring/logs.png"
alt="Robyn Config Grafana logs dashboard"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Logs dashboard
</figcaption>
</figure>
<figure className="overflow-hidden rounded-lg border border-white/10 bg-zinc-950">
<img
src="/images/robyn-config/monitoring/metrics.png"
alt="Robyn Config Grafana metrics dashboard"
className="w-full"
/>
<figcaption className="px-4 py-3 text-sm text-zinc-400">
Metrics dashboard
</figcaption>
</figure>
</div>

#### Validate Generated Projects

After generating or modifying a project, run the checks that match the generated package manager:

```bash
# uv projects
uv run pytest
uv run ruff check .

# poetry projects
poetry run pytest
poetry run ruff check .
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

For monitoring, confirm the application exposes Prometheus metrics and that Grafana has data:

```bash
curl http://localhost:8000/metrics
curl -I http://localhost:3000
```

## What's next?

After exploring the plugins, Batman wanted to explore the community.So, Robyn pointed him to
Expand Down
Loading
Loading