> For the complete documentation index, see [llms.txt](https://docs.appflowy.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appflowy.io/docs/documentation/software-contributions/architecture/backend/initialize.md).

# Initialize

FlowySDK works as the AppFlowy application Backend. It will be initialized before the application launch. Check out the initialization sequence diagram shown below.

![file : flowy\_sdk.plantuml](https://raw.githubusercontent.com/AppFlowy-IO/docs/main/uml/output/FlowySDK-Initialization.svg)

1. FlowyRunner will get called when the entry point, the `main` function, got called.
2. FlowyRunner call `initialize` function on each task that registers as a LaunchTask one by one.
3. `InitRustSDKTask` calls the init function and passes the working directory into FlowySDK.

   ```dart
    getIt<FlowySDK>().init(directory)
   ```

   The directory is different according to the `IntegrationMode`, which means running AppFlowy on developing mode will not alter the data on release mode.

   1. IntegrationMode.release

   ```dart
    Directory documentsDir = await getApplicationDocumentsDirectory();
    final directory = Directory('${documentsDir.path}/flowy')
   ```

   1. IntegrationMode.develop

   ```dart
    Directory documentsDir = await getApplicationDocumentsDirectory();
    final directory = Directory('${documentsDir.path}/flowy_dev')
   ```

   1. IntegrationMode.test

   ```dart
    final directory = Directory("${Directory.current.path}/.sandbox")
   ```
4. `InitAppWidgetTask` initialize the `ApplicationWidget` and call `runApp` function.
5. `InitPlatformServiceTask` start the `NetworkListener`.

## WIP

typing...💬️


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.appflowy.io/docs/documentation/software-contributions/architecture/backend/initialize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
