Project structure

Next.js folder structure.

In a Next.js project the folders are the routes: each folder inside app is a URL segment, and a few special file names decide what that segment shows. This page lays out the conventional structure, then shows a real open-source project mapped by Nodeway.

Free to start. macOS (Apple silicon and Intel), Windows and Linux.

The conventional layout

A typical project on the App Router, with the optional src folder:

  • src/app/The routes. Every folder is a segment of the URL.
  • layout.tsxThe root layout, wrapped around every page.
  • page.tsxThe page shown at /.
  • blog/[slug]/page.tsxA dynamic segment: one page for /blog/anything.
  • (marketing)/A route group: shares a layout without adding to the URL.
  • api/users/route.tsA route handler that exports GET, POST and the other methods.
  • loading.tsx, error.tsxLoading and error states for the segment they sit in.
  • src/components/Shared UI components.
  • src/lib/Helpers, data access and other code that is not a route.
  • public/Static files, served from the site root.
  • middleware.tsRuns before matching requests. Named proxy.ts from Next.js 16.
  • next.config.tsNext.js settings.

The rules that matter

  • A folder is only reachable when it has a page.tsx or a route.ts. Other files in it, such as components, are not served.
  • A folder starting with an underscore, like _components, is private: it and everything inside it is left out of routing.
  • Square brackets make a dynamic segment ([id]), and [...slug] catches every segment after it.
  • The older Pages Router uses a pages folder instead, with API routes under pages/api. Both can live in one project while it moves over.

A real example: Umami

umami-software/umami is a privacy-focused web analytics platform. Nodeway mapped it at commit dbb8d60, from 23 November 2026. Most of it is TypeScript: 1,245 files of 1,266, followed by JavaScript (18) and Shell (2).

It uses the src folder. Every one of its routes, pages and API route handlers alike, is under src/app; shared UI sits in src/components, and most of the code that reads and writes the database is in src/queries. Its tables are defined in a Prisma schema in the top-level prisma folder.

Source files
1,266
Functions and classes
2,149
Confirmed calls
4,478
Routes
275
Tables
29

Its folders

  • src/1,183 files275 routes
  • app/687 files275 routes
  • components/289 files
  • queries/101 files
  • lib/70 files
  • openapi/13 files
  • permissions/10 files
  • packages/40 files
  • mcp/package33 files
  • api-client/package7 files
  • scripts/30 files
  • seed/11 files
  • .eloqnt/1 file
  • docker/1 file
  • podman/1 file
  • prisma/1 file29 tables

Routes

Nodeway found 275 routes, 64 of them pages, and linked 275 to the function that handles them. The rest by HTTP method: GET 126, POST 64, DELETE 17, OPTIONS 3, PATCH 1. All are under src/app (275).

Some of them

RouteMethod
/mcpDELETE · src/app/mcp/route.tsDELETE
/api/meGET · src/app/api/me/route.tsGET
/p/[slug]GET · src/app/(collect)/p/[slug]/route.tsGET
/q/[slug]GET · src/app/(collect)/q/[slug]/route.tsGET
/api/sendPOST · src/app/api/send/route.tsPOST
/api/batchPOST · src/app/api/batch/route.tsPOST
/api/linksGET · src/app/api/links/route.tsGET
/api/sharePOST · src/app/api/share/route.tsPOST

Data model

Nodeway found 29 database tables, defined with Prisma. Code in the repository reads or writes 29 of them. The most used:

TableUsed by
website12 columns · links to team and user · prisma/schema.prisma10 read8 write
team_user6 columns · links to team and user · prisma/schema.prisma7 read6 write
two_factor_auth6 columns · links to user · prisma/schema.prisma8 read5 write
share8 columns · prisma/schema.prisma4 read7 write
team8 columns · prisma/schema.prisma6 read5 write
board9 columns · links to team and user · prisma/schema.prisma3 read6 write
link9 columns · links to team and user · prisma/schema.prisma3 read5 write
pixel8 columns · links to team and user · prisma/schema.prisma3 read5 write

The full map, with its entry points, a traced request and the most-called code, is on the Umami architecture page.

See your own project's structure

Nodeway reads a Next.js project on your own computer and draws its folders, files, functions, routes and tables, with the imports and calls between them. Open a folder and the map is drawn locally; nothing is uploaded. The getting started guide covers installing it, and the repo maps show 31 open-source projects mapped the same way.

Questions

Should I use a src folder in Next.js?

It is optional. Next.js finds app, pages and the other special folders either at the project root or inside src. Putting them in src keeps application code apart from configuration files at the root.

Where do API routes go in the App Router?

In a route.ts (or route.js) file inside app. The folder path is the URL, and the file exports functions named after HTTP methods, such as GET and POST. A folder can hold a page.tsx or a route.ts, not both.

What does a folder in parentheses mean?

It is a route group. A folder named like (marketing) groups routes and can give them their own layout, but its name is left out of the URL.

See your whole codebase in minutes.

Open a folder and Nodeway maps it on your own computer. No account, and nothing is uploaded.

More guides