Why app structure matters
Split responsibilities so features stay understandable as the app grows.
By the end, you can recognize a risky all-in-one implementation and propose sensible boundaries.
Step 1: Name the responsibilities
A café has a counter, order book, and delivery desk. Replacing the delivery company should not require rebuilding the counter. A form similarly displays input, checks it, saves a , and may send an email. Those jobs have different reasons to change.
Step 2: Make the handoffs visible
A boundary is where one responsibility hands work to another. A page route chooses what to show; components represent interface parts; checks accepted input; server behavior handles trusted saves and provider calls. The browser can initiate the flow, but must not contain private provider keys.
Step 3: Ask for a map before moving code
Ask AI to show which responsibilities are mixed and which separation solves a concrete change problem. Reusable code can reduce duplication, but splitting every line creates a maze. File length alone does not tell you whether the design is clear.
Step 4: Preserve behavior through the move
Inspect a small refactor and repeat the original flow, including failures. When a saves but its email fails, report the saved separately from notification status. When only a visible label changes, do not rename stored fields unnecessarily. If the must change, support old readers while migrating them.
Map form display, , saving, and email delivery. Propose the smallest separation that makes email failures understandable and keeps private provider work on the server. Preserve the existing form behavior. Explain every extra dependency or schema change before editing. Illustrative before / after (behavior, not ready-to-run code): - Browser component: layout + private key + save + email + Screen → validated server save → separate notification outcome
The map describes responsibilities, not a required number of files. A boundary is useful when it clarifies behavior or enables a justified independent change.
Sources and further reading
A -form file mixes screen layout, input checks, saving, and email delivery. It is hard to fix email failures without touching the screen. What should the AI propose?
Choose one answer.