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, controllers, sessions/CSRF, ERB-style templates, SQLite models with validations and associations, migrations, authentication and file-upload generators, background jobs, outbound HTTP, SMTP and WebSocket clients all work end to end; examples/blog is the Rails "Getting Started" blog built on it. Not built: a WebSocket server, an asset pipeline, i18n, mailer classes (what differs from Rails).

Quick start

Needs Ruby 3.2+, a C toolchain, make, git, curl and the SQLite and zlib 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/

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

On one CPU core the blog serves 2.6 to 12.2 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, queries beyond where, pagination, transactions, column names, ordering
Requests Rate limiting, the client address, parameterised headers, query strings and request bodies
Configuration config/app.rb, environment variables, time zones
Background work and operations Jobs, scheduled tasks, backups, the health check
Outbound HTTP, WebSocket feeds and e-mail HttpClient, WebSocket.subscribe, Mailer
Testing Writing tests for an app, outbound calls, 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