Frontend Engineering
Frontend architecture that scales with teams
Boundaries, state and contracts that keep product delivery moving.
Williams Madu · · 9 min read
How to organise frontend systems around change, ownership and observable user outcomes instead of folder fashion.
Structure follows change
A frontend architecture should make frequently changing product behavior easy to locate. Grouping code by capability usually gives teams a clearer ownership model than grouping every file by technical type.
A useful boundary contains UI, state, validation, analytics and API knowledge for one product capability. It prevents product rules from leaking everywhere.
The folder structure is not the achievement. The achievement is that a developer can reason about a user flow without opening twenty unrelated files.
Treat server state honestly
Server data is not ordinary component state. It has freshness, ownership, permissions, background changes and failure concerns. Pretending it behaves like local UI state creates interfaces that look stable while behaving unpredictably.
A clear request boundary turns network behavior into product states: loading, empty, stale, optimistic, failed and recovered.
This is especially important for dashboards, payment flows and admin tools where one incorrect assumption can become a business incident.
Build contracts between frontend and backend
Strong frontend delivery depends on stable API contracts. The client should know which fields are public, which values can be absent and which state transitions are supported.
Contract clarity reduces defensive code and makes design review sharper. Product decisions become visible in names, types and documented examples.
A good contract also protects future teams. They can extend the product without accidentally depending on private backend details.
Design components around responsibility
A component should have a clear reason to exist. Some components express visual language. Some coordinate a product workflow. Some integrate with external state.
Reusable components should make the correct path easier, not force every screen to pass a long list of overrides.
The goal is a design system that helps teams move faster without flattening every product problem into the same visual template.
Design a UI contract that survives network reality
Every remote view needs more than a successful array response. It must represent loading, empty, ready, stale and recoverable error states. Distinguishing these conditions prevents a blank screen from being mistaken for an empty database and stops a failed request from silently replacing valid content.
A consistent data boundary can normalize field names, dates, pagination and media URLs before they reach presentation components. That keeps components focused on semantic rendering and makes it easier to replace a backend without rewriting the entire design system.
- Use stable query keys for server-owned data and invalidate them after writes.
- Keep pagination metadata with each response instead of guessing total pages.
- Normalize absolute versus relative media URLs in one place.
- Preserve focus, keyboard order and live status announcements when data changes.
- Treat stale data as a deliberate policy, not an accidental fallback.
Further reading and references:
type RemoteData<T> =
| { status: 'loading' }
| { status: 'ready'; data: T; updatedAt: number }
| { status: 'empty' }
| { status: 'error'; message: string; retryable: boolean }
function assertNever(value: never): never {
throw new Error(`Unhandled UI state: ${JSON.stringify(value)}`)
}Explicit states make UI acceptance and error recovery easier to reason about.
Keep abstractions smaller than the problem
A shared component earns its place when multiple use cases depend on the same behavior and the abstraction makes correct usage easier. Premature generalization often creates a configurable component with dozens of flags and no clear responsibility.
Prefer capability-level folders and small public interfaces. A blog feature can own its API adapter, rich-text renderer, article layout, pagination and tests; the global design system should own tokens, typography, focus styles and common controls.
- Identify the real state and ownership boundaries.
- Extract stable presentation primitives only after repeated use.
- Write contract tests around normalization and rendering.
- Test a realistic mobile viewport and slow connection.
- Review component APIs after the next feature is delivered.
A reusable component is successful when it reduces decisions for its consumers, not when it exposes every possible option.