Bottleneck
A modern, AI-assisted dev process often splits into two iterative phases:- Research & Planning: Using a large-context AI (like Gemini 2.5 Pro) to analyze an existing feature, brainstorm solutions, or draft a technical specification. This requires providing the AI with all the relevant code for that feature.
- Implementation: Using a specialized coding agent or CLI tool to translate the plan from the research phase into clean, functional code.
Types Driven
app/, components/, hooks/, trpc/, and zustand/.
This manual process of curating a “context package” is a bottleneck. It breaks your development flow and makes it harder to get accurate, contextual responses from your AI.
Solution
A feature-first (or feature-based) architecture solves this problem by reorganizing the project around functionality rather than file types. The core idea is to create a new top-levelfeatures/ directory, where each subdirectory is a self-contained module representing a distinct part of your application.
Here is the same project, refactored for a feature-first approach:
Feature Driven
src/features/: This is the new home for all feature-specific logic. Each feature, likeprofile, is a self-contained module with its own components, hooks, API endpoints, and state management.src/components/: This directory is now reserved for truly global components. This includes your UI primitive library (likeshadcn/ui) and application-wide components like the main navigation or footer.src/lib/,src/hooks/,etc.: Top-level directories like these are now used only for genuinely global, cross-cutting concerns that are shared across multiple features.
Speed, Scalability, and Sanity
Adopting a feature-first structure yields immediate and long-term advantages that extend beyond just AI collaboration.AI Workflow Efficiency
This is the most significant and immediate payoff. Instead of spending time manually gathering scattered files, you can now easily create comprehensive context for an AI using tools like Repomix by simply pointing to the feature directory:src/features/profile.
Fluid Developer Experience
By grouping related code, features become modular and decoupled. This makes the entire codebase easier to navigate.- Onboarding: New developers can quickly understand a feature by exploring a single directory.
- Debugging: When a bug appears in the user profile, you know exactly where to look.
- Refactoring & Deletion: Modifying or removing a feature becomes a trivial task. You can confidently change or delete a feature’s directory without worrying about leaving orphaned files scattered across the repository.
