Skip to content

About

CyberTrain is a Rails-shaped web application framework written natively for Spinel.

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

CyberTrain

Homepage · Tutorial · Guides · API reference

cybertrain

A Rails-shaped web framework written natively for Spinel, matz's ahead-of-time Ruby compiler. cybertrain build compiles your controllers, models, views and the framework into one native binary: no Rack, no gems at runtime, no Ruby interpreter in production. The Rails vocabulary (before_action, Article.where(...), resources :articles) comes from plain Ruby generated at build time instead of runtime metaprogramming.

Status: pre-alpha. Routing (namespaces, scopes, formats and respond_to), controllers with concerns, helper_method, strong parameters, HTTP caching, cookies and an encrypted session, CSRF, a Content Security Policy, force_ssl and host checks, ERB-style templates with components, application helpers, the number, form and Turbo helpers and per-controller layouts, digested assets with an import map, SQLite models (decimal, json, date and datetime columns; declared associations with includes; Rails' validators; model concerns; encrypted columns; bulk inserts and typed aggregates), migrations, and the authentication and file-upload generators all work end to end. So do background jobs (job classes with retry policies, cron schedules, a jobs page), a cache store, Turbo Streams over Server-Sent Events or WebSocket, and the outbound clients: HTTP (streamed, gzip and Server-Sent Events responses), SMTP (plain or HTML mail, sent now or from a job) and WebSocket feeds. examples/blog is the Rails "Getting Started" blog built on it. Since 2026-11-05 porting an existing Rails application is a goal, in five phases (design record, D1); a SQLite database that a Rails application created can be taken over as it is. Not built: i18n, mailer classes (a mail is a method that calls Mailer.deliver or deliver_later), mail attachments, HTTP/2 (what differs from Rails).

Quick start

Needs Ruby 3.2+, a C toolchain, make, git, curl and the SQLite, zlib and OpenSSL headers (details; cybertrain doctor checks them).

gem install cybertrain
cybertrain new blog    # also installs Spinel, the first time (a few minutes)
cd blog
cybertrain g scaffold article title:string body:text
cybertrain db migrate
cybertrain server      # http://127.0.0.1:3000
cybertrain build       # production: one binary in dist/

The binary runs every role a deployment needs: ./blog server for HTTP and the realtime endpoint (turbo_stream_from @article on a page, Cybertrain::Stream.broadcast_append_to from an action or a job), ./blog worker for jobs and scheduled tasks (several may share the database; jobs are delivered at least once), ./blog feeds for WebSocket subscriptions, and ./blog console for a prompt over the models.

Or try it with nothing installed: open the playground in GitHub Codespaces (what the playground holds).

On one CPU core, with 16 connections, the blog serves 2.2 to 8.8 times the requests per second of the same app in Rails 8.1, in about a tenth of the memory (numbers).

Documentation

Tutorial Build the blog step by step: scaffold, comments, authentication, uploads, deployment
Installing Requirements, the cybertrain command, how Spinel and the framework are installed
How it works Build-time code generation, interpreted views, the server, the development loop, and a table of the differences from Rails
Models and the database Migrations, column types, queries, associations, validations, encrypted columns, transactions, taking over a Rails database
Requests Routing, formats and respond_to, concerns, strong parameters, HTTP caching, cookies and the session, rate limiting, CSP, force_ssl and hosts, headers, query strings and request bodies
Assets Digested stylesheets, images and JavaScript, CSS url(), the helpers, the import map, serving
Configuration config/app.rb, environment variables, time zones
Background work and operations Job classes, retries and concurrency keys (delivered at least once, so make jobs idempotent), every and cron tasks, the jobs page, the worker and feeds process roles, the cache store, the console, backups, the health check
Realtime Turbo Streams over Server-Sent Events or WebSocket, broadcasts from actions, jobs and feeds, signed stream names, feed health
Outbound HTTP, WebSocket feeds and e-mail HttpClient (streaming, gzip, redirects, Server-Sent Events), WebSocket.subscribe (timers, restarts), Mailer (HTML mail, deliver_later)
Testing Writing tests for an app, outbound calls, jobs, CI
Deploying To a server with systemd, or with Kamal
API reference Every class and method an application uses; also the template language
Design record · benchmark · spikes Why it is built this way, and the Spinel constraints behind it

The guides' Markdown sources are in docs/guide/.

Contributing

Bug reports, questions and pull requests are welcome; see CONTRIBUTING.md (setup, tests, the commit gate, releasing). Security issues go through SECURITY.md.

License

MIT; see LICENSE.

About

CyberTrain is a Rails-shaped web application framework written natively for Spinel.

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages