Backend setup

The local server depends on PostgreSQL with pgvector, Redis, Mailpit, the AFFiNE server native package, and a server environment file. The checked-in development Compose file, development Docker environment example, server environment example, and @affine/server package scripts are the current source of truth. Use the server development guide for orientation; it may lag behind the checked-in configuration and scripts.

The supported flow is:

  1. install and enable the repository-pinned Rust toolchain;
  2. copy .docker/dev/compose.yml.example to .docker/dev/compose.yml and .docker/dev/.env.example to .docker/dev/.env;
  3. start the required services with Docker Compose using those copied files;
  4. build the native package with yarn affine @affine/server-native build;
  5. copy packages/backend/server/.env.example to packages/backend/server/.env;
  6. uncomment and configure DATABASE_URL, the Redis settings, and any other required entries to match the copied .docker/dev/.env; do not hard-code credentials or assume commented defaults already match the Compose configuration;
  7. run yarn affine server init after schema or data migrations change;
  8. start the server with yarn affine server dev.

Run the web app separately when testing client/server behavior. Do not use development accounts, passwords, or environment files in a deployed environment.