For developers

2. How a site is put together

From the THINQ Site developer guide, in the guide's own words. The same text ships with every site's core.

2.1 Two repos, one site

THINQ Site is one product, core (thinq-platform/thinq-site-core), and many site repos, one per client. A site repo is thin. It holds only what belongs to that site and points at core for everything else:

your-site/
├── core/                        git submodule → thinq-site-core, pinned to one commit
├── content/                     seed content: pages, menus, site settings, forms (JSON)
├── public/                      files served as-is: logos, brand images, downloads
├── src/
│   ├── themes/
│   │   ├── <your-theme>/index.ts    your theme
│   │   └── index.ts                 the theme registry (your copy of core's)
│   ├── features/
│   │   ├── <your-site>/             your blocks, header, footer, pages
│   │   └── index.ts                 the feature registry (your copy of core's)
│   └── app/…                        only if you add routes (one-line re-exports)
├── .cascade-overrides.json      the core files this site keeps its own copy of
├── Dockerfile .gitignore .dockerignore   identical copies of core's; leave them alone
├── env.example                  copy to .env.local
└── README.md / CLAUDE.md        this site's own notes

The admin, the APIs, sign-in, forms, posts, events, search, the image pipeline, SEO and security all come from core/ and are never copied into your repo.

2.2 Assembly: how the two become one app

Your repo is never run on its own. It is assembled with core into one Next.js app:

  1. Take every file core provides (not its tooling, docs or seed content).
  2. Lay every file from your repo on top. Where both have the same path, yours wins.
  3. Build and run the result.

The same assembly runs in three places: dev.mjs (into .thinq/build), the host's Docker build, and the cascade that tests core updates against your site. You can run it yourself to see exactly what will deploy:

node core/scripts/assemble.mjs --site . --out /tmp/your-site-build

"Yours wins" is how a site customizes core without forking it, and it is also the main way to break a site. A file you add at a path core already uses replaces core's file, and core's later fixes to that file stop reaching you, mostly silently. So:

  • Put your code under your own folders (src/themes/<yours>/, src/features/<yours>/).
  • Before you create a file anywhere else, check that core has nothing at that path (ls core/<path>).

2.3 What you own

Path What goes there
src/themes/<yours>/** Your theme (Themes)
src/themes/index.ts Register your theme. This file is not checked against core at all
src/features/<yours>/** Blocks, header, footer, page components, helpers
src/features/index.ts Register your feature (shared with core, see §2.6)
src/app/<your-route>/… One-line re-exports for routes that are not CMS pages (Pages §6.3)
src/site/** Site hooks: your copy replaces core's empty default (Pages §6.8)
content/** Seed content
public/** Static files

Put the header and footer inside your own feature folder too (src/features/<yours>/Header.tsx), not in a shared folder like src/features/components/. Everything under src/features/ other than your own folder belongs to core, so keeping yours in one folder makes it obvious what is yours.

2.4 What you must not edit

These are kept byte-identical on every site by an automated drift check. A site copy that differs fails the check, and with it the site's core updates:

src/lib/** · src/framework/** · src/proxy.ts · src/app/api/** · src/app/admin/** · src/app/health/** · src/app/preview/** · src/app/oauth/** · src/app/.well-known/** · src/components/admin/** · src/features/** (other than your own folder and src/features/index.ts) · src/app/sitemap.ts · src/app/robots.ts · src/app/opengraph-image.tsx · src/app/feed.xml/route.ts · src/app/llms.txt/route.ts · src/app/indexnow-key.txt/** · src/app/media/[name]/route.ts · src/app/img/[...name]/route.ts · src/components/SiteImage.tsx · Dockerfile · docker-entrypoint.sh · .gitignore · .dockerignore · LICENSE.md

core/cascade.manifest.json is the authority; this list is a summary of it.

Two things on that list are worth knowing about: SEO and image serving are core. The sitemap, robots, the RSS feed, the share image and SiteImage are shared on purpose, so an SEO or image fix reaches every site. If your design needs something they don't do, that is a core request.

2.5 Files that are core's but not checked

Some core files are not on the drift list, so a site file at the same path replaces them without any warning. The common ones:

  • src/components/** outside admin/: the core blocks (src/components/blocks/*), the default Header.tsx and Footer.tsx, SiteNav.tsx, FooterParts.tsx, SafeHtml.tsx, SmoothScroll.tsx.
  • src/app/layout.tsx, src/app/page.tsx, src/app/[slug]/page.tsx, src/app/globals.css, and the public blog, events and search routes.
  • src/themes/index.ts.

Replacing one of these works, but it cuts that file off from core. For example, a site with its own copy of src/components/blocks/Pricing.tsx would never have received the 2026-09-25 fix for literal <p> tags in that block, and a site with its own src/app/layout.tsx would not have received built-in analytics on 2026-10-20. Prefer the supported routes instead:

You want to change Do this instead of copying the file
The header or footer chrome (Header and footer)
A core block Restyle with tokens, or copy it into your feature under a new type (Blocks §4.11)
Fonts Your theme (Themes §3.6)
Global CSS Your theme's tokens, or Tailwind classes in your components (Themes §3.7)
Redirects, or a response header Admin → Redirects for exact paths; otherwise withCoreConfig in next.config.ts (below)

next.config.ts: never copy core's. Core's Next.js config, including the security headers and the route cache, is in src/lib/next-config.ts. If your site needs a redirect the Redirects screen can't express (a wildcard, a host match) or an extra response header, pass only that:

import { withCoreConfig } from "./src/lib/next-config";

export default withCoreConfig({
  async redirects() {
    return [{ source: "/old-blog/:slug", destination: "/blog/:slug", permanent: true }];
  },
});

Your headers are added, but can't replace a header core sets. A core test runs on every site and fails its core updates if next.config.ts drops any of core's config, so a full copy stops working the next time core changes it.

If none of these fits, ask Bo first. The answer may be a small core change that every site gets.

2.6 The two files you share with core

src/features/index.ts and src/lib/schemas.ts are overrides: files a site is expected to have its own copy of. Your site needs its own src/features/index.ts, because that is where your feature is registered. (Most sites never need their own schemas.ts.)

The catch: when core changes one of these files, the cascade cannot merge the change into your copy. Your site's .cascade-overrides.json records the core commit each copy was last reconciled with:

[{ "path": "src/features/index.ts", "reconciledAt": "46a91d9" }]

When core moves past that commit, the drift check fails and core updates stop reaching the site until someone merges core's changes into the site's copy and moves reconciledAt forward. Bo does that, so you will see a reconcile commit on main; pull before you work (§1.7).

When you edit src/features/index.ts yourself, keep to this:

  • Add your import and your feature to registeredFeatures, last, so your chrome wins.
  • Leave every core line as it is, including the helper code below the list.
  • Don't change .cascade-overrides.json. If you think it needs changing, ask.
import { formsFeature } from "./forms";
import { postsFeature } from "./posts";
import { eventsFeature } from "./events";
import { encoreFeature } from "./encore";      // yours

export const registeredFeatures: FeatureModule[] = [
  formsFeature,
  postsFeature,
  eventsFeature,
  encoreFeature,                                // yours, last
];

2.7 What happens to a request

For orientation, the path a public page takes:

  1. src/proxy.ts applies the redirects set in the admin (and, for /admin, the session and role checks). Security headers, including the Content-Security-Policy, are added to every response by core's Next.js config (src/lib/next-config.ts, values in src/lib/security-headers.ts).
  2. A route renders it. CMS pages go through src/app/[slug]/page.tsx (the home page through src/app/page.tsx), which loads content/pages/<slug>.json, validates it against every registered block schema, and renders SiteHeader, the blocks, and SiteFooter.
  3. SiteHeader and SiteFooter are core's components unless a feature registers chrome (last registered wins).
  4. Each block renders through the component registered for its type.
  5. The result is cached in memory and served from there until any content changes (an admin save, a THINQ Connect edit), which drops the whole cache.

Content is read from disk on the server. There is no database round trip and no content API between your components and the content: a block receives its data as typed props.

This text is maintained in thinq-site-core at docs/developers/02-how-a-site-is-built.md (commit e72488e) and published here unchanged.