Skip to content

Twake Mail Refactoring plan #4232

@hoangdat

Description

@hoangdat

Why?

Problem:

  • Current architecture has centralized "god object" controller managing multiple concerns, causing tight coupling, difficult testing, and scalability issues.
  • Add new feature = touching existing code base

How?

Solution: Introduce Repository Pattern with clear separation between app-level state, feature-level state, and UI controllers.

  • App-level state repositories (singleton): Own canonical state, expose streams
    • EmailStateRepository
    • MailboxStateRepository
    • UserStateRepository
    • ...
  • Feature-level state: Manage feature-specific state
    • ComposerStateRepository
    • SearchStateRepository
    • ...
  • UI controllers: Handle UI events, subscribe to streams
    • MailboxTreeController
    • EmailListController
    • ComposerController
    • ...
  • UI reactions

Impact

  • Each repository owns one domain (mailbox, email, user)
  • Only repository can mutate state
  • Controllers subscribe only to what they need
  • Controllers read-only via streams
  • No controller knows about other controllers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions