skip to content

In one web admin console codebase shared by five feature teams of 40 engineers, how would you draw feature-module seams and keep them from eroding?

level: principalimportance: should knowfreq 32%

answer

  1. folders follow teams and features
  2. one public entry per feature
  3. dependencies point one way
  4. the kernel's gravity
  5. a build rule plus a shrinking baseline

basics

~20 s

Group code by feature, give each feature one public entry as its only importable surface, keep a small owned shared kernel, and enforce the seams with an import-boundary build rule whose baseline of old violations only shrinks.

solid answer

~50 s

I'd give each team's product area a feature folder holding its components, state, API calls and tests, with one public entry file listing what others may import. Dependencies point one way: pages compose features, features use the shared kernel and the design system, and another feature only through its entry; a cycle between features means the seam is wrong. The kernel holds the HTTP client, auth session, formatting and design-system wrappers, has an owner, and admits code on the third genuine reuse, not the first. Erosion is stopped by the build: an import-boundary rule fails on deep imports or wrong-direction imports, a code-ownership file routes each entry to its team, and existing violations sit in a baseline that only shrinks. The judgment call is strictness: hard seams slow cross-cutting work, so I'd decide how exceptions are granted and watch cycles, kernel growth and multi-team pull requests.

code

pseudocode · 12 lines
pseudocode
src/
  app/            shell, routes, pages        may import: features/*/entry, shared, design-system
  features/
    orders/       entry  + internal files       may import: shared, design-system, other features' entry only
    customers/    entry  + internal files
    billing/      entry  + internal files
  shared/         http client, auth session, formatting, design-system wrappers
                                                may import: design-system

build rule: fail if an import reaches features/X/<anything but entry> from outside X
build rule: fail on any import pointing up the list above
baseline:   known violations listed; the list may only shrink

go deeper

for a junior

Recall the idea of grouping code by feature, with one public entry per feature that is the only thing other features may import.

for a middle

Explain the dependency direction from pages to features to the shared kernel to the design system, and why a cycle between two features means the seam is in the wrong place.

for a senior

Show how the seams are enforced: an import-boundary rule in the build, ownership routing for each entry, and a baseline of existing violations that may only shrink.

for a principal

Own the trade-offs: how strict the seams should be, how exceptions are granted, when folders become packages, and which signals tell you the organisation has outgrown the current cut.

## Group by feature, not by file type At five feature teams and forty engineers in one web codebase, the first decision is the top-level grouping. | Grouping | Example | Works when | Breaks when | |---|---|---|---| | **By file type** | `components/`, `services/`, `utils/` | small team, few features | every feature change touches five folders; ownership is unclear | | **By feature** | `features/orders/`, `features/billing/` | several teams, clear product areas | features need each other often and the seams are drawn wrong | Grouping by feature puts an order screen's components, its state, its API calls and its tests in one folder that one team owns. A change to orders stays inside `features/orders/`, and the folder's owner is obvious. ## A feature's public entry Each feature has **one public entry file** that lists what other code may use: a component such as a customer-name chip, a typed contract for an entity, a route definition. Everything else in the folder is internal. - Other features import **only from the entry**, never from a file deep inside. - The entry is small on purpose; adding to it is a design decision reviewed by the owning team. - Internals can be renamed and restructured freely, because nobody outside depends on them. ## The dependency direction 1. **The app shell and pages** compose features and own routing. 2. **Features** depend on the shared kernel and the design system, and on another feature only through its entry — ideally rarely. 3. **The shared kernel** depends on the design system only. 4. **The design system** depends on nothing in the app. A **cycle** between two features (orders imports billing, billing imports orders) is a seam drawn in the wrong place: either something belongs in the kernel, or the page should compose the two instead of one feature embedding the other. ## The shared kernel and its gravity The **shared kernel** holds what genuinely belongs to everyone: the HTTP client, the auth session, formatting, wrappers over the design system. It has an owner and stays small. Its pull is the main threat to the seams: - Code promoted to the kernel on its **first** reuse often carries one feature's domain with it. - Once in the kernel, it is everyone's dependency and no one's responsibility. - A common rule is to promote on the **third** genuine reuse and to keep domain logic in features, exposed through their entries. ## Enforcing it: the build, not good intentions Conventions erode under deadlines; a **build rule** does not. An **import-boundary rule** in the lint or build step fails the build when a file imports a feature's internals or breaks the layer direction. Around it: - a **code-ownership file** routes each feature's folder, and especially its entry, to the owning team for review; - existing violations are recorded as a **baseline** that may only shrink, so the rule can go in today without a big-bang cleanup; - metrics worth watching: baseline size over time, cycles between features, kernel growth, and pull requests that need approval from three or more teams. ## The calls with no single right answer - **How strict?** Hard boundaries slow cross-cutting work such as a new permission model touching every feature. Some teams allow a reviewed exception list; others insist the kernel absorbs the change. - **Cross-feature UI.** When orders shows a customer chip, the customers feature can export it, or the page can compose both. The first is simpler; the second keeps features unaware of each other. - **Folders or packages?** Separately built packages make the public surface explicit and enforced by the build, at the cost of tooling and versioning overhead. Still one deploy. - **Not microfrontends.** Everything above is one codebase, one build, one deploy. Splitting into independently deployed frontends is a different decision with runtime contracts and its own costs; seams in one codebase are often the cheaper first step. ## What a lead says in the round Draw the folders, the entry rule, the direction of dependencies and the kernel's admission rule; name the build rule that enforces them and the baseline that lets it start today; then say which trade-off you would pick for this organisation, and what signal would change your mind.

  • The orders screen must show a customer chip that the customers team owns. How does it get it?
    The customers feature exports the chip through its public entry, and orders imports it from there, never from the file inside. If the page can compose the two side by side instead, orders need not know customers at all. If the chip turns out to be domain-free and needed everywhere, it becomes a kernel candidate.
  • When would you turn feature folders into separately built packages?
    When folder rules are too easy to bypass or build times hurt. Packages make the public surface explicit and enforced by the build, at the cost of tooling and versioning overhead. They are still one deploy; independently deployed frontends are a separate decision with runtime contracts.
  • How do you tell that the seams are eroding before it hurts?
    Watch the baseline of violations, which should only shrink; cycles between features; how fast the shared kernel grows; and pull requests needing approval from three or more teams. Each one rising says the folders no longer match how work actually flows.

  • At forty engineers, grouping by file type keeps the codebase easiest to navigate.
  • Any file may import any other; code review will catch bad dependencies.
  • Promote code to the shared kernel the first time two features need it.
  • Feature seams only become real once each feature is deployed separately.
  • Features may import each other's internals when the teams agree informally.