How fjkit is put together

Five pictures, one for each architecture decision that is closed. What was decided and why is CHARTER.md §3; this is what the decisions look like.

01 A2

The package boundary

Your app touches the kit in four places. Everything else is sealed in the package.

YOUR APP routers/*.py routes, Depends, template choice page.html calls macros, writes no classes _board.html the htmx fragment brand.css the --primary lines, nothing else import extends {% from %} overrides tokens FJKIT fjkit.Templates page() · stream() ui/shell.html head, theme, asset links ui/layout · data · form · table the closed vocabulary dist/fjkit-<pack>.css eight packs, built at release

All four arrows point one way. Your app depends on fjkit; nothing in the kit reaches back into your app, and nothing in it knows the shape of your data.

brand.css is all the styling configuration there is, and it is plain CSS variables. No step compiles it.

What this removes from your repository

a Tailwind install

the binary runs when fjkit is released, not when your app does

a watcher

there is nothing to rebuild after you edit a template

a vendoring script

htmx and Basecoat are pinned in the wheel and served by mount_fjkit


02 A5

Template resolution, and what eject changes

The app's template directory is searched first, so one import line resolves differently after an eject — and the caller never changes.

{% from "ui/button.html" import button %}

Before

① app/templates/ui/button.html

not there — the loader moves on

② fjkit/templates/ui/button.html

found, and this is what renders

After fjkit eject button

① app/templates/ui/button.html

found, and this is what renders

② fjkit/templates/ui/button.html

never reached

Shadowing is the feature, not an accident. ChoiceLoader puts your directory in front of the package's.

The price is that an ejected file stops receiving upstream fixes, which is why the documentation does not lead with it. fjkit eject copies the macros you name and re-exports the rest, so the file you own stays small — 49 lines against a 289-line source, for badge.


03 A1

When the build runs

The same pipeline runs either way. The difference is who runs it, and how often.

Every app builds its own

your templates + the component CSS

go into the Tailwind CLI

the CLI

is yours to install, pin and run

--watch

stays open while you work

the output

is a file your deployment has to produce

fjkit builds at release

the kit's templates + the component CSS

go into the same CLI, in fjkit's CI, once

the output

ships inside the wheel, one file per style pack

your brand.css

is a second <link>, not a second build

--watch

does not exist on your side

Measured on the pack this site loads: 236 KB raw, 25.2 KB gzip, against a 28 KB budget the build enforces. About 217 KB of the raw figure is Basecoat's component layer, which ships whole whether fjkit writes one macro over it or forty.


04 A6

The render path: one partial, two entry points

A full page and an htmx swap take different routes into the same template.

GET /tasks tasks_page() POST /tasks create_task() · hx-post tasks/_board.html the only definition included, and returned a whole document page.html, through the shell a fragment swapped into #board

_board.html has two ways in and two ways out, and one definition in the middle. The first paint and the swap therefore render from the same source, so they cannot drift.

@router.get("/tasks", name="tasks_page")
@render("tasks/page.html", partial="tasks/_board.html")
def tasks_page(service: TaskServiceDep) -> BoardResponse:
    return board(service)

partial= is the guarantee. One route answers a navigation with the page and an htmx request with the fragment, so there is no second route to keep in step.


05 A7

The gate loop

A closed vocabulary only holds if breaking it fails. Every failure names the component that is missing.

The loop

① you write a template

and reach for a class the kit does not emit — grid-cols-7, say

② fjkit check fails the build

the class is not in the whitelist, and the whitelist is derived from Basecoat's own CSS rather than maintained by hand

③ the blocked class is the answer

it names a component, or a macro parameter, that does not exist yet

④ it goes into ui/*.html

and the next template that needs it passes

This loop is the kit's only expansion mechanism, and the demo is its test case. Measured when 0.1 was finished: the same screens written before fjkit produced 258 violations, and the rewrite against the kit produced 0.

The check also blocks a utility that merely happens to exist today. An app that borrows gap-4 because the shell emits it breaks silently on the day the shell stops.