frontend-foundation

Architecture — Frontend Foundation

Purpose

Frontend Foundation is designed as a long-lived, swap-friendly Next.js starter. Its primary goal is to ensure that UI code is never coupled to:

This enables teams to evolve technology choices without refactoring UI or business logic.


Core Principles

1. Inversion of Control (Frontend-First)

UI components never import:

Instead, UI interacts only with hooks and services.


2. Implicit Hexagonal Architecture

This repository follows hexagonal principles without academic folder names.

The separation exists by responsibility, not by theory labels.

This mirrors how modern production frontends are actually built.


3. Swap-ability as a First-Class Constraint

Every major concern is isolated behind a boundary:

No UI changes are required when swaps occur.


Folder Responsibilities

src/app - Routing and layouts only. No business logic.

src/components - Pure presentational components. No side effects.

src/hooks - The ONLY API UI code is allowed to consume. Example: useAuth, useTheme, useDashboard.

src/services - Business intent and orchestration. Example: loginUser, loadDashboardData.

src/clients - Low-level adapters for HTTP, CMS, or external services.

src/stores - State adapters. Storage mechanism is irrelevant to consumers.


What This Architecture Explicitly Avoids


Why This Matters

This structure: