Docs Site
Architecture deep dive for the `apps/docs` Next.js documentation app, its Fumadocs shell, and its shared login handoff.
apps/docs is the standalone documentation application for SterlingIndex. It is a Next.js App Router app built on Fumadocs, deployed on the dedicated docs host, and intentionally kept separate from the marketing site even though both are public, unauthenticated surfaces.
The app is documentation-heavy and runtime-light. It renders mostly static MDX content, keeps its own shell and metadata contract, and now exposes the same shared dashboard sign-in handoff used by the marketing surface.
System Role
- Primary purpose: publish engineering-facing architecture, deployment, and contract documentation at
docs.<domain>. - Runtime boundary: the app owns the docs shell, page tree, metadata, and search route, but defers authenticated product access to the shared dashboard sign-in handoff from
@sterling/auth. - Deployment assumption: the app deploys independently on Vercel, serves
https://docs.<domain>/docs, and does not inherit the marketing site's route tree or shell primitives.
docs.<domain>/
-> src/app/layout.tsx
-> Fumadocs RootProvider
-> docs route tree
-> top-nav login button
-> sidebar login CTARoute Structure
| Route | Purpose | Primary file |
|---|---|---|
/ | Root entry that redirects to /docs | apps/docs/src/app/page.tsx |
/docs | Docs index and section landing page | apps/docs/content/docs/index.mdx through the Fumadocs page tree |
/docs/[[...slug]] | Statically generated documentation pages | apps/docs/src/app/docs/[[...slug]]/page.tsx |
/api/search | Docs search endpoint | apps/docs/src/app/api/search/route.ts |
Shell and Layout Model
The global shell lives in apps/docs/src/app/layout.tsx.
- It publishes the docs
metadataBase, title template, Open Graph metadata, and Twitter metadata throughapps/docs/src/lib/site.ts. - It injects Google-hosted
Mona SansandInter, matching the rest of the repo's public surfaces. - It mounts
RootProviderfromfumadocs-ui/provider/next, not the marketing shell fromapps/www.
The docs section layout lives in apps/docs/src/app/docs/layout.tsx.
- It renders
DocsLayoutfromfumadocs-ui/layouts/docs. - It sources the page tree from
apps/docs/src/lib/source.ts. - It applies repo-specific layout options from
apps/docs/src/lib/layout-options.tsx.
Shared Login Handoff
The docs app now uses the same shared auth contract as the other public and operator-facing surfaces.
apps/docs/src/lib/layout-options.tsximportsnormalizeBaseUrl()andbuildDashboardLoginHref()from@sterling/auth.- It derives
DOCS_LOGIN_HREFfromNEXT_PUBLIC_DASHBOARD_URL, with a local fallback ofhttp://localhost:8080. - The top navigation renders a visible
Log inbutton through the Fumadocslinksconfig. - The docs sidebar renders a persistent footer CTA that points to the same dashboard sign-in handoff contract.
This means the docs app stays public and documentation-focused, but it still provides a clear escape hatch into the authenticated product.
Content and Generation Model
The content source is the MDX tree under apps/docs/content/docs.
apps/docs/src/lib/source.tsconverts the MDX collection into a Fumadocs source.apps/docs/src/app/docs/[[...slug]]/page.tsxreads the matching page, renders the MDX body, and exports static params for build-time generation.generateMetadata()attaches per-page title, description, and canonical path values.
Because the page tree is generated at build time, the docs app is mostly deterministic:
- there is no live CMS dependency,
- the route surface is tied directly to checked-in MDX files,
- the login CTA is the only notable cross-app runtime handoff in the shell.
Runtime Environment Inputs
The checked-in docs runtime contract now includes:
NEXT_PUBLIC_DOCS_BASE_URLfor the docs metadata and canonical originNEXT_PUBLIC_DASHBOARD_URLfor the shared dashboard-login handoffAPP_PUBLIC_DOCS_URLas a fallback name supported byapps/docs/src/lib/site.ts
These values are documented in apps/docs/.env.example and mirrored into the shared local/prod examples under infra/.
Deployment and Verification
The docs app is expected to deploy independently on Vercel.
- package metadata:
apps/docs/package.json - Next config:
apps/docs/next.config.ts - app shell:
apps/docs/src/app/layout.tsx - layout options and shared login CTA:
apps/docs/src/lib/layout-options.tsx
Verification surface:
pnpm --dir apps/docs buildpnpm --dir apps/docs typecheckpnpm --dir apps/docs lint
Manual smoke checks should confirm:
/redirects to/docs- the top-nav
Log inbutton lands on the dashboard sign-in handoff URL - the sidebar footer CTA lands on the same dashboard sign-in handoff URL
- canonicals and metadata point at
docs.<domain>
Key Files
apps/docs/package.jsonapps/docs/next.config.tsapps/docs/src/app/layout.tsxapps/docs/src/app/page.tsxapps/docs/src/app/docs/layout.tsxapps/docs/src/app/docs/[[...slug]]/page.tsxapps/docs/src/lib/site.tsapps/docs/src/lib/source.tsapps/docs/src/lib/layout-options.tsxpackages/auth/src/index.ts