Docs › Start
Project structure
What lives in your repo, what lives in packages, and how a page gets its data.
An ACES project splits into two parts:
- Engine: code that is the same on every site. It ships in versioned
@aces-core/*packages, and you upgrade it with your package manager. - Your project: code that makes a site yours, such as components, UI, tokens, the skin and routes. It is copied into your repo, and you edit it freely.
Layout
aces.config.ts the one config: site, locales, features, registries
src/proxy.ts locale detection and redirects (Next.js 16 middleware)
src/app/layout.tsx root layout: header and footer from the Apps entry, Draft Mode bar
src/app/[lang]/ routes, all locale-prefixed
page.tsx home (the Page whose Specialty Page is "Homepage")
[...slug]/page.tsx every other Page
articles/, search/ feature routes
src/app/api/draft/* Live Preview entry points
src/app/styles.css stylesheet entry: imports tokens, base and the skin, in layers
src/styles/
tokens.css brand + semantic tokens (Tailwind 4 @theme): rebrand here
base.css, prose-base.css surfaces, reset, type scale, readable rich text (always on)
skin/ Base skin: one CSS file per component (optional)
custom/ skin files you ejected (yours)
src/libs/ imported through @aces/* aliases
cf/ @aces/cf Contentful components (cf-*) + generated registry
clients/contentful/ @aces/contentful GraphQL client, shared fragments
features/ @aces/features app shell, navigation, articles, search, page body
ui/ @aces/ui UI primitives (Tailwind 4 + Base UI)
theme/ @aces/theme fonts + breakpoints for JS
i18n/ types/ utils/ hooks/ store/
contentful/ models.json, content.json (demo), starter.json, assets/
A cf component
Each Contentful component lives in src/libs/cf/lib/cf-<name>/:
| File | Role |
|---|---|
services.ts |
The GraphQL fragment and a query by entry ID. Add fields here. |
render.tsx |
The markup ("use client"): layout classes and data-slot hooks. Live Preview props go on editable elements. Its look is in src/styles/skin/. |
index.tsx |
Server component: fetches, then renders. Used on the live site. |
client.tsx |
Client component: fetches and subscribes with useContentfulLiveUpdates. Used in Draft Mode. |
skeleton.tsx |
Loading and fallback state. |
aces component add writes all five and registers the component. See the CLI reference.
How a page gets its data
Each component fetches its own data by entry ID:
- The page query returns only the body’s list of
__typenameandsys.id. - The page body renderer looks up each
__typenamein the component registry and renders that component with the ID. - On the live site that is the server component (
index.tsx). In Draft Mode it is the client component (client.tsx), which updates live as editors type.
So a component works the same wherever it appears: in a page body, embedded in rich text, or in an entry preview.
Rules of the road
aces.config.tsis the single source of truth. Don’t hard-code site, locale or registry values elsewhere. See Configuration.- The registry is generated. Never edit
src/libs/cf/registry/server.tsorclient.ts. Runpnpm aces syncafter editing the config.devandbuildrun it for you. - UI comes from
@aces/uionly. Base UI, lucide-react, cva and tailwind-merge are imported only insidesrc/libs/ui. ESLint enforces this. - Looks live in tokens and the skin, not markup. Colors, radii, fonts and the type scale are tokens in
src/styles/tokens.css(fonts load insrc/libs/theme/lib/fonts.ts); how each component looks issrc/styles/skin/. Sections switch background withdata-surface. See Styling. - Client files import cf components by path (
@aces/cf/lib/cf-image/render), never from the@aces/cfbarrel. The barrel includes server code. - Responsive layout uses CSS breakpoints (
hidden lg:flex), notuseMediaQuery. The hook isfalseon the server, so the first HTML would be wrong.
Environment
| Variable | Used by |
|---|---|
NEXT_PUBLIC_CF_SPACE, NEXT_PUBLIC_CF_ENVIRONMENT |
The site and the Optimization SDK |
NEXT_PUBLIC_CF_ACCESS_TOKEN |
Delivery API (the live site) |
NEXT_PUBLIC_CF_PREVIEW_ACCESS_TOKEN |
Preview API (Draft Mode) |
CF_PREVIEW_SECRET |
Server only: checks Live Preview requests. Generated by aces setup. |
NEXT_CF_MANAGEMENT_TOKEN |
The aces CLI only. Keep it out of deployed environments. |
The CLI also reads CONTENTFUL_SPACE_ID, CONTENTFUL_ENVIRONMENT, CONTENTFUL_DELIVERY_TOKEN, CONTENTFUL_PREVIEW_TOKEN and CONTENTFUL_MANAGEMENT_TOKEN from the shell when .env.local doesn’t have them.
Something wrong or missing? Open an issue.