1. Barrel file
A barrel index.ts is the single entry point; it defines exactly what the module exposes.
// index.ts — the module's barrel: only the public surfaceTyporithm · easy
Step 1 of 8 · intro card
App Patterns
A module exposes a small public API through a barrel index and keeps its helpers private. Re-export only what callers need; everything else stays an internal detail, giving low coupling and high cohesion.
A module groups related code behind a clear boundary: a public API that callers use, and internals that nobody outside should touch.
A barrel index.ts is that boundary — it re-exports only the public surface, like createUser and the User type, while validate and hash stay unexported and therefore private.
Hiding internals keeps coupling low (consumers depend only on the stable API) and cohesion high (everything inside the module works toward one purpose).
The barrel re-exports only the public API.
Unexported helpers stay private internals.
Low coupling, high cohesion follow from the boundary.
// index.ts — the module's barrel: only the public surface
export { createUser } from "./create-user";
export type { User } from "./types";
// helpers like ./validate and ./hash stay privateConnect each part of the code to the concept before you type.
A barrel index.ts is the single entry point; it defines exactly what the module exposes.
// index.ts — the module's barrel: only the public surfaceOnly createUser is re-exported, so it becomes part of the module's public API.
export { createUser } from "./create-user";The User type is published too, while its internal construction stays hidden.
export type { User } from "./types";Files not re-exported from the barrel remain implementation details no consumer can reach.
// helpers like ./validate and ./hash stay privateRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.