liveBook · Manning

File-system based routing

As explained in Crack Any Codebase with AI

File-based routing is a routing pattern in which filesystem paths determine the URL paths or other externally accessible routes.

File-system-based routing makes filesystem paths determine externally accessible routes. A route manifest can therefore begin with the directory tree rather than a centralized configuration file. section 8.2

In Cal.com, each TypeScript file under apps/api/v1/pages/api/ defines a REST endpoint, while its directory determines the URL path. The public REST routes coexist with tRPC routers that consolidate feature procedures. section 8.2

Read the route tree as both an API map and a record of architectural decisions:

  • Use ls or the file tree to locate filesystem routes and estimate the API surface. section 8.2
  • Treat sibling resource files as separate procedures, versioned directories as compatibility history, and parallel transports as distinct client channels. section 8.2
Figure 8.4 Four routing styles, and the effort required to map the full API for each. Filesystem routes are visible with ls; an aggregator file lists all routes in one place; decorator-scattered routes require scanning every handler; and a schema file defines the entire surface, one typed line per operation.

Compare filesystem routes with aggregator, decorator-scattered, and schema-defined routing by the effort required to map the full API. section 8.2

How Crack Any Codebase with AI covers it

How deep it goes
Explains path-to-URL mapping and architectural signals in conventions, without descending into handler implementation.
Examples
Uses Cal.com's Next.js API routes, tRPC holidays router, versioned booking directories, and parallel public and private transports.
What you can do after
Diagnose and map a framework's API surface from its file tree, then infer versioning and transport decisions.
How it connects
Connects filesystem routing with route manifests, REST APIs, tRPC routers, API versioning, and URL trees.

Also explained in

Compare how 3 books explain file-system based routing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Crack Any Codebase with AI. The section links point to the parts of the book it draws on.