Skip to content

What is Runcobo? ​

Runcobo is a batteries-included web framework for Crystal. It ships everything you need to go from a first route to a production deploy — typed input validation, JSON and HTML views, uploads, static files, logging and error handling, plus a toolchain for databases, migrations and SQL code generation.

It's built around one idea: everything about an endpoint lives together — its route, the input it accepts, its logic and its response, side by side in one folder.

src/actions/posts/create_post.cr
crystal
class Posts::CreatePost < Blog::BaseAction
  post "/posts"                              # where it lives

  call do
    input = validate(CreatePostContract)     # what it accepts
    post = store.create_post(author_id: input.author_id, title: input.title)
    render status_code: 201                  # what it returns
  end
end

The route, the accepted input and the logic sit in one class. Its contract and its response template sit right beside it, in the same folder:

  • CreatePostContract (in create_post_contract.cr) declares the fields the endpoint accepts and their types — Request Contracts.
  • render sends create_post.jbuilder, which lists the response fields — Views.
  • store.create_post is a typed method generated from a SQL query — Database Access.
  • Blog::BaseAction is your application's base class for every action — Project Structure.

Core ideas ​

One endpoint, one folder

An action, its contract and its template sit side by side. Run cobo routes to find the code behind any URL.

Typed input at the boundary

The first line of call validates the request. After it, input.title is a String; bad requests get a 422.

Checked by the compiler

Routes, contracts, templates and layouts compile into your binary. A missing template is a build error, not an incident.

A SQL-first ORM

crsql turns the SQL you write into typed methods for PostgreSQL, MySQL or SQLite.

One way to do each thing

One way to read input, one way to render, one way to pass dependencies — so every Runcobo app reads the same.

Explicit wiring

Middleware is a plain array you can read and reorder. Dependencies reach actions through the request context, not globals.

What's in the box ​

AreaWhat you get
RoutingRoutes declared on actions, typed path parameters, custom HTTP methods, route listing
InputRequest contracts for path, query, form and JSON input — types, constraints, nested objects, cross-field rules
UploadsMultipart uploads with size, file and field limits, atomic saving and automatic cleanup
OutputJSON, text, files, redirects, empty responses
ViewsCompile-time Jbuilder (JSON) and Water (HTML) templates, with layouts and partials
ServerRequest IDs, structured logging, error handling, static files, graceful shutdown, TLS, trusted proxies
Database toolingLocal databases for PostgreSQL, MySQL and SQLite, SQL migrations with verified rollbacks, staging/production migration commands
ORMcrsql: typed query methods generated from SQL for PostgreSQL, MySQL and SQLite, with a CI check
ToolingOne CLI, cobo: dev server, console, script runner, project tasks, test runner

Next steps ​

Released under the MIT License.