Dependency rules¶
The current architecture is enforced primarily through Gradle module boundaries and the repository/datasource/use-case conventions below.
Module families¶
androidApp
shared
startup
navigation
notification
resources
core/*
data/*
feature/*
server/*
quality/*
Current rules¶
- Keep
androidAppthin. Platform implementations belong in the owning feature/core module's platform source set. - Presentation calls domain use cases. ViewModels should not reach directly into DAOs, datasources or repository implementations.
- Workflows compose use cases. Cross-feature sequencing belongs in a workflow state machine in
:feature:conversationorchestration:*; itsperform(step)calls one use case/repository/nested workflow per step, and its puretransitiondecides the next step. - Repositories do not call other repositories or use cases, not even of their own feature. Repository implementations own their datasources/mappers and share a datasource when two repositories need the same data; cross-feature workflows belong above repositories.
- Datasources do not call repositories. Datasources face storage/network/platform primitives. Data of another module comes through a
…Sourcecontract in:protocol, implemented by a datasource of the owning module (never by a repository). - Feature ownership remains strict.
:feature:inviteowns invitation lifecycle,:feature:identityidentity/trust/recovery,:feature:membershipGroup membership/security,:feature:chatsconversation presentation and read-only data access. - Conversation writes belong in
:feature:conversationorchestration:*. Chats depends only on:feature:conversationorchestration:apiand submits commands throughConversationOrchestrator. The orchestration modules are layereddelivery → message → groupstate → membership → lifecycle → incoming; a lower layer never depends on a higher one and uses a port instead (e.g.DirectReauthorizationPort). Do not move membership logic back into Chats or identity logic into Invite. :feature:messagingstays generic. It executes the persisted outbox/incoming queue and must not decide Direct-vs-Group business rules.- Domain is implementation-independent. No Compose/Room/Ktor implementation/platform framework imports in common domain code.
- Representation suffixes are meaningful.
...Entity= persistence,...Dto= data representation, unsuffixed = domain,...Ui= presentation. - Mapper names identify their destination (
toXDto(),toX(),toXUi()). - Direct and Group paths stay separate where their semantics differ.
- Attachment ownership stays explicit. Attachments own blob/source/cache/transcript concerns; Chats maps them into message content representations.
- Server applications are independent. Server services communicate through HTTP/protocol boundaries and shared low-level server modules, not by importing each other's application internals.
- No dependency cycles. A lower-level module must not reach upward for convenience.
Correct orchestration example¶
flowchart LR
UI[Chats ViewModel] --> ORCH[ConversationOrchestrator]
ORCH --> ENG[WorkflowEngine]
ENG --> FLOW[ConversationWorkflow state machine]
FLOW --> IUC[Invite use case]
FLOW --> IDUC[Identity use case]
FLOW --> MUC[Membership use case]
FLOW --> REPO[orchestration repository]
Workflows may compose use cases because that is precisely their responsibility. See Conversation orchestration. What remains forbidden is hiding that coordination inside InvitationRepositoryImpl, GroupMembershipRepositoryImpl, a datasource, or a Room DAO.
Generated reference¶
The generated module catalog is derived from the current Gradle/source tree. If the normal Gradle report is available, regenerate with: