AEAl-Andalus⺢Experience
Sign in · Join
AEAl-Andalus⺢Experience
ProjectsGalleryAboutArticlesDashboardAPI
© 2026 — Modular content systems☕buy me a coffee
Framework Study Guide
ChaptersCardsLegendRoadmapRoute Map
Chapters
00 · Root Layout01 · Server Page (page.tsx)01a · Special Files (not-found, error, loading)02 · Client Component (UI & Interaction)02a · Client Boundaries & Islands03 · Entity Actions (actions/*.ts)04 · Server Actions ("use server")05 · Context Provider (context/*.tsx)06 · API Route (app/(api)/<entity>/route.ts)07 · TypeScript + Prisma08 · Entity-First Feature Design09 · Deployment, Docker & Cloud10 · Next 16 + Prisma 7 Upgrade11 · Prisma 7 (SQLite-first, App Router)12 · TypeORM (Entities + Migrations)13 · Drizzle ORM (SQL-first)11 · CSS, Mobile-First Flex, Tailwind12 · Libraries, Accelerators & Production Shortcuts14 · Next.js 16: cache, PPR, proxy, AI
→ cards/00-layout

Chapter

00 · Root Layout

Global shell, providers only, no domain logic or Prisma.

Mental Model

  • Global conductor: wires providers, resolves global permissions, hands off.
  • Not an entity; not a place for mutations or Prisma.
  • Runs once per navigation; defines the application shell.
  • If it gets “smart”, the architecture is broken.

Allowed Imports

// language / config
import "./globals.css";
import { Inter } from "next/font/google";

// context providers (client boundaries)
import Providers from "./providers";
import { EditModeProvider } from "@/contexts/EditModeContext";
import { AIEngineProvider } from "@/contexts/AssistantContext";

// global helpers (no entities)
import { resolveGlobalPermissions } from "./permissions";

Typical Signature

export default async function RootLayout({
children,
}: { children: React.ReactNode; }) {
const permissions = await resolveGlobalPermissions(); // context

return (
<html lang="en">
<body>
<EditModeProvider canEdit={permissions.canEdit}>
<AIEngineProvider>
<Providers session={permissions.session}>
{children}
</Providers>
</AIEngineProvider>
</EditModeProvider>
</body>
</html>
);
}

Never Do Here (and where it belongs)

  • Prisma queries (🟡) → put them in entity actions.
  • Business rules → keep in entity/domain services, never in layout.
  • Mutations / server actions → belong in app/.../actions.ts files.
  • Internal API calls → call actions directly; skip API round-trips from layout.

Colour-Coded Miniature

export default async function RootLayout({
{ children }: {
children: React.ReactNode;
}}) {
const permissions = await resolveGlobalPermissions(); // context read

return (
<html lang="en">
<body>
<EditModeProvider canEdit={permissions.canEdit}>
<AIEngineProvider>
<Providers session={permissions.session}>
{children}
</Providers>
</AIEngineProvider>
</EditModeProvider>
</body>
</html>
);
}

Next 16 proxy.ts — First Line of Defence

  • proxy.ts replaces middleware.ts as the first interception point for every request.
  • Use it for: host-routing (multi-tenant domains), redirects, rewrite rules, and shared response headers.
  • DO NOT use it for: auth checks (use Server Actions), data fetch, Prisma access — those belong in entity actions.
  • File location: project root or src/proxy.ts (same level as layout.tsx).
  • Runs before any rendering; keep it stateless and fast.

Quick Rules

  • Root layout = boring, stable shell.
  • Providers are fine; logic is not.
  • Reads only for global permissions; no Prisma.
  • Zero entity intelligence; delegate everything downward.