Build and deploy an app
A shared notes board, from an empty directory to a deployed URL, in six steps.
By the end you will have written routes, templates, a database schema, a login and a durable object that does work on a timer, and pushed the result to a server. Every snippet here was run before it was written down.
What you need
- The
meleecommand. Today that means a checkout of the melee repository andmise run build; there is no standalone install yet (What melee cannot do explains why). - Ruby 4.0 and the
sqlite3gem, formelee dev. - For the last step only, a running
melee-serverto push to. If you do not have one, Operating melee is how to get one, and the first five steps work without it.
The app
A notes board. Anyone can see the open notes; an admin signs in with a shared secret to add them and tick them off; and a counter tracks how many people looked at the board today, rolled over at midnight by something that runs when nobody is visiting at all.
That last part is the interesting one. There are no threads in a melee app and no job queue, so “do this later” has exactly one answer, and step 5 is it.
The steps
- A new app —
melee new, what it writes, and running it. - Routes and templates — a route, a layout, a partial, and escaping.
- A database — migrations as files, queries with binds.
- Forms, sessions and a login — POST, CSRF,
session,before. - Work that happens on its own — a durable object and its timer.
- Deploying it —
melee check,melee push, logs and secrets.
The finished app is about 140 lines across ten files you write: app.rb, one file under lib/, five
templates and three migrations.