Structure
Arrange code so dependencies point one way, folders follow features, files are easy to find, and no module depends on itself through a loop.
- Required 2
- Recommended 2
Required
Point dependencies inward
RequiredBusiness rules never import the web framework, the database or other outside services. Outer layers depend on inner ones, never the reverse.
Allow no dependency cycles
RequiredNo module may depend on itself through a chain of imports. Cycles make code impossible to test, load or change on its own.
Recommended
Group code by feature
RecommendedPut the code for one feature together, such as
orders/orinvoices/, instead of spreading it across folders namedcontrollers/,models/andservices/.Name files after what they hold
RecommendedUse one naming style for files and folders, and name each file after its main export.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/structure.