PageSpace runs as three cooperating services sharing a PostgreSQL database.
┌─────────────┐
│ Client │
│ (Browser) │
└──────┬──────┘
│
┌────────────┼────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Web │ │ Realtime │ │ Processor│
│ :3000 │ │ :3001 │ │ :3003 │
└────┬─────┘ └────┬─────┘ └────┬─────┘
│ │ │
└────────────┼────────────┘
│
┌─────┴─────┐
│ PostgreSQL│
│ + Redis │
└───────────┘
The main Next.js 15 application. Handles everything except real-time connections and file processing.
Responsibilities:
/api/*)Stack:
A dedicated Socket.IO server for real-time communication.
Responsibilities:
Authentication:
ps_sock_*, 5-minute lifetime)Communication with Web:
Handles file uploads, processing, and storage.
Responsibilities:
Storage:
UPLOAD_DIRAuthentication:
SERVICE_SECRETPostgreSQL is the single source of truth for all data.
Key tables:
users — User accounts and authenticationdrives — Workspacespages — All content (documents, folders, AI chats, etc.)chat_messages — AI and channel messagespage_permissions — Direct user-to-page permissionsdrive_members — Drive membership and rolesuser_ai_settings — Encrypted AI provider keysmcp_tokens — MCP authentication tokenssession_tokens — Opaque session token hashesSchema management:
pnpm db:generatepnpm db:migrateUsed for permission caching. If Redis is unavailable, the system falls back to in-memory caching.
Usage:
pagespace:perms:{userId}:{pageId}The simplest deployment runs all three services on one machine. This is suitable for small teams (< 50 users).
UPLOAD_DIR (NFS or similar).PostgreSQL handles the load for most deployments. For very large installations:
pg_stat_statementsSearch docs, blog posts, and more.