Parcourir la source

update some doc

appflowy il y a 3 ans
Parent
commit
685643be36

+ 4 - 4
README.md

@@ -8,13 +8,13 @@
 
 ## Documentation
 
-* [**Getting Started**](doc/getting_started.md)
-* [**Roadmap**](doc/roadmap.md)
-* [**Deep Dive AppFlowy**](doc/architecture.md)
+* [**Getting Started**](doc/GETTING_STARTED.md)
+* [**Roadmap**](doc/ROADMAP.md)
+* [**Deep Dive AppFlowy**](doc/APPFLOWY_SYSTEM_DESIGN.md)
 
 
 ## Contributing
-Read the [Contributing Doc](doc/contribute.md) before you want to contribute.
+Read the [Contributing Doc](doc/CONTRIBUTING.md) before you want to contribute.
 
 ## Social Media
 * Slack (to be determined)

+ 30 - 0
app_flowy/packages/flowy_sdk/lib/dispatch/error.dart

@@ -0,0 +1,30 @@
+import 'package:flowy_logger/flowy_logger.dart';
+import 'package:flowy_sdk/dispatch/flowy_error.dart';
+import 'package:flowy_sdk/protobuf/ffi_request.pb.dart';
+import 'package:flowy_sdk/protobuf/ffi_response.pb.dart';
+
+class StackTraceError {
+  Object error;
+  StackTrace trace;
+  StackTraceError(
+    this.error,
+    this.trace,
+  );
+
+  FlowyError toFlowyError() {
+    Log.error('${error.runtimeType}\n');
+    Log.error('Stack trace \n $trace');
+    return FlowyError.fromError('${error.runtimeType}. Stack trace: $trace');
+  }
+
+  String toString() {
+    return '${error.runtimeType}. Stack trace: $trace';
+  }
+}
+
+FFIResponse error_response(FFIRequest request, StackTraceError error) {
+  var response = FFIResponse();
+  response.code = FFIStatusCode.Err;
+  response.error = error.toString();
+  return response;
+}

+ 0 - 0
doc/about app flowy.md → doc/ABOUT_APPFLOWY.md


+ 71 - 0
doc/APPFLOWY_SYSTEM_DESIGN.md

@@ -0,0 +1,71 @@
+# ๐Ÿฅณ AppFlowy - Event Driven System 
+
+* Goals of the System
+* Some Design Considerations
+* High Level Design
+* Component Design 
+
+## ๐ŸŽฏ Goals of the System
+The AppFlowy project is an attempt to build a high performance application. Here are the top-level requirements for out system.
+
+1. **High Performance.** 
+2. **Cross-platform.**
+3. **Reliability**
+4. **Safety**
+
+
+## ๐Ÿค” Some Design Considerations
+
+## ๐Ÿ“œ High Level Design
+
+## ๐Ÿ“š Component Design
+
+### ๐Ÿ“™ Event Dispatch
+
+```
+                        Frontend                                                     FLowySDK
+                                                             โ”‚                                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+                                                             โ”‚                                          โ”Œ7โ”€โ–ถโ”‚Handler Aโ”‚
+                                                             โ”‚                                          โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+                                                             โ”‚                             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                       โ”‚                        โ”Œโ”€โ”€โ”€โ–ถโ”‚Module A โ”‚โ”€โ”€โ”ผโ”€โ”€โ–ถโ”‚Handler Bโ”‚
+โ”‚Widgetโ”‚โ”€1โ”€โ–ถโ”‚Blocโ”‚โ”€2โ”€โ–ถโ”‚ Repository A โ”‚โ”€3โ”€โ”                   โ”‚                        โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚                   โ”‚                        โ”‚                 โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”ดโ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ””โ”€โ”€โ–ถโ”‚Handler Cโ”‚
+                      โ”‚ Repository B โ”‚โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ–ถโ”‚ Event โ”‚โ”€4โ”€โ–ถโ”‚FFI โ”‚โ”€5โ”€โ”€โ–ถโ”‚Dispatcher โ”‚โ”€6โ”€โ”ผโ”€โ”€โ”€โ–ถโ”‚Module B โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”ฌโ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚                   โ”‚                        โ”‚
+                      โ”‚ Repository C โ”‚โ”€โ”€โ”€โ”˜                   โ”‚                        โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ”‚                        โ””โ”€โ”€โ”€โ–ถโ”‚Module C โ”‚
+                                                             โ”‚                             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+                                                             โ”‚
+                                                             โ”‚
+```
+Here are the event flow: 
+1. User click on the `Widget`(The user interface) that invokes the `Bloc` actions
+2. `Bloc` calls the repositories to perform additional operations to handle the actions.
+3. `Repository` offers the functionalities by combining the event, defined in the `FlowySDK`.
+4. `Events` will be passed in the `FlowySDK` through the [FFI](https://en.wikipedia.org/wiki/Foreign_function_interface) interface.
+5. `Dispatcher` parses the event and generates the specific action scheduled in the `FlowySDK` runtime.
+6. `Dispatcher` find the event handler declared by the modules.
+7. `Handler` consumes the event and generates the response. The response will be returned to the widget through the `FFI`.
+
+The event flow will be discussed in two parts: the frontend implemented in flutter and the FlowySDK implemented in Rust.
+
+#### Frontend
+The Frontend follows the DDD design pattern, you can recap from [**here**](DOMAIN_DRIVEN_DESIGN.md).
+```
+    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+    โ”‚Widgetโ”‚โ”€โ”€1โ”€โ”€โ”€โ”€โ–ถโ”‚Blocโ”‚โ”€โ”€2โ”€โ”€โ”€โ”€โ–ถโ”‚ Repository A โ”‚โ”€3โ”€โ”€โ”
+    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
+                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
+                                  โ”‚ Repository B โ”‚โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ–ถโ”‚ Event โ”‚
+                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+                                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
+                                  โ”‚ Repository C โ”‚โ”€โ”€โ”€โ”€โ”˜
+                                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
+```
+
+#### FlowySDK
+
+

+ 0 - 1
CONTRIBUTING.md → doc/CONTRIBUTING.md

@@ -18,7 +18,6 @@ Consult the Table of Contents below, and jump to the desired section.
 - [Code of Conduct](#code-of-conduct)
 
 
-
 ## Sign the CLA Agreement
 
 TODO

+ 0 - 0
doc/domain driven design.md → doc/DOMAIN_DRIVEN_DESIGN.md


+ 0 - 47
doc/architecture.md

@@ -1,47 +0,0 @@
-# ๐Ÿฅณ AppFlowy System Design
-
-* Goals of the System
-* Some Design Considerations
-* High Level Design
-* Component Design 
-
-## ๐ŸŽฏ Goals of the System
-
-
-
-## ๐Ÿค” Some Design Considerations
-
-## ๐Ÿ“œ High Level Design
-
-## ๐Ÿ“š Component Design
-    
-### ๐Ÿ“• Component 1
-
-
-### ๐Ÿ“— Component 2
-
-
-### ๐Ÿ“˜ Flutter Event Flow
-
-
-### ๐Ÿ“™ Rust Event Flow
-
-```
-                                                                          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
-                                                                       โ”Œโ”€โ–ถโ”‚Service Aโ”‚
-                                                                       โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
-                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
-                        โ”Œโ”€โ–ถโ”‚Module A โ”‚โ”€โ–ถโ”‚ Services  โ”‚โ”€โ–ถโ”‚Deps Resolvedโ”‚โ”€โ”ผโ”€โ–ถโ”‚Service Bโ”‚
-                        โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
-                        โ”‚                                              โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
-โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                 โ””โ”€โ–ถโ”‚Service Cโ”‚
-โ”‚ Event โ”‚โ”€โ”€โ–ถโ”‚Runtime โ”‚โ”€โ”€โ”ผโ”€โ–ถโ”‚Module B โ”‚                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
-โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
-                        โ”‚
-                        โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
-                        โ””โ”€โ–ถโ”‚Module C โ”‚
-                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
-```
-
-* sync will cause typing lag
-

+ 0 - 12
doc/contribute.md

@@ -1,12 +0,0 @@
-[WIP]
-* Contributing
-    * First steps
-    * Opening issues
-    * Participating in discussions
-    * Finding something to work on
-    * Open your PR
-    * Review Process
-    * Getting more involved
-        * Organization membership
-        * Contributor
-        * Maintainer

+ 0 - 1
doc/why flutter and rust.md

@@ -1 +0,0 @@
-[WIP]

+ 7 - 0
scripts/install_rust.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+echo 'install rust'
+sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
+curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
+echo 'export PATH="$$HOME/.cargo/bin:$$PATH"' >> ~/.bash_profile
+source ~/.bash_profile

+ 15 - 0
scripts/install_tool.sh

@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#targets
+rustup target add x86_64-apple-darwin
+
+#tools
+echo 'install tools'
+rustup component add rustfmt
+cargo install cargo-expand
+cargo install cargo-watch
+cargo install cargo-cache
+
+#protobuf code gen env
+brew install [email protected]
+cargo install --version 2.20.0 protobuf-codegen