A large React codebase does not stay workable by accident. Left alone it drifts toward one big folder where everything imports everything, state lives wherever it was first needed, and nobody can say who owns what. A few boundaries do most of the work of preventing that, and I have come to think they are as much about teams as about code.
A feature owns its state and exposes one surface
The first boundary is the feature folder, a directory that holds everything a feature needs, its components, hooks, state, and tests, with one index file that says what the rest of the application may use.
This keeps a feature's internals from being depended on by accident, and it gives each feature an owner, because a folder with a public surface is something a team can be responsible for in a way that a scattering of files cannot.
Data loads at the edges
The second boundary is where data comes from. I think fetching belongs at the edge of a feature, in a route or a top-level component, with the components below receiving what they need as props or context. When leaves fetch their own data, the same request happens five times, loading states multiply, and a change to the data shape becomes a hunt through the tree.
The component library lives apart
The third boundary is between the application and its component library. Buttons, inputs, dialogs, and layout primitives live in a separate package with stricter rules. No application imports, no business logic, accessibility built in, versioned changes. Application code uses the library, and the library never knows the application exists. A library that may import from a feature stops being a library.
Shared state has to earn its place
Most state in a React application is local and should stay with its component or feature. State goes global when more than one feature genuinely needs it, and that should be a deliberate decision with a name attached. A store anyone can add to becomes the big folder all over again.
A linter enforces it
The last boundary makes the others real, because every rule above can be a lint rule. No imports across feature folders except through the index, no fetching below a set depth, no application imports in the library, a review for anything added to the global store. Rules in the linter are enforced on every change by nobody in particular, the only enforcement that survives a busy quarter.
Boundaries are team boundaries
Each boundary is also a line on the org chart. A feature with a public surface can be owned. A component library that lives apart can have a team. I think a large codebase stays workable when its structure matches how its people are organized, and the boundaries are how that match is kept.
Photo source: https://photos.robertstowe.com/flowers
