Generate from source

Generate an architecture diagram from a Next.js project.

The interesting line in a Next.js app is the one between server and client, and it is invisible in the file tree.

Download for macOS
v0.1.33 · .dmg · Apple Silicon & Intel
Signed & notarized by Apple · opens without a Gatekeeper warning
sha256 698955a0187bc039f4c74f5d05a9f10fbb27376a45788a0a241d1326b73873c7
Download for Windows instead
$curl -fsSL https://lucidtrain.com/install.sh | sh

What it reads

The app or pages directory to establish the route tree, the use client directives that mark where the client boundary falls, route handlers and server actions for the API surface, next.config for rewrites and redirects, and any database or service client to identify what the server talks to.

How Next.js becomes components

Routes become the client tier, grouped rather than listed one file per box. Server components and route handlers become the application tier. The client boundary is drawn explicitly, because it determines what ships to the browser and therefore what a user can read, which matters for both performance and for anything you assumed was server-only. Data access from server code becomes the data tier.

Why the layout can be trusted

The agent reads the files listed above and emits a semantic graph: components, the tier each belongs to, and the edges between them, with no coordinates anywhere. The ELK layout engine then computes positions and orthogonal edge routing. This is why the output cannot come back with boxes overlapping or arrows crossing through cards, which is the usual failure when a language model is asked to place things on a canvas itself.

The boundary is where the bugs are

Most confusing behaviour in an App Router codebase comes from a misplaced boundary: a component marked client that pulls a large dependency into the bundle, or a server component doing something that quietly runs on every request. Drawing the boundary rather than inferring it from directives scattered across files makes those obvious.

Your code stays on your machine

It runs on your machine. With a local Ollama model nothing leaves the laptop at all, and with your own API key the file contents go to the provider you chose and never through us. For a source that is your actual codebase, that distinction is usually the deciding one.

Next.js to diagram

In the projectIn the diagram
app/ or pages/ route treeClient tier, grouped by area
use client directivesThe client boundary, drawn explicitly
route.ts handlersAPI surface
Server actionsApplication tier operations
Server component data fetchingEdges to the data tier
next.config rewrites and redirectsEdge tier routing
middleware.tsEdge tier
Database and service clientsData and external tiers

The prompt

shell
$ Survey this Next.js project and diagram it: the route tree, where the client boundary falls, the route handlers and server actions, and what the server talks to.
FAQ

Questions

App Router or Pages Router?

Both, including projects mid-migration with the two side by side, which is a case where the diagram is unusually useful because it shows how far the migration actually got.

Will it show which components are client versus server?

Yes, that boundary is drawn explicitly rather than left implicit in directives across many files.

Does it work for a static export?

Yes, and the diagram is naturally simpler, since there is no server tier to draw.

Can it diagram the API separately?

Yes. For an app with a substantial API surface, a separate diagram of route handlers and what they touch is more readable than one picture covering both.

Related