← Back to React Course | Chapter 13: Advanced React & Architecture | Lesson 9 of 14

Scalable Folder Architecture

Folder architecture is like organizing a kitchen — knives in one drawer, spices in another — so you can find what you need quickly, no matter how big the kitchen gets.

Simple Structure for Small Apps

For a small app, a flat structure — one components/ folder, one hooks/ folder, maybe a utils/ folder — is often perfectly sufficient and easy to navigate. Adding more elaborate structure before it's actually needed can add friction without real benefit.

Note: Start simple. You can always reorganize into a more elaborate structure later once the app's real shape becomes clear.

Warning: Over-engineering folder structure for a project with 5 components can make the codebase feel more complicated than it actually is.

Example: Creating a Flat Folder Structure

bash
$ mkdir -p src/components src/hooks src/utils
$ ls src
components  hooks  utils  App.jsx  main.jsx

⚠️ Run this command in your terminal.

Feature-Based Structure for Larger Apps

As an app grows, grouping files by FEATURE (all of a shopping cart's components, hooks, and logic together in one features/cart/ folder) rather than by file TYPE keeps related code physically close together, making it easier to find everything relevant to one feature at once.

Note: A good signal you've outgrown a flat structure: you frequently need to jump between several distant folders just to work on one feature.

Warning: Mixing both organizing principles inconsistently (some features grouped, others scattered by type) is often more confusing than picking either approach and sticking with it.

Example: Creating a Feature-Based Folder Structure

bash
$ mkdir -p src/features/cart/components src/features/cart/hooks
$ ls -R src/features/cart
src/features/cart:
components  hooks  cartSlice.js  CartPage.jsx

src/features/cart/components:
CartItem.jsx  CartSummary.jsx

⚠️ Run this command in your terminal.

Consistency Over Perfection

There's no single universally correct folder structure — different teams and frameworks favor different conventions successfully. What matters most is picking ONE approach and applying it consistently, so anyone on the team (or future you) can predict where to find or add a given file.

Note: Document your project's chosen convention briefly (even a short README section) so new contributors don't have to guess.

Warning: A codebase with several competing, inconsistently-applied organizing schemes is often harder to navigate than one with a single, simpler, consistently-followed convention.

Common Mistakes
  1. Organizing purely by file TYPE (one giant components folder, one giant hooks folder) instead of by FEATURE, making related files scattered far apart.
  2. Over-engineering folder structure for a tiny app that doesn't need it yet.
  3. Not having any consistent convention at all, letting each contributor organize files differently.
Chapter Summary
  • Small apps can stay simple: a flat components/ folder is often enough.
  • Larger apps often benefit from feature-based folders (features/cart/, features/auth/) grouping related components, hooks, and logic together.
  • Consistency matters more than any one correct structure — pick a convention and apply it uniformly.
  • Folder structure should evolve with the app; premature over-organization can add friction early on.
Browser Support

No React-version restriction — this is a project organization convention, not an API.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.