Folder Structure
What you'll learn
~15 min- Recognize three common project structure patterns (static site, web app, API)
- Understand the src/ convention and why nearly every project uses it
- Direct an AI to place files in the correct location using structural knowledge
- Read a project tree and identify where new files should go
By the end of this lesson, you’ll be able to glance at any project’s folder structure and know where things belong — so you can give precise directions to your AI assistant instead of vague ones.
The Mental Model: A Filing Cabinet
Think of project structure like a filing cabinet in an office. You could throw every document into one drawer and technically find things eventually. But a well-organized cabinet has labeled drawers, tabbed folders, and a consistent system that anyone can follow.
The same principle applies to software projects:
- One drawer for pages (what visitors see)
- One drawer for reusable pieces (headers, buttons, cards)
- One drawer for styles (how things look)
- One drawer for utilities (helper tools)
When you tell an AI “add a new page,” it needs to know which drawer to open. That is your job as the orchestrator.
Why Structure Matters
You could throw all your files into one folder and things would technically work. But as projects grow, organization becomes essential. Good structure means:
- You (and the AI) can find things quickly
- Related files live together
- New files have an obvious home
- The project is understandable at a glance
Here is a concrete comparison. Imagine a project with 20 files:
Disorganized (everything in one folder):
my-project/├── Header.jsx├── app.js├── about.html├── auth.js├── button.css├── contact.html├── footer.css├── format.js├── global.css├── header.css├── index.html├── logo.png├── main.js├── nav.css├── package.json├── photo1.jpg├── photo2.jpg├── sidebar.jsx├── validate.js└── README.mdOrganized (grouped by purpose):
my-project/├── src/│ ├── components/ <- Reusable UI pieces│ │ ├── Header.jsx│ │ └── Sidebar.jsx│ ├── pages/ <- Each page of the site│ │ ├── index.html│ │ ├── about.html│ │ └── contact.html│ ├── styles/ <- All stylesheets│ │ ├── global.css│ │ ├── header.css│ │ ├── nav.css│ │ ├── footer.css│ │ └── button.css│ ├── scripts/ <- Application logic│ │ ├── app.js│ │ ├── main.js│ │ └── auth.js│ └── utils/ <- Helper functions│ ├── format.js│ └── validate.js├── public/ <- Static assets│ ├── logo.png│ ├── photo1.jpg│ └── photo2.jpg├── package.json└── README.mdSame 20 files. The organized version tells a story at a glance: this is a website with three pages, a couple of reusable components, custom styles, some application logic, and helper utilities. You can direct the AI with confidence: “Add a new page in src/pages/” or “Create a date formatting helper in src/utils/.”
Common Patterns
Pattern 1: Simple Static Site
For basic HTML/CSS/JS websites:
my-site/├── index.html├── about.html├── css/│ └── style.css├── js/│ └── main.js├── images/│ └── logo.png└── README.mdRule: Group files by type (CSS together, JS together, images together).
Pattern 2: Modern Web App
For projects using a framework (React, Astro, Next.js, etc.):
my-app/├── src/│ ├── components/ <- Reusable UI pieces│ │ ├── Header.jsx│ │ ├── Footer.jsx│ │ └── Button.jsx│ ├── pages/ <- Each page of the app│ │ ├── index.jsx│ │ ├── about.jsx│ │ └── contact.jsx│ ├── styles/ <- Stylesheets│ │ └── global.css│ └── utils/ <- Helper functions│ └── format.js├── public/ <- Static assets│ ├── favicon.ico│ └── images/├── package.json├── README.md└── .gitignoreRule: Group files by function (components, pages, styles, utilities). Note: frameworks differ in specifics — for example, Next.js often uses app/ instead of src/pages/, and Astro uses src/pages/. The organizational principle (group by function) is the same.
Pattern 3: API / Backend
For server-side applications:
my-api/├── src/│ ├── routes/ <- API endpoints│ │ ├── users.js│ │ └── products.js│ ├── models/ <- Data structures│ │ ├── user.js│ │ └── product.js│ ├── middleware/ <- Request processing│ │ └── auth.js│ └── index.js <- Entry point├── tests/ <- Test files│ ├── users.test.js│ └── products.test.js├── package.json└── .env <- Environment variables (secrets)Rule: Group files by architectural role (routes handle requests, models define data, middleware processes requests in between).
Pattern 4: Python Data Project
For data analysis, research scripts, and CLI tools:
my-analysis/├── src/│ ├── __init__.py│ ├── main.py <- Entry point│ ├── loader.py <- Data loading and cleaning│ └── visualize.py <- Chart generation├── data/│ ├── raw/ <- Original data (never edit)│ └── processed/ <- Cleaned output├── output/ <- Generated reports, charts├── tests/│ └── test_loader.py├── requirements.txt└── README.mdRule: Separate raw data from processed data and output. Source code in src/, never edit files in data/raw/.
You may also encounter domain-specific structures outside web apps. Here are two examples from other fields:
🧬In Your Field: Biotechclick to expand
Bioinformatics projects often follow a pattern that mirrors the scientific method. You will see structures like this:
gene-expression-analysis/├── data/│ ├── raw/ <- Original FASTQ/CSV files (never edit)│ ├── processed/ <- Cleaned, normalized data│ └── reference/ <- Genome references, annotations├── scripts/│ ├── 01-preprocess.py│ ├── 02-align.py│ └── 03-analyze.py├── results/│ ├── figures/│ └── tables/├── docs/│ └── methods.md└── README.mdNotice the numbered scripts — they run in order, just like steps in a protocol. Raw data stays untouched (like preserving original samples), and results are generated from scripts that can be re-run. When you ask an AI to set up a bioinformatics pipeline, you can reference this pattern: “Organize it like a standard bioinformatics project with raw data, scripts, and results separated.”
📊In Your Field: MIS / Businessclick to expand
Business analytics projects often need to separate data sources from dashboards from reports:
sales-dashboard/├── src/│ ├── components/│ │ ├── RevenueChart.jsx│ │ ├── KPICard.jsx│ │ └── FilterBar.jsx│ ├── pages/│ │ ├── overview.jsx│ │ └── regional.jsx│ └── utils/│ └── formatCurrency.js├── data/│ ├── sales-2024.csv│ └── regions.json└── package.jsonThe data/ folder keeps your source data separate from the code that visualizes it. When you ask an AI to build a dashboard, specifying this separation up front means you can swap in new data files without touching any code. Tell the AI: “Keep the data files in a separate data/ folder so I can update them independently.”
Key Naming Conventions
| Convention | Example | When to use |
|---|---|---|
kebab-case | my-component.jsx | Common for HTML/CSS files and some frameworks |
PascalCase | MyComponent.jsx | React/JSX component files |
camelCase | formatDate.js | Utility function files, common in JavaScript |
snake_case | data_loader.py | Common in Python projects |
| Plural folders | components/, pages/, utils/ | Usually for folders containing multiples (though config/, lib/ are singular) |
src/ | Source folder | Many modern projects |
Naming conventions vary by language and framework — the code works regardless of casing. The best rule of thumb: look at the existing files the AI generated and follow the same style. When an AI tool scaffolds a project, it follows standard conventions for that framework automatically. Consistency matters more than which specific convention you use.
The src/ Convention
Many modern projects use a src/ folder (though not all — some frameworks use app/ or keep files at the root). src/ stands for “source” — it contains the code you write (or that the AI writes for you). Outside src/ you will often find configuration, static assets, tests, scripts, and dependency/build folders.
project/├── src/ <- YOUR code lives here├── node_modules/ <- Downloaded dependencies (don't touch)├── dist/ <- Build output (generated, don't touch)├── package.json <- Configuration└── README.md <- DocumentationThe simple rule: When in doubt, put it in src/.
This is like the “working area” of a lab bench. The src/ folder is where the active work happens. Everything else is either supplies (node_modules), output (dist), or labels (package.json, README.md).
Worked Example: Directing the AI with Structure
Let’s say an AI created this project for you:
campus-events/├── src/│ ├── components/│ │ ├── EventCard.jsx│ │ ├── Header.jsx│ │ └── SearchBar.jsx│ ├── pages/│ │ ├── index.jsx <- Homepage│ │ └── event/[id].jsx <- Individual event pages (brackets = dynamic route)│ ├── styles/│ │ └── global.css│ └── utils/│ └── formatDate.js├── public/│ └── images/├── package.json└── README.mdNow your stakeholder asks for four new features. Here is how you would direct the AI for each one:
| Request | What you tell the AI | Why |
|---|---|---|
| ”Add a calendar view" | "Create a CalendarView component in src/components/” | It is a reusable UI piece |
| ”Add an admin page" | "Create an admin page at src/pages/admin.jsx” | It is a new page |
| ”Add event category icons" | "Put the icon files in public/images/icons/” | Static assets go in public/ |
| ”Add a function to filter events by date" | "Add a filterByDate function in src/utils/” | It is a helper function |
You do not need to know how to code these features. You need to know where they belong so the AI puts them in the right place.
What AI Tools Generate
When you tell Claude Code or Gemini CLI to “create a React app,” the tool will generate a standard project structure automatically. It follows the conventions of whatever framework it is using.
Your role as an orchestrator:
- Understand what the folders mean (not every file, just the pattern)
- Direct the AI to the right location: “Add a new component in src/components/”
- Verify things are in logical places
- Reorganize if something feels off: “Move the utility functions to src/utils/“
When Things Go Wrong
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Building Your Intuition
You do not need to memorize folder structures. You need to develop an intuition for where things belong. Here is how:
- When an AI creates a project, look at the structure and understand the top-level folders
- When you need to add something, think: “Is this a component, a page, a style, or a utility?” and direct the AI to the right folder
- When something feels disorganized, ask the AI: “Reorganize this project to follow standard conventions”
Quick commands for exploring structure:
# See top-level structurels
# See recursive structure (if tree is installed)tree -L 2
# Create standard folders for a new projectmkdir -p src/{components,pages,styles,utils} public/images
# Move a misplaced filemv src/pages/DataTable.jsx src/components/DataTable.jsxOver time, this becomes second nature. You will glance at a project structure and immediately understand where everything is and where new things should go.
Key Takeaways
- Structure = communication. A well-organized project tells you (and the AI) where everything belongs at a glance
- Three common patterns: static sites group by file type, web apps group by function, APIs group by architectural role
- The
src/folder is where your code lives — everything else is configuration, dependencies, or output - Your orchestrator job is to read the structure and direct the AI to the right location: “Put this component in
src/components/” - When the AI makes a mess, ask it to reorganize — you do not need to move files manually
🔍Configuration files at the root
You will often see files like astro.config.mjs, tailwind.config.mjs, tsconfig.json, or .eslintrc sitting at the project root. These are configuration files for various tools. The AI can edit config files for you, but always review the changes and rerun your app/tests to make sure nothing broke. Each config file controls a specific tool (Astro, Tailwind, TypeScript, ESLint), and they live at the root because that is where those tools look for them by convention. Think of them as the “settings panel” for each tool in your project.
You need to add a reusable chart component to a project that has src/components/, src/pages/, and src/utils/ folders. Where should it go?