Chapter 1: apps, a folder with one thing in it
A repository like this one splits into two kinds of code. There is code
that does things: answers HTTP requests, calls Jev, writes to a database,
waits on the network. And there is code that only thinks: given these
facts, which rule fires; given this answer, what goes on the page. The doing
kind lives here, in apps/. The thinking kind lives in packages/
(chapter 5).
Right now there is exactly one app, the Cloudflare Worker that is the whole
website. The folder exists anyway, because the split is the point, not the
count: when an app needs something that does no I/O, it goes in a package
and gets tested with plain cargo test, on your laptop, with no Cloudflare
anywhere.
flowchart LR
subgraph apps["apps/ (does things)"]
W["lmjtfy: the Worker"]
end
subgraph packages["packages/ (only thinks)"]
R[rules] --- A[ask] --- L[llm]
AR[archive] --- B[budget] --- C[card] --- T[tree]
end
W --> packages
Aside. In Nuxt terms,
apps/lmjtfyis your Nitro server and pages together, andpackages/is a folder of composables that never touchfetch. The difference is that Rust makes the line hard: a package that tried to call the network would not compile, because none of them depend on the Worker's runtime.
In this folder
| Path | What |
|---|---|
| lmjtfy/ | The Cloudflare Worker: the site, its two Durable Objects, and the clone proxy. |
← Previous: Prologue · Up: lmjtfy · Next: Chapter 2, the Worker →