# AFFiNE Workspace

> Next-gen knowledge base combining docs, whiteboards, and databases.

- Category: Productivity & Collaboration
- Difficulty: intermediate
- Components: affine, postgresql, redis
- Tags: workspace, notion-alternative, affine, collaboration, knowledge-base
- Source: https://docker.recipes/productivity/affine-workspace

## Overview

AFFiNE is an open-source, next-generation knowledge management platform that combines the functionality of Notion, Miro, and Airtable into a single unified workspace. Built with a local-first approach, AFFiNE allows users to create and organize documents, whiteboards, and databases while maintaining complete control over their data. The platform features block-based editing, real-time collaboration, and the ability to seamlessly switch between different content types within the same workspace.

This Docker deployment sets up a complete AFFiNE workspace environment using three essential services: the main AFFiNE GraphQL server for the application logic and user interface, a PostgreSQL database for persistent data storage and complex relational queries, and Redis for high-performance caching and session management. The AFFiNE container serves the web interface on port 3010 and handles all workspace operations, while PostgreSQL manages structured data integrity and Redis provides fast access to frequently used information and real-time features.

This configuration is ideal for teams and organizations seeking a self-hosted alternative to proprietary productivity suites, developers wanting full control over their knowledge base infrastructure, and privacy-conscious users who prefer to keep their intellectual property on their own servers. The combination of AFFiNE's versatile editing capabilities with PostgreSQL's robust data management and Redis's performance optimization creates a powerful foundation for collaborative knowledge work.

## Features

- Block-based editor supporting rich text, tables, databases, and whiteboard elements in unified documents
- Real-time collaborative editing with conflict resolution and live cursor tracking
- Dual-mode interface allowing seamless switching between page and whiteboard views
- Local-first architecture with automatic synchronization and offline capability
- Advanced database views with filtering, sorting, and multiple display formats (table, kanban, calendar)
- Template system for creating reusable document and workspace structures
- Full-text search across all content types including text, database entries, and whiteboard objects
- Version history and change tracking for all workspace content

## Use cases

- Team knowledge bases combining technical documentation with visual brainstorming boards
- Project management workflows using database views for task tracking and whiteboards for planning
- Educational content creation with interactive lessons combining text, diagrams, and structured data
- Personal productivity systems integrating note-taking, task management, and creative thinking
- Software development teams managing requirements, architecture diagrams, and project documentation
- Research organizations organizing literature reviews, data collection, and collaborative analysis
- Small business operations managing processes, customer information, and strategic planning

## Prerequisites

- Docker and Docker Compose installed with minimum 2GB RAM available for all services
- Port 3010 available for AFFiNE web interface access
- At least 5GB free disk space for PostgreSQL data, Redis cache, and AFFiNE configuration storage
- DB_PASSWORD environment variable configured for PostgreSQL authentication
- Basic understanding of workspace and collaboration tool concepts
- Web browser with JavaScript enabled for accessing the AFFiNE interface

## docker-compose.yml

```yaml
services:
  affine:
    image: ghcr.io/toeverything/affine-graphql:stable
    container_name: affine
    environment:
      - NODE_ENV=production
      - AFFINE_CONFIG_PATH=/root/.affine/config
      - REDIS_SERVER_HOST=redis
      - DATABASE_URL=postgres://affine:${DB_PASSWORD}@db:5432/affine
      - NODE_OPTIONS="--import=./scripts/register.js"
      - AFFINE_SERVER_HOST=0.0.0.0
      - AFFINE_SERVER_PORT=3010
    volumes:
      - affine-config:/root/.affine/config
      - affine-data:/root/.affine/storage
    ports:
      - "3010:3010"
    depends_on:
      - db
      - redis
    networks:
      - affine-network
    restart: unless-stopped

  db:
    image: postgres:15-alpine
    container_name: affine-db
    environment:
      - POSTGRES_USER=affine
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=affine
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - affine-network
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: affine-redis
    volumes:
      - redis-data:/data
    networks:
      - affine-network
    restart: unless-stopped

volumes:
  affine-config:
  affine-data:
  postgres-data:
  redis-data:

networks:
  affine-network:
    driver: bridge
```

## .env

```bash
# AFFiNE
DB_PASSWORD=secure_affine_password
```

## Usage notes

- Web UI at http://localhost:3010
- Combines docs, whiteboards, databases
- Local-first with sync support
- Notion/Miro alternative
- Block-based editing

## Troubleshooting

- AFFiNE interface shows connection errors: Verify Redis and PostgreSQL containers are running and check DATABASE_URL environment variable format
- Slow page loading and editing performance: Increase Redis memory allocation or check for Redis memory pressure warnings
- Database connection failures on startup: Ensure DB_PASSWORD environment variable matches between affine and db services
- Real-time collaboration features not working: Check Redis container logs for connection issues and verify REDIS_SERVER_HOST configuration
- Workspace data not persisting after container restart: Verify affine-data and postgres-data volumes are properly mounted and accessible
- Port 3010 access denied or connection refused: Check if port is already in use and verify AFFINE_SERVER_HOST is set to 0.0.0.0

