Deploy AFFiNE (AI + Search)

Notion + Miro alternative with AI (your own key) and full-text search

Deploy AFFiNE (AI + Search)

Just deployed

Just deployed

Just deployed

Deploy and Host AFFiNE (AI + Search) on Railway

AFFiNE is an open source workspace that puts docs, whiteboards and databases on one canvas, a self-hostable answer to Notion and Miro. This template runs the official AFFiNE server with its AI assistant switched on (bring your own OpenAI, Anthropic or Gemini key) and server-side full-text search through Manticore, with your admin account created for you on first boot.

About Hosting AFFiNE (AI + Search)

AFFiNE stores every workspace in Postgres and every uploaded file on a volume, and syncs edits live between browsers, the desktop app and mobile. This template runs four services:

  • AFFiNE: the official ghcr.io/toeverything/affine image, pinned to a release tag. It serves the web app, the API and the admin panel on one public URL.
  • Postgres: pgvector/pgvector on Postgres 16, the same database upstream ships. pgvector holds the AI embeddings.
  • Redis: job queue and cache, persisted to a volume.
  • Manticore: the search engine behind AFFiNE's server-side indexer, private network only.

On first boot AFFiNE runs its database migrations, writes its config, and creates your admin account from the email you enter at deploy time. Nobody else can claim the instance in the meantime.

Common Use Cases

  • A private Notion-style wiki and knowledge base for a team, on infrastructure you control
  • Whiteboarding, mind maps and planning boards next to the docs they belong to
  • Lightweight databases and kanban boards for projects and content calendars
  • AI writing, summarising and chat over your own docs, billed to your own provider key
  • Replacing a paid SaaS workspace for privacy or data residency reasons

Dependencies for AFFiNE (AI + Search) Hosting

  • Postgres with pgvector (included)
  • Redis (included)
  • Manticore Search (included)
  • Optional: an OpenAI, Anthropic or Gemini API key for AI features
  • Optional: an SMTP account for invitation and password reset emails

Deployment Dependencies

Implementation Details

First login. Open the AFFiNE service's public URL and sign in with the email you entered at deploy time. The password is in the AFFiNE service's Variables tab as AFFINE_ADMIN_PASSWORD. Change it in AFFiNE afterwards (avatar, then Account settings). Changing the variable later does nothing; it is only read on the very first boot.

Your first workspace. AFFiNE opens a Demo Workspace that lives in your browser only. Click Enable AFFiNE Sync on the banner (or create a new workspace and choose the server) so it is stored on your server and shows up on every device.

Adding people. Open signup is off, so a public URL is not a free document host for strangers. Add people in Admin panel, Accounts (/admin/accounts), or turn signup on in Admin panel, Settings, Auth. Admin panel settings take priority over the template's defaults.

AI (bring your own key). AI is enabled for the server. Each workspace owner adds a key in Workspace Settings, Integrations, AI BYOK: pick the provider, choose Server storage, paste the key, select Test connection, then Connect. The AI chat lives under Intelligence in the sidebar. Writing and chat work with OpenAI, Anthropic or Gemini; transcription and workspace indexing for AI need a Gemini key. If a model fails its connection test, add a different one with Add model (for example Claude Haiku 4.5 or Sonnet 4.6) and switch the failing one off.

Search. Workspace-wide full-text search runs on the server through Manticore, so it works the same on every device. A brand-new workspace takes a minute or two before its first search results appear.

Version. The template pins 0.27.5-beta.3. In 0.27.4, the newest stable release, AI keys cannot connect: Anthropic always fails, and chat fails for every provider (upstream issues #15505 and #15587). Both work in this build. When 0.27.5 stable ships, change the AFFiNE service's image tag to it and redeploy. Upgrades run their migrations on boot. Back up Postgres first.

Email (optional). Without SMTP, invitations and password resets are not emailed; adding people from the admin panel still works. To send mail, add these variables to the AFFiNE service and redeploy: MAILER_HOST, MAILER_PORT, MAILER_USER, MAILER_PASSWORD, MAILER_SENDER (and MAILER_IGNORE_TLS=true only for servers without TLS).

Custom domain. Add the domain to the AFFiNE service, then set AFFINE_SERVER_EXTERNAL_URL to https://your.domain and AFFINE_SERVER_HOST to your.domain and redeploy. Links, invites and AI requests from the browser only work from the URL in AFFINE_SERVER_EXTERNAL_URL.

Where things live. Uploaded files and the server's config (config.json, private.key) are on the AFFiNE volume at /root/.affine. Docs and settings are in Postgres. The Railway variables for URL, Redis, SMTP and search are copied into config.json on every boot, so edit those in Railway, not in the file.

Troubleshooting.

  • AI key says "Connection failed": check the key works with that provider, then try another model as described above. The browser must be on the AFFINE_SERVER_EXTERNAL_URL address.
  • Search returns nothing for a new workspace: wait a minute; the first index build runs in the background.
  • Logs are very chatty: AFFiNE logs at verbose level by default; this is normal.

Why Deploy AFFiNE (AI + Search) on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying AFFiNE (AI + Search) on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
NEW
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0