Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
update README with DDD Event flow
appflowy2053cd7f05b9
diff --git a/.gitignore b/.gitignoreindex 088ba6ba7d..67f6890827 100644--- a/.gitignore+++ b/.gitignore@@ -8,3 +8,6 @@ Cargo.lock# These are backup files generated by rustfmt**/*.rs.bk++/rust-lib/flowy-ast+/rust-lib/flowy-derive\ No newline at end of filediff --git a/.idea/appflowy_client.iml b/.idea/appflowy_client.imlindex 3d6231c1bd..366f01032b 100644--- a/.idea/appflowy_client.iml+++ b/.idea/appflowy_client.iml@@ -2,6 +2,7 @@<module type="CPP_MODULE" version="4"><component name="NewModuleRootManager"><content url="file://$MODULE_DIR$">+ <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-ast/src" isTestSource="false" /><excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/.pub" /><excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/.dart_tool" /><excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/build" />@@ -26,6 +27,7 @@<excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/flowy_protobuf/.dart_tool" /><excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/flowy_protobuf/.pub" /><excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/flowy_protobuf/build" />+ <excludeFolder url="file://$MODULE_DIR$/rust-lib/target" /></content><orderEntry type="inheritedJdk" /><orderEntry type="sourceFolder" forTests="false" />diff --git a/doc/architecture.md b/doc/architecture.mdindex 71f97e649d..1575f42a54 100644--- a/doc/architecture.md+++ b/doc/architecture.md@@ -167,27 +167,65 @@ The AppFlowy Client consists of lots of modules. Each of them follows the DDD deto communication with other module.```- Client- ┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐- │ │- │ User Editor Setting │- │ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │- │ │ presentation │ Dependency │ presentation │ │ presentation │ │- │ │ │ Injection │ │ │ │ │- │ │ application ├───────────────▶│ application │ │ application │ │- │ │ │◀───────────────│ │ │ │ ◉ ◉ ◉ │- │ │ domain │ │ domain │ │ domain │ │- │ │ │ │ │ │ │ │- │ │ Infrastructure │ │ Infrastructure │ │ Infrastructure │ │- │ └───────────────────┘ └───────────────────┘ └───────────────────┘ │- │ ▲ │ │- │ │ Dependency Injection │ │- │ └─────────────────────────────────────────────────────────────┘ │- │ │- └──────────────────────────────────────────────────────────────────────────────────────────────────────┘++ Client+ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐+ │ │+ │ Module A Module B Module C │+ │ ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐ │+ │ │ presentation │ Dependency │ presentation │ │ presentation │ │+ │ │ │ Injection │ │ │ │ │+ │ │ application ├───────────────▶│ application │ │ application │ │+ │ │ │◀───────────────│ │ │ │ ◉ ◉ ◉ │+ │ │ domain │ │ domain │ │ domain │ │+ │ │ │ │ │ │ │ │+ │ │ Infrastructure │ │ Infrastructure │ │ Infrastructure │ │+ │ └───────────────────┘ └───────────────────┘ └───────────────────┘ │+ │ ▲ │ │+ │ │ Dependency Injection │ │+ │ └─────────────────────────────────────────────────────────────┘ │+ │ │+ └──────────────────────────────────────────────────────────────────────────────────────────────────────┘```Let's dig it how can I construct each module. I take `User` module for demonstration.+```++ presentation Application domain Infrastructure++ │+ │ │+ 7 Data Model+ ┌──────────────────────────────┐ │ ┌────────────────────────┐ │ ┌───────────────────────────┐+ │ │ │ │ ┌─────────────┐ │ ┌─────▶│ Repository implementation │+ ▼ Bloc │ 2.1 │ │ Aggregate │ │ │ │ └───────────────────────────┘+┌─────────────┐ │ ┌─────────────────┴─────┐ │ └─────────────┘ │ │ │ 4+│ Widget │ │ ┌────────┐ ┌────────┐ │ │ │ ┌────────┐ │ │ │ ▼+└─────────────┘ │ │ │ Event │ │ State │ │───┬────▶│ │ Entity │ │ │ ┌─────────────────────┐+ │ │ └────────┘ └────────┘ │ │ │ │ └────────┘ │ │ │ │ Unit of Work │+ │ │ └──────▲────────────────┘ │ │ ┌─────────────────┐ │ │ └─────────────────────┘+ │ │ │ │ │ │ Value Object │ │ │ │ │ 5+ └──────────┼────────┘ │ │ └─────────────────┘ │ │ ▼+ 1 │ │ └────────────────────────┘ │ │ ┌─────────────────────┐+ │ │ ◈ │ │ Persistence Service │+ │ │ │ contain │ │ └─────────────────────┘+ │ │ ┌────────────────────┐ │+ │ │ │ Service │ │ │+ │ │ └────────────────────┘ │+ │ 2.2 │ │+ │ │ ┌───────────────────────┐ │+ │ └───▶│ Repository interface │ │ │+ │ └───────────────────────┘ │+ │ │ │ │+ │ │ 3 │+ │ └───────────────┼──┘+```++1. Send event using the bloc. The bloc does not know about the `Widget`. It should communicate through events.+2. The bloc dispatching the event to the appropriate handler of the `Domain`+ 1. Conversion between, DTO (Data Transfer Object) to domain model and Domain Model to DTO.+ 2. Handling the business logic using the repository interface+3. Repository are used to store the domain model data and calls respective service to finish the jobs.# Event-Driven\ No newline at end of file