Lesson 13: Architecture and Harmony
As projects grow, local excellence (good variable names, small functions) is not enough. You need system-level Vibe—the architectural harmony that dictates where files live and how modules interact.
Separation of Concerns (SoC)
Files and directories should be organized so that related functionality is grouped together, and independent concerns are kept separate.
Common Vibe-Friendly Directory Structure
Instead of dumping everything into a single src folder, separate by technical role:
controllers/: Handles incoming requests (HTTP layer).services/: Contains core business logic (the 'why' of the application).repositories/ordata/: Handles data access (database interaction).utils/: Generic, reusable helper functions.
This structure gives a new developer an immediate map of the system: they know exactly where to look to modify the database layer versus changing a web route.
Decoupling and Dependencies
High Vibe code is loosely coupled. Modules should rely on abstractions (interfaces) rather than concrete implementations. This prevents 'ripple effects' when one module changes.
Inversion of Control (IoC)
Allowing higher-level modules to define the behavior for lower-level modules (often implemented via Dependency Injection) results in highly testable and flexible code, providing the best long-term architectural vibe.