Architecture
Content is data, pages are thin, and every folder has one job. This page is the map, plus the rules I apply when I add to it.
Folder map
Everything lives under src/.
| Folder | Responsibility |
|---|---|
app/ | App Router entry points and the HTML shell: layout.tsx (fonts, metadata, global styles), page.tsx (landing), and one folder per route (about, experience/[slug], skills/[skill], resume, api/resume-request), plus the llms.txt route and the md routes under the pages they describe. Also robots.ts, sitemap.ts and opengraph-image.tsx. |
sections/ | Page-level narrative blocks of the landing page: Hero, About, Skills and Experience. |
containers/ | Layout and behavior wrappers, such as the header, the footer and the floating navigation container. |
partials/ | Cross-cutting layout pieces: Container, PageShell, SectionHeader, DescriptionList, HashScroll and ResumeDownload. |
components/ | Reusable UI pieces: Button, Text, Cursor, FloatingNav and a few visual helpers. |
content/ | The site’s content as data: experience.ts, skills.ts, about.ts, gallery.ts, links.ts and resume.ts. |
config/ | Typed environment schemas (env/), navigation section IDs (navigation/), i18n resources (localization/), design tokens (styles/), site facts (site.ts) and per-page metadata (seo.ts). |
lib/ | Logic that does not belong to a component. resume-request/ is the request handling behind the resume download dialog, jsonResume/ builds the /resume.json export, dateTime/ is the single home for date and time parsing and formatting (Luxon, always in America/New_York), career/ derives career start and years of experience from the role history, markdown/ builds the Markdown alternates and /llms.txt, blog/ holds the Sanity reads, webhook check and RSS feed behind the blog, webmcp/ registers the tools for browser agents (see WebMCP tools), and resumeRequest/ lets one of those tools open the resume dialog. |
modules/ | React hooks and providers, and the logic tied to them. |
utils/ | Small pure functions with no app imports: clamp, clamp01, wrapIndex, stepIndex, padNumber, isExternalUrl, displayHost, isPlainLeftClick and classNames. |
prototypes/ | Design explorations that are compared in Storybook and not shipped. Nothing in the app imports them (ESLint enforces it). Each has a README with what was explored and what was chosen. |
What I allow in utils/
src/utils/ holds small functions that anything can import. I put a function there only if all four hold:
- Pure. The same input gives the same output. No
window,document,Date.now(),Math.random(), environment or i18n reads. A time or a locale comes in as an argument. Dates and times areDateTimevalues from@/lib/dateTime, which is the only place that imports Luxon; ESLint rejectsnew Date(),Intl.DateTimeFormatand a directluxonimport elsewhere insrc. - No app imports. Nothing from
@/components,@/content,@/config, React, framer-motion or next. The standard library and type-only imports are fine. - Generic. The name and signature carry no domain terms (skills, roles, glass, nav).
- Shared or plainly general-purpose. Used in two or more places, or obviously not tied to one.
Everything else stays beside its user. Helpers for one component live in that component’s folder. Hooks stay out of utils/. Anything that reads i18n, such as formatPeriod, stays in config/localization.
Each util is a folder with name.ts, name.test.ts and an index.ts, and utils/index.ts re-exports them all. Import from @/utils, never from a file inside a util’s folder. Each test file runs in the Node unit project and covers the documented behavior, the boundaries and the invalid inputs. Where a util replaced copies that disagreed, its doc comment says which behavior won and a test pins it.
Before writing a one-line Math.min(…, Math.max(…)), padStart(2, "0") or /^https?:\/\// check, look in utils/.
Where shared UI goes
Shared UI is built in three layers, and each depends only on the ones before it. Check them in this order before writing a local copy:
- Foundations (
src/config/styles/): tokens and style helpers with no markup. The radius scale,labelType,focusRing,visuallyHiddenandrise, each with a story underFoundations. Add a value here when two stylesheets need the same one. - Primitives (
src/components/): single-purpose components built on the foundations, such asIcon,Eyebrow,Chip,Surface,Meter,VisuallyHiddenandLinkOrAnchor. They take props instead of class names and have a story with controls. Add one when the same markup and style repeat in two places. - Composites (
src/partials/andsrc/containers/): pieces made of primitives for a page or a section, such asSectionHeader,DescriptionList, thePageShellfamily andLandingSection.
A page-level stylesheet should hold only what is specific to that page. Styling lists what exists in each layer.
How I lay out a folder
The folder map above says what each top-level folder is for. This section covers the folders inside them. The reference example is LandingSkills:
LandingSkills/
LandingSkills.tsx
LandingSkills.css.ts
LandingSkills.stories.tsx
index.ts
SkillIndex/
SkillIndex.tsx
SkillIndex.css.ts
SkillIndex.stories.tsx
index.ts
SkillList/
SkillList.tsx
SkillList.css.ts
index.ts
SkillSearch/
SkillSearch.tsx
SkillSearch.css.ts
index.tsThe skill list’s sorting and filtering helpers are used at three depths, so they are not part of this tree: they live in src/modules/skillCatalog/. The skill hover card moved out of the tree for the same reason: the landing list and the /skills/[skill] related tiles both show it, so it lives in src/components/SkillPreview/ with its useSkillPreview hook.
The rules:
- One folder per component. A component folder holds
Name.tsx,Name.css.ts,Name.stories.tsx,Name.test.tsx(as applicable) and anindex.tsbarrel. The component lives inName.tsx, never inindex.tsx. - Logic that serves one component lives with it. A helper, hook or test used by a single component sits in that component’s folder.
- Anything shared by siblings moves up to the layer that fits it:
components/,containers/,partials/,lib/ormodules/, under a name that does not mention one consumer. Do not createshared/folders. A path such as@/modules/skillCatalogshows the dependency direction. - Parent components own their children. A child used by exactly one parent nests inside the parent’s folder. A child used by two or more moves up a layer, as in rule 3.
- At most 8 files directly inside a folder. Subfolders do not count. Past 8, group into subfolders. Two folders are exempt:
src/app(the App Router fixes its file names, so route entries such aspage.tsx,layout.tsxandroute.tsalso sit outside the naming rule in item 7) andsrc/content(parallel data modules with their tests beside them). - Import through the barrel. Outside its own folder, import
@/components/Foo, not@/components/Foo/Foo.css. If a consumer needs a style or helper, the barrel exports it. - Names.
PascalCasefolder and file for components,camelCasefor plain modules, and no two files in one folder whose names differ only by case. On a case-insensitive filesystem, such a pair resolves unpredictably.
Stories stay beside their components rather than in a stories/ folder, as Quality gates describes.
Not every folder has a story, and these are the ones that do not, with the reason:
HashScroll,ClientLayout,SplashScreen: boot and behavior code with nothing to look at in isolation. The route-scroll and transition probes cover them.AppLoading: it is server-rendered and removes itself on hydration, so a client-only Storybook always renders nothing.Cursor,FloatingNavContainer,Header(beyond its logo link) andLandingHero(beyond its title): they depend on the page’s scroll, the cursor provider or the splash sequence, so a story would show a broken frame. The probes exercise them in the built site.PagePrimitivesandStackTint: styles and tokens only.PageShell,Chip,Meterand the other stories show them in use.
Move files with git mv, in commits that change no logic, so git log --follow keeps the history. Do not restructure an existing folder inside an unrelated change.
Nothing enforces these rules automatically, so my review is the backstop. To re-check the file count per directory:
git ls-files src | xargs -n1 dirname | sort | uniq -c | sort -rnI am applying the layout folder by folder, so some folders still hold a flat list of files. The rules apply to new components and to any file a task already moves.
How a page is composed
Content is data and pages are thin. A secondary page such as /experience/[slug] follows one pattern:
- The route file in
src/app/reads a content module fromsrc/content/. - It wraps everything in
PageShellfromsrc/partials/PageShell, which supplies the back link and the shared spacing. - It composes the shell’s building blocks:
PageHeader,PageBody,DescriptionList(fromsrc/partials/DescriptionList),PageSection,PageHighlightsandPageAdjacentNav.
Dynamic routes only exist for slugs present in the content module. They set dynamicParams = false and build their paths with generateStaticParams, so an unknown slug is a real 404. /blog/[slug] is the exception and keeps dynamicParams on, because its posts come from Sanity and are published without a build. See Blog.
Anchors on the landing page and the floating navigation share section IDs from src/config/navigation/nav-sections.ts, so links and content cannot drift apart.
The resume request flow
The /resume page is built from the same content modules as the rest of the site. Its Download button opens a full-page dialog (src/partials/ResumeDownload) that asks for a name and an email, both required. The PDF is only ever delivered by email: the site has no direct download.
Download -> dialog opens (native <dialog>, focus trapped)
'-- Send it -> POST /api/resume-request, wait for the answer
|-- 204 -> "Check your inbox"
'-- 4xx/5xx -> inline error, form stays open for a retryThe route handler at src/app/api/resume-request/route.ts is a thin wrapper around handleResumeRequest in src/lib/resume-request/handle.ts. That function:
- applies a best-effort per-IP rate limit,
- validates the input with zod (
schema.ts), - verifies the Cloudflare Turnstile token,
- sends the PDF to the visitor through Resend, then an owner notification.
Nothing is stored. The handler returns 204 once the visitor’s email is sent and 502 when it could not be (a Resend error, a missing PDF, or missing keys), so the dialog never claims success for an email that was not sent. A failed owner notification is only logged. Outside production, missing keys skip the send and still return 204 so the flow can be tried locally.
Feature flags
Two features are behind flags managed in Vercel (project operation-looking-glass, Flags): the ⌘K palette (command-palette) and the AI assistant (assistant). I keep the pages static. Reading a flag while rendering would read cookies and headers and turn every route dynamic, so the client fetches GET /api/flags once after the page loads, shares the answer between every component that needs it, and renders nothing flagged until the answer says true.
The route (src/app/api/flags/route.ts) evaluates each flag with the Flags SDK and answers with Cache-Control: public, s-maxage=60, stale-while-revalidate=300. A change in Vercel reaches visitors within about a minute, with no redeploy. The assistant’s own routes (/api/chat and /api/chat/session) also read the assistant flag on the server and answer with the fallback while it is off, so switching it off stops the model calls and not just the UI.
| Situation | Result |
|---|---|
| Flag on in Vercel | On, after the flags load |
| Flag off in Vercel | Off |
No FLAGS key (CI, a local production build) | Off |
FLAGS malformed, or Vercel unreachable | Off, and the answer is not cached |
Local development without FLAGS | On |
Each flag is evaluated on its own, so one failing leaves the other as it was.
The header’s top-right slot
The chip at the header’s top right belongs to one feature at a time, chosen by resolveHeaderAction (src/containers/HeaderAction) from the two flags and from whether the assistant is available. The assistant has priority, and the command palette is its fallback.
assistant flag | Assistant available | command-palette flag | Slot |
|---|---|---|---|
| on | yes | on or off | The assistant chip |
| on | no | on | The command palette chip |
| on | no | off | Empty |
| off | not asked | on | The command palette chip |
| off | not asked | off | Empty |
With both flags off the slot is empty and neither feature is reachable: the palette’s shortcuts (⌘K, Ctrl+K, /) are listened for only while the palette is the one shown.
“Available” comes from GET /api/chat/status (src/lib/assistant/availability.ts), which the browser asks only while the assistant flag is on. It is true when the assistant is set up (model key and session secret), its limit store answers, and today’s global budget is not spent. It reads the budget with peek, which records nothing. It does not depend on the visitor, so the CDN shares the answer for 30 seconds, and a store failure is never cached. A failed request reads as not available.
While the status is loading and the assistant flag is on, the slot stays empty, so the palette does not flash in and then get replaced. The assistant’s inline launchers (the About section and /about) follow the same rule: they show only while the flag is on and the assistant is available. A visitor whose own per-address or per-session limit is spent still sees the assistant and gets its fallback panel with the contact links, because that limit is theirs and not the site’s.
Flags Explorer and overrides
GET /.well-known/vercel/flags (src/app/.well-known/vercel/flags/route.ts) is the discovery endpoint Vercel Toolbar’s Flags Explorer reads to list the flags, with their description and Off/On options. The SDK checks the Authorization header against FLAGS_SECRET and answers 401 otherwise, so nothing is public. FLAGS_SECRET is created by Vercel when Flags Explorer is enabled for the project; confirm it is set for the Preview and Production environments (vercel env ls, never print the value) and run vercel env pull to test locally.
An override set in the toolbar is the encrypted vercel-flag-overrides cookie. /api/flags evaluates the flag inside the request, so the SDK decrypts that cookie and returns the override. Because the CDN keys on the URL and not on cookies, the header fetches /api/flags?overrides=1 while the cookie is present, and the route answers with Cache-Control: private, no-store for that URL even when the cookie is missing, so the override URL never holds a shared entry. A visitor without the cookie keeps the shared, cached answer and never sees someone else’s override. Clearing the override in the toolbar returns the visitor to the normal URL on the next load.
To debug an empty Explorer, request /.well-known/vercel/flags from the toolbar and check for a 401 (secret mismatch between the project and the deployment) or a 500 (missing FLAGS_SECRET or a malformed FLAGS key).
A flag is on only for the boolean true, so every failure reads as off. The flag is built when it is first evaluated and not when the module loads: the Vercel adapter throws while it is built if the key is malformed, and a throw at import time would make the route a 500.
To add a flag, define it in src/lib/featureFlags/flags.ts with the same key as its slug in Vercel, then add it to FlagValues, parseFlags and handleFlagsRequest.
A build without Vercel credentials prints Module not found: Can't resolve '@vercel/flags-definitions'. Vercel generates that package during its own builds to give the SDK offline fallback definitions, so the warning is harmless elsewhere. CI builds have no key, so the palette is off in the built-page accessibility probe.
Environment variables
Typed schemas live in src/config/env/client.ts and src/config/env/server.ts and use @t3-oss/env-nextjs. I do not set SKIP_ENV_VALIDATION. It skips the schema default for NEXT_PUBLIC_SITE_URL, so the build fails with Invalid URL. NEXT_PUBLIC_APP_ENV=staging makes a deployment serve noindex metadata and a disallow-all robots.txt.