skip to content

In a large mobile app's design, what do the app module, feature modules and core modules each hold, and which way may dependencies point?

level: juniorimportance: should knowfreq 33%

answer

  1. a feature is a screen or a flow
  2. core is reused and owns no flow
  3. the app module assembles and starts
  4. arrows point down, never back up
  5. no reaching into another feature

basics

~20 s

Feature modules hold one user-facing flow; core modules hold code many features reuse, such as UI components, networking and a domain's data; the app module is the entry point that assembles them. Dependencies point app to feature to core, never upward.

solid answer

~40 s

A **feature module** owns one user-facing capability, a screen or a closely related flow such as ordering food or topping up a wallet, with its UI, its view models and its feature logic. **Core** (also called shared or common) modules hold what many features reuse and no single feature owns: the design-system components, the HTTP client setup, analytics, formatting helpers, and data modules that expose one domain's repository. The **app module** is the entry point: it depends on every feature, provides the root navigation and wires implementations together. The rule is one-directional, app to feature to core. A core module never depends on a feature, and features don't reach into each other's internals; when two features must cooperate, they go through a small contract module or through code the app module wires.

go deeper

for a junior

Recall the three kinds by what they hold: a feature owns a flow, a core module is reused by many, the app module assembles and starts the app. Then state the direction: app to feature to core.

for a middle

Explain why the direction matters: an upward edge from core to a feature drags feature code into every consumer and invites a cycle. Place a data module and a design-system module correctly and say why.

for a senior

Show judgment when placement is ambiguous: code used by two features moves down into core or into a contract module, never sideways. Name the hub risk of a growing common module before it happens.

for a principal

Treat the kinds as an ownership map: feature modules belong to product teams, core and app modules to a platform group with a stricter review bar. Weigh what each extra module costs against what it isolates.

## Why a large app is split into modules A **module** here is a unit the build system compiles separately, with its own declared dependencies and its own public surface. Splitting one app binary into modules is not about shipping several apps: everything still ends up in one installed binary. It is about three things that get worse as a codebase and its team grow: - **Build time**: a change should rebuild the part of the app it touches, not all of it. - **Encapsulation**: a module can hide everything except a deliberate public surface, so other code cannot grow a dependency on its internals. - **Ownership**: a module can belong to one team, which reviews its changes and fixes its bugs. Take the super-app this topic uses throughout: ride-hailing, food delivery and a wallet in one binary, built by about 60 engineers in eight feature teams. Without modules, all of that is one compilation unit, and every team edits it at once. ## The three kinds of module | Kind | What it holds | Who depends on it | Example in the super-app | |---|---|---|---| | **App module** | The entry point, root navigation, and the wiring that binds implementations together | Nothing depends on it | The module that produces the installed binary | | **Feature module** | One user-facing flow: its screens, view models and feature logic | The app module; other features use only its API module, if it has one | Ride booking, food ordering, wallet top-up | | **Core module** (shared, common) | Code many features reuse and no feature owns | Features, other core modules, the app module | Design-system components, the HTTP client setup, analytics, a payments data module | A **data module** that exposes one domain's repository, and hides that domain's network and disk sources behind it, is a core-tier module: several features may read payments data, so it cannot live inside any one of them. ## Which way the arrows point The dependency graph has a direction, and the direction is the design: 1. The **app module** depends on feature modules and on any core module it needs for wiring. 2. **Feature modules** depend on core modules, and on another feature only through that feature's small contract (an API module), never its implementation. 3. **Core modules** depend on other, more basic core modules and outside libraries, never on a feature. 4. The graph has **no cycles**: if two modules each needed the other, neither could be built first. Read top to bottom, the graph narrows: many features over a smaller set of core modules over a few foundations. Code that changes often (features) sits above code that changes rarely (core), so the frequent changes affect few modules and the rare ones are the only ones that ripple widely. ## What goes wrong when the kinds blur - **A core module that imports a feature** turns every consumer of that core module into an indirect consumer of the feature. The arrow now points up, and a cycle is one edit away. - **A feature that imports another feature's implementation** couples two teams: the ride feature recompiles when the wallet's screens change, and the wallet team can no longer refactor freely. - **A grab-bag common module** that collects every shared helper becomes a **hub**: nearly everything depends on it, so any edit to it puts most of the graph at risk of rebuilding and puts every team in its review path. Split it by purpose instead: UI components, networking, formatting. - **Business logic in the app module** makes the module that depends on everything also the one that changes most, which is the worst place for churn. ## Where shared code goes When two features need the same piece of code, it moves **down**, into a core module both depend on, or into a contract module the owning feature publishes. It never moves **sideways**, with one feature depending on the other to reach it. That single rule, applied every time the question comes up, keeps the graph a clean funnel from the app module down to the foundations. How one feature opens another feature's screen is a separate question about route contracts; this one is only about which module may depend on which.

  • Where does a data module that exposes a payments repository sit, core or feature?
    It sits in the core tier: its public surface is one domain's repository, its data sources stay hidden, and several features may depend on it. Putting it inside the wallet feature would force every other feature that needs payments data to depend on the wallet feature, which is exactly the sideways edge the graph forbids.
  • Is one common module that everything depends on a good core module?
    Only while it stays small and stable. A grab-bag of unrelated helpers becomes a hub: almost every module depends on it, so each edit risks rebuilding most of the app and drags every team into its review. Split it by purpose so a change reaches only the modules that use that piece.

  • A core module may depend on a feature module when it needs that feature's data.
  • Features should import each other's classes directly; contracts between them are ceremony.
  • The app module is the natural home for most of the business logic.
  • One shared module that every other module depends on has no effect on build time.
  • Modules are only folders; the build does not need to know where the boundaries are.