Skip to main content

max / quasi

6.3 KB · 139 lines History Blame Raw
1 # quasi
2
3 quasicoherent: the stack every Make Creative app is built on. `quasi` for short,
4 and that is what you type.
5
6 A quasi-coherent sheaf is determined by local module data on an affine cover and
7 glues, with no finiteness demanded of the pieces. That is the architecture: one
8 description per host context, agreeing on overlaps, renderers free to be unalike.
9
10 ## What it is
11
12 ```
13 request (path + params)
14 -> router this repo, imports no host crate
15 -> description makeover-layout
16 -> renderer webview | tui | egui
17 -> host adapter axum route | Tauri protocol | wry | direct call
18 ```
19
20 The router answers with what a screen *is*. The host decides how that becomes
21 pixels. One codebase reaches desktop, iOS, a terminal, egui, and a hosted web
22 app, because the host is the boundary that stops mattering.
23
24 ## What it owns
25
26 Seams, not vendors. quasi owns the boundaries between code we own and the major
27 dependencies underneath it, and the test for admitting one is:
28
29 **Name two implementations that exist or are already committed to.** A boundary
30 with one implementation forever is not a boundary, it is an indirection.
31
32 By that test, in scope: the host (Tauri, wry, axum, direct call), the renderer
33 (webview, tui, egui, via `makeover-layout`), database configuration and
34 migration across SQLite and Postgres, and eventually a shared session and auth
35 layer, which the server has and the desktop apps do not.
36
37 Out of scope, deliberately: `tokio`, `serde`, `tracing`, `chrono`, `uuid`,
38 `thiserror`. Ubiquitous, stable, and with no second implementation anyone would
39 adopt, so wrapping them costs a translation tax and returns nothing.
40
41 Also out of scope: anything whose value *is* its API surface. `sqlx`'s
42 compile-time-checked query macros are the reason to use `sqlx`, so quasi owns
43 which driver is configured and how migrations run, and queries stay written
44 against the driver directly.
45
46 The two stores are not one query layer, and quasi does not pretend otherwise
47 (settled 2026-08-07). Embedded is `rusqlite` and synchronous; hosted Postgres is
48 `sqlx` and async. A stack claiming a single query layer would have the
49 scaffolder generate the wrong one.
50
51 Boundaries already owned elsewhere stay where they are and are referenced rather
52 than absorbed: `makeover` and `makeover-geometry` for colour and spacing,
53 `synckit` for sync, `s3-storage` for blobs, `docengine` for rendered content,
54 `tagtree` for tags. One repo per project. quasi names the stack and fills the
55 seams that have no owner.
56
57 ## Layout
58
59 - `crates/quasi-router/` — the host-agnostic router. The keystone.
60 - `crates/quasi-http/` — the seam the http-shaped hosts share: decoding,
61 status mapping, the htmx contract, the `Serves` trait.
62 - `crates/quasi-axum/` — the axum host adapter.
63 - `crates/quasi-tauri/` — the Tauri custom-protocol host adapter.
64 - `crates/quasi-webview/` — the webview renderer: a screen in, an htmx document
65 out.
66 - `crates/quasi-store/` — the embedded store's migration runner.
67 - `crates/quasi/` — the scaffolder binary, and `template/`, the app it writes.
68
69 Crates are added when their component starts, not up front.
70
71 ## Getting an app
72
73 ```
74 cargo run -p quasi -- new fieldnotes
75 cd fieldnotes
76 cargo test the screens, with no host
77 cargo run -p fieldnotes-server http://127.0.0.1:3000
78 cargo run -p fieldnotes-desktop a window
79 ```
80
81 What comes out is a workspace of three crates: `-core` holds the state, the
82 store and the described screens and imports no host crate; `-desktop` and
83 `-server` are a window and a listener over the same router. Both serve the same
84 screens and neither knows the other exists.
85
86 ## Status
87
88 The router, both host adapters, the webview renderer, the store's migration
89 runner and the scaffolder are implemented.
90
91 The router carries the contract in full: one address space where the verb
92 separates a read from a write, a screen tree composed from `makeover-layout`'s
93 vocabulary, responses that name the region they replace, and failures classified
94 so a host can turn one into a status code and another into a banner. It is sync,
95 because the two renderers shipping first call it inside a frame and an event
96 loop.
97
98 `quasi-http` is what the two hosts turned out to share once there were two of
99 them. Decoding a query string and a form body, mapping an error's class to a
100 status, naming a fragment's region in an `HX-Retarget` header, and the htmx
101 client configuration a classified error needs. Nothing in it knows which host it
102 is in, and nothing in it is async.
103
104 `quasi-axum` is the hosted adapter. What is left in it is axum's own: it mounts
105 as a fallback, so ordinary axum routes merged in front keep serving the things a
106 description has no word for (static assets, health, file uploads), it reads the
107 body with a limit, and it makes the blocking hop the sync router needs.
108
109 `quasi-tauri` is the desktop and iOS adapter, a custom-protocol handler. The
110 window loads from the adapter's own scheme rather than from tauri's asset
111 protocol, which is what keeps every action a screen emits same-origin: no CORS,
112 nothing added to the CSP. A `passthrough` closure is its version of axum's
113 merged routes. There is no platform branch in it, because wry hands a handler
114 `<scheme>://localhost/<path>` on Linux, macOS, iOS and Windows alike.
115
116 Neither adapter emits markup. A `Serves` implementation supplies that, because
117 both serve HTML to a webview and generating it inside one would guarantee a
118 second copy. `quasi-webview` is that implementation: a screen in, an htmx
119 document out, with the transport entering in a single function.
120
121 `quasi-store` is what `sqlx::migrate!` used to be. SQL files embedded at build
122 time, applied once, recorded in a ledger with a checksum, so an applied
123 migration is immutable. It is here because goingson and Balanced Breakfast each
124 hand-wrote one after leaving `sqlx-sqlite`, and a generated app would have been
125 the third.
126
127 `quasi` is the scaffolder. It followed the router on the condition that the
128 router's shape be proven against two hosts, which it was. Its template is real
129 Rust and real manifests under `crates/quasi/template/`, excluded from the
130 workspace and embedded in the binary — readable and diffable, rather than a
131 liquid dialect that compiles nowhere.
132
133 Design and sequencing live in the wiki note `quasi-overview`; the backlog is in
134 GoingsOn under project `quasicoherent`.
135
136 ## Licence
137
138 MIT.
139