chapter seventeen

17 Folder structure: The floor plan of your codebase

 

This chapter covers

  • Four layouts: monorepo, by-layer, by-feature, hybrid
  • Naming a repo's layout from its root, with AI
  • Having AI tell a real module from a junk drawer
  • Tracing one ticket through every layer with AI
  • Asking AI to flag the utils/anti-pattern

Chapter 16 used the test folder to see what a system promises. This chapter reads the file tree to find out where your next change actually goes. You clone a project you just inherited and open it in your editor. You see a src/, a lib/, and a handful of junk drawers like utils/, helpers/, common/, shared/, and core/. All of them seem to hold the same kind of small, disconnected functions. You know this is a subscription company, but there is no billing/ folder, which means that logic is hiding somewhere else. You start opening directories at random. Three levels down, you find an index.ts that re-exports a function from ../shared/lib/utils/helpers/format.ts. You ask your AI assistant for help, and it confidently points you to one directory when the real code spans three. Half an hour of clicking later, you have learned little beyond the fact that the original authors had no plan. You are tired before you read a single line of application code.

17.1 A repo's layout is a bet on what changes

17.2 The tree is the architecture, and tooling checks part of it

17.3 Read the root: Deduce the layout pattern

17.4 Open each folder: Contract or junk drawer?

17.5 Trace one ticket across every layer it touches

17.6 Summary