ATL-2026-026engineering_noteexploratory

Clean Architecture ends at the module boundary. What happens next?

Tasks and reports interpret one membership differently. How to choose between a shared model, separate representations, a contract and events.

Published
October 28, 2026
Verified
October 27, 2026

Clean Architecture ends at the module boundary. What happens next?

An application has projects. Project members can create tasks and publish reports. One module manages members, another handles tasks, and a third handles reports. Each has its own domain, data, and presentation layers. Dependencies point in the intended direction, and the individual module tests pass.

Then the product introduces temporary suspension. A suspended person remains a project member, but can no longer create tasks or publish reports. The members screen already shows the new status. Task creation is blocked too. Yet the person can still submit a report: the reports module knows nothing about the new state.

The example is hypothetical, but the problem is real enough: each module can be neatly structured while a rule that must apply in several places gradually drifts apart.

One response is to put the project member in shared and use the same class everywhere. Another is to keep a separate model in each module so they do not depend on one another. Both can work. Neither the name of a shared folder nor the absence of an import from a neighbouring module answers who owns the rule and how others learn when it changes.

What the modules actually share

The example concerns one user's membership in a particular project. It has its own identifier, the user and project identifiers, and a state. Temporary suspension does not change the membership identifier. Member management creates the membership and changes its state; tasks and reports use it to decide whether an action is allowed.

For simplicity, both features follow the same rule: an active membership permits task creation and report publication; a revoked or suspended membership forbids them. Role-based permissions, reinvitations, and other conditions are outside this example. These are assumptions for the comparison, not a universal access model.

That distinction is easy to miss. A catalogue product and a line on a completed order are related, but follow different rules: a catalogue price change need not alter an old order's total. They are not two copies of one entity with the same lifecycle. In this example, tasks and reports refer to the very same membership.

Across the alternatives, that membership keeps one meaning and one identifier. An in-memory class, a stored record, and screen data may represent it differently without becoming separate memberships. How many data copies exist, and which one can be considered current, are separate questions.

Initially, membership is either active or revoked. Once suspended is introduced, two formerly equivalent checks can look like this:

enum MembershipStatus { active, suspended, revoked }

// Inside the tasks module.
bool mayCreateTask(MembershipStatus status) =>
    status == MembershipStatus.active;

// Inside the reports module.
bool mayPublishReport(MembershipStatus status) =>
    status != MembershipStatus.revoked;

With suspended, the first condition rejects the action and the second permits it. The problem is not a poorly named class. Two modules expressed the same rule independently, and their results agreed only for the original set of states.

For the comparison below, assume the server makes the final access check before changing data. A Flutter interface can hide a button or explain a restriction in advance, but that does not replace the server check: the client can have stale data or be modified by the user.

Why Clean Architecture matters here

In Robert Martin's description of Clean Architecture, the dependency rule concerns the direction of source-code references: inner rules must not depend on details of outer layers. It helps keep domain logic independent of Flutter widgets, an HTTP client, or a table schema.

But if both tasks and reports have their own activity rule, respecting that direction does not make their answers agree. Alongside the layers inside each feature, the design needs decisions about interaction: where membership changes, what contract neighbours can use, and what they do while data is being updated.

For larger domains, DDD offers explicit model boundaries called bounded contexts. A module and a bounded context are not necessarily the same thing: several modules can work within one context, and a single module can be too broad. Clean Architecture and DDD can complement one another, but they address different design questions.

One shared model and rule

The most direct option is a small membership package containing identity, state, and the common rule. Both modules use one type:

enum MembershipStatus { active, suspended, revoked }

final class Membership {
  const Membership({
    required this.id,
    required this.projectId,
    required this.userId,
    required this.status,
  });

  final String id;
  final String projectId;
  final String userId;
  final MembershipStatus status;

  bool get mayWork => status == MembershipStatus.active;
}

This represents the same membership, not separate records for tasks and reports. The class shows the rule, not storage, state transitions, or server enforcement. If both actions receive a current membership and use mayWork, the rule need not be rewritten in two places.

When suspended is added, both consumers need the new model version and must read the state correctly. Here, mayWork already permits only active, so its expression need not change. Storage and API decoding, screens, and both user actions still need checking. A shared method does not update an old app on a phone or make a stale snapshot current.

The cost becomes visible with the next change. Put notification settings, storage details, and report-specific fields into the same package, and tasks start depending on all of them. An incompatible package change affects every consumer. If tasks then import internal report classes through shared, the package becomes a detour around the module boundary.

A small jointly maintained core can be a reasonable choice when the meaning and rules really are common and teams are prepared to coordinate changes. Eric Evans's reference describes a Shared Kernel as an agreed common part of models, not a warehouse for everything used twice. Calling a folder shared is not enough: the teams still need to agree who maintains compatibility and who can change the rule.

A separate model in each module

Another option is a Membership in tasks and a separate Membership in reports. The membership's identity and meaning remain the same. The modules can own their classes, data conversion, and checks without importing a neighbour's model.

For example, tasks might have:

// tasks/domain/membership.dart
enum MembershipStatus { active, suspended, revoked }

final class Membership {
  const Membership(this.id, this.status);
  final String id;
  final MembershipStatus status;

  bool get mayCreateTask => status == MembershipStatus.active;
}

And reports:

// reports/domain/membership.dart
enum MembershipStatus { active, suspended, revoked }

final class Membership {
  const Membership(this.id, this.status);
  final String id;
  final MembershipStatus status;

  bool get mayPublishReport => status != MembershipStatus.revoked;
}

The snippets are deliberately short: user and project fields are omitted, but id refers to the same membership in both classes. The reports rule is intentionally shown in its incorrect state after suspension was added; otherwise the discrepancy would remain hidden.

Each module can develop its implementation without adopting the shape of the other's class. If reports need to store when membership was last read, that field does not have to appear in the tasks model. An independent class, however, does not make the business rule independent.

Going from two states to three means each module must learn to receive suspended, store or convert it correctly, and reject its action. One check above is already safe for the new state; the other is not. A build may pass while tests cover only active and revoked. If the reports module cannot yet decode the new state, the failure may appear only when data arrives at runtime.

Duplicating data and duplicating a rule are different decisions. Two copies of an identifier and status may be useful to the modules. Two independent implementations of “a member can work only while active” need coordinated changes and checks. The absence of a shared library does not remove that agreement.

If both models store their own copies, there is also a synchronisation question: which record is current, and what happens when only one has been updated? A system can designate one owner for changes or reconcile multiple sources of writes. The second route is possible, but adds conflict-resolution rules; having two classes does not provide those rules by itself.

An owner and a narrow boundary

The complete model can remain in the members module without being passed to other modules at all. Tasks need an answer to a narrower question: may this user work in the project? Reports need the same answer.

For example, a consumer can declare the interface it needs:

enum AccessDecision { allowed, denied, unavailable }

abstract interface class MembershipAccess {
  Future<AccessDecision> decide({
    required String projectId,
    required String userId,
  });
}

An implementation calls the members module and returns a decision; application assembly code connects the pieces. Tasks depend on their interface, the members module need not import tasks, and an adapter knows both sides. The direction of the call and the direction of source-code dependencies can differ.

unavailable is deliberately separate from denied. “The information is unavailable” does not mean the membership was revoked. If the source confirms that membership is absent, this example returns denied; if it cannot be checked, it returns unavailable. For a data-changing operation, the absence of confirmed permission may mean refusing or deferring the action. The interface should explain the connection problem rather than tell the person they have been blocked when they may not have been.

Adding suspended changes the rule at the membership owner. The contract can remain unchanged if both features need only “allowed / denied / unknown”. This independence still has a cost: consumers depend on the meaning and availability of the answer, while the adapter and contract checks need maintenance. If reports later need to show why access was denied, the boundary will need to change.

A separate contract package is another way to express the connection. It need not contain the owner's internal domain model. Versioning and the meaning of denied still need agreement; an interface does not become independent simply because it lives in a separate directory.

Martin Fowler describes contract testing: a consumer records what it expects from a boundary, and a provider can run those checks as it changes. Here, the important cases include all three membership states, absent data, and an unavailable source—not just the response type. A test of a stub alone does not prove that the real provider honours the agreement.

When the consumer needs data, not permission

A members list may show a person's name and status alongside a task count. It does not need the complete membership model and the tasks module's internal model. A separate application scenario can request the necessary data from both modules and prepare a representation for the interface.

The resulting list row is a read model: data assembled for display. It refers to the same membership by identifier, but does not become another owner of its lifecycle. It is convenient to change with the screen; using it to decide whether someone may publish a report right now is more dangerous.

An adapter between different models serves a related purpose. If an external source calls a state blocked while the project uses suspended, the adapter translates the concepts at the boundary. DDD uses an anti-corruption layer to protect one model from another's semantics. But not every fromJson constructor deserves a separate architectural layer: when the meaning is identical, a simple conversion may be enough.

An event reports a change; it does not update everything by itself

The members module can announce that a membership with a particular identifier has become suspended. Tasks and reports receive the event and update their own copies. This avoids calling both consumers directly for every change and allows local read models.

Time can pass between the change and event processing. During that interval, the reports screen may still show an active member. An event may arrive twice, out of order, or disappear when a process ends if it existed only in memory. Persisted copies therefore need a chosen source of truth, a change version, and rules for repeat processing and recovery of missed updates. The implementation depends on the delivery mechanism; neither a message broker nor microservices are automatically required for every internal event.

Microsoft's documentation on domain events distinguishes in-process handling from propagation between systems. Within one process, synchronous handlers can participate in a shared transaction if they actually use that transaction and the same storage. Asynchronous delivery or changes across independent stores need their own guarantees. Naming something an event does not create those guarantees.

For access restrictions, delay matters especially. A screen can update from an event, but the server still needs to check current permission when a task is created. Even asking the owner immediately before writing may not be enough: the membership can be suspended between the check and the write. If the rule requires suspension and a forbidden action not to succeed concurrently, the check and change must be coordinated on the server—for example, using a transaction with suitable locking or a conditional write based on a version. The adequacy of a particular mechanism depends on the store and the required ordering.

The cost of one change

Introducing suspended changes more than the number of files. The question is where responsibility for consistent behaviour lands:

Option What changes when suspended appears What still needs attention
Shared model and rule Shared state and decoding; the rule may already permit only active Consumer updates, version compatibility, and data freshness
Separate models with repeated rules State, decoding, and behaviour are checked in each module Rule agreement, change delivery, and diverging copies
Owner with a narrow API State and decision change at the owner; consumers check the contract Answer availability and meaning, integration, and permission checks on writes
Events and local copies The source publishes a change; consumers update their representations Delay, duplicates, ordering, recovery, and preventing actions based on stale data

Every option needs the same scenarios: active permits both actions; revoked and suspended forbid them; after a state change, an old copy must not cause the server to accept a forbidden operation. Separately, check what the person sees when information is unavailable or an event has not yet been processed.

The short Dart examples were run locally with SDK 3.12.2: the two conditions agreed for the original states and diverged for suspended; the shared rule rejected work in non-active states. This checked the examples, not a working application: server authorisation, event delivery, and transactions were not tested.

The comparison also changes with the system's shape. Flutter application modules are built and shipped together, but installed copies do not all update at once. Two server components can be deployed separately even if their source is in one repository. Separate classes give source-code independence; build, release, and behavioural independence need separate consideration.

Choosing a boundary for your project

For this rule, a reasonable starting point may be a membership-owning module and a narrow request for an access decision. Only agreed identifiers and the contract are shared; screens receive their own read models. If several modules genuinely develop substantial identical rules together, a small shared kernel may be simpler than many adapters. If modules must evolve at different speeds, separate models may justify the cost of conversion and checks.

Each choice retains a dependency. A shared model must be updated with its consumers; separate models must stay in agreement; a request to the owner must remain available and understandable to other modules. The choice depends on which of those dependencies the team can manage most comfortably.

Start with a change that has already touched neighbouring features. Find the original rule, follow the same entity by identifier, and mark where decisions are made from it. Then add a state or change the rule on paper: which modules need changes, where could an error go unnoticed, and who checks the result end to end?

Whichever option the team chooses, both tasks and reports must honour a membership suspension. To the user, this is one project, even if different modules own its features.


ArkTelos Lab: engineering journal · ArkTelos official site

Channels: ArkTelos Lab EN · ArkTelos Lab RU · ArkTelos EN · ArkTelos RU

Result boundaries

  • The membership and system are hypothetical. Individual Dart snippets were checked; an application, server authorisation, event delivery and transactions were not tested.

Telegram edition

Read in ArkTelos Lab

Read in ArkTelos Lab ↗

ARKTELOS CHANNELS

News and engineering material, without mixing languages.

The main channels cover ArkTelos development. ArkTelos Lab publishes architecture analysis, experiments, and reproducible research.