Why fjkit, and when not

What the alternatives cost, and what this one costs. Read this before you commit to the shape, not after.

01

Three ways to put a UI on a FastAPI app

Three approaches, and what each one costs.

None of these is wrong. They differ in what the cost is, and in when the cost arrives.

① Templates and your own CSS

what you write

Jinja, plus a stylesheet you own — hand-written, or a utility framework you compile yourself

what it costs

a design system you did not set out to build. Spacing, states, focus rings, dark mode and accessibility are all yours, and they decay as the app grows, because nothing fails when one page drifts from another

when it is right

a handful of pages, or a look that nothing off the shelf will give you

② A client-rendered front end

what you write

a component application, served and deployed separately from the API

what it costs

a second build, a second language and a second thing to deploy. Your data gets shaped twice — once for the API, once for the view — and the loading, error and empty states the server used to answer become yours to write

when it is right

genuine client state: an editor, a canvas, a live document, anything that keeps working between requests

③ A server-rendered component kit — this one

what you write

handlers that return a model, and templates that call macros. The browser gets HTML

what it costs

section 02

when it is right

a back office, an internal tool, a content site, an admin — a real interface over an API you already have, where the page is the unit and the server already knows everything


02

What this one costs

Three things you give up. Each one is the price of something in section 01.

The trade

You cannot write arbitrary CSS

the class vocabulary is closed and fjkit check fails the build on anything outside it. That is what buys the missing build step. fjkit compiles the stylesheet before your app exists, and that works only because the closed vocabulary already lists every class a template may ask for. When a layout seems to need a utility, the answer is a macro parameter, which means an upstream change rather than a local one

A component the kit has not written stops you

the gate blocks the class, and the thing it names has to be built before that page ships. fjkit eject copies a macro into your repository as an escape hatch — and the file you take stops receiving upstream fixes, which is why the documentation does not lead with it

The look starts as someone else's

eight style packs ship, and a token override repaints all of it, but this is a design system you adopt rather than one you author

The first two are the same trade seen from both ends. A vocabulary narrow enough to pre-compile is narrow enough to run out.