sethucms
Build on it

How the code is laid out

Rule: no source file is longer than 700 lines. When a file grows past that, it is split into parts (A, B, C) and the original file stays as the thin middle file that brings them together. Existing imports keep working, and a reader finds one idea per file.

Gateway (apps/api/src)

Original fileStays asParts
gateway.tsWires the services together, runs the request pipelineboot/: access-log, admin, change-feed, gauges, http-helpers, types, workspaces
connections/registry.tsThe registry classregistry-types, registry-helpers
migration/manager.tsThe job managermanager-types, manager-helpers, prepare, copy
content/drafts.tsThe drafts servicedrafts-types, drafts-checks
store/firestore.tsRe-exports the partsfirestore-client, -state, -shared, -audit, -changes
tenancy.ts, routes/workspaces.tsWorkspaces (doc 30)
schema/code.ts, schema/define.ts, routes/schema.tsSchema as code (doc 29)
files/, routes/files.tsImages and files (doc 31)

Tests follow the same split: tests/gateway.test.ts, gateway-drafts.test.ts, gateway-admin.test.ts.

Admin app (sethucms-admin/src)

Original fileStays asParts
api/gateway.tsThe endpoint listapi/wire.ts (types), api/client.ts (session, workspace, request)
components/FieldInput.tsxPicks the control for a fieldcomponents/fields/: FileUpload, JsonInput, ReferenceSelect, helpers
styles.cssOnly @import lines, in the order the styles applystyles/: tokens-base, ledger-lists, forms-chrome, content-editor, layout, cards-home, editor-only

Writing new code

  • Keep each file under 700 lines. Split by idea, not by size alone.
  • Braces on every if, long calls broken across lines, descriptive names, a doc comment on each function.
  • Run the tests for what you changed and say what you could not run.