# Synapse Architecture SUMMARY: How Synapse is built — Fastify, PostgreSQL, FTS5, embeddings, MCP server. Synapse Architecture Synapse is a multi-tenant memory API built on Fastify, PostgreSQL with FTS5, and an optional embeddings service for semantic search. High-Level Architecture [CODE BLOCK] Core Components 1. Synapse API (Fastify) The main HTTP server. Handles: - REST endpoints (, , , etc.) - Authentication (Mind Key for agents, JWT for humans) - Rate limiting ( auth only) - Static file serving (web UI at , , etc.) - Webhook dispatch Built with Fastify 5 for performance. Runs on port 12800 in production. 2. PostgreSQL with FTS5 The primary data store. Uses PostgreSQL with the FTS5 extension for full-text search. Key tables: | Table | Purpose | |-------|---------| | | User accounts | | | Mind scopes (each has a Mind Key) | | | Memory records with FTS5 virtual table | | | Task management | | | Chat history | | | Persistent scripts | | | Webhook registrations | | | Scheduled tasks | | | Key-value store | | | Audit trail | FTS5 enables sub-millisecond full-text search across all memory content. See FTS5 Search for details. 3. Embeddings Service (Optional) For semantic search, Synapse generates vector embeddings of memory content. These are stored alongside memories and used for similarity search. - Provider: configurable (OpenAI, local model, etc.) - Stored as column in table - Used by endpoint - See Semantic Search 4. MCP Server (Separate Service) The Synapse MCP server runs as a separate process (port 13100). It: - Exposes 79 tools via Model Context Protocol - Supports stdio, HTTP/SSE, and WebSocket transports - Translates MCP tool calls into Synapse API calls - Multi-tenant: one Mind Key per session 5. Browser Proxy (Separate Service) For browser automation, a separate Playwright-based service runs on port 13000. The MCP server can call this for tools. 6. SSH Proxy (Separate Service) For SSH-based remote commands, a separate service runs on port 12900. Multi-Tenancy Model [CODE BLOCK] Each mind is fully isolated. Mind Keys grant access to exactly one mind. JWTs grant access to the user account (for managing minds). See Multi-Tenancy for details. Request Flow Memory Store Request [CODE BLOCK] Memory Search Request [CODE BLOCK] Deployment Synapse is deployed as a Docker container. See : [CODE BLOCK] Performance Characteristics | Operation | Latency | Throughput | |-----------|---------|------------| | Memory store | 5ms | 1000+ req/s | | Memory recall | 20ms | 500 req/s | | FTS5 search | 10ms | 800 req/s | | Semantic search | 50ms | 200 req/s | | Chat poll | 5ms | 2000 req/s | Next Steps - Memory Model - Multi-Tenancy - FTS5 Search