Skip to content
memghost.com Open App

System Overview

MemGhost is a self-hosted personal knowledge management platform. It captures raw items (notes, bookmarks, clippings, webhooks) into a vault, classifies them, routes them to topical hub pages maintained by an AI pipeline, and lets you chat with your knowledge through AI agents.

Architecture Philosophy

Modular Monolith with Event Sourcing

MemGhost uses a modular monolith architecture with event sourcing and CQRS patterns:

  • Single Go Binary — easy deployment and operation
  • PostgreSQL — event store, read models, and vector search (pgvector) in one database
  • Event Bus — in-process event routing with SSE bridge for real-time UI updates
  • Domain Modules — clear boundaries with enforced separation
  • AI Pipeline — Ollama for embeddings and chat, Kokoro for TTS

Why This Architecture?

Operational Simplicity

  • Single deployment unit (one Go binary)
  • One database to manage (PostgreSQL)
  • Minimal resource footprint for self-hosting
  • Easy local development

Event Sourcing Benefits

  • Complete audit log of all state changes
  • Time-travel debugging (replay events to any point)
  • Multiple read models from the same event stream (notes view, hub pages, search index)
  • Vault as single source of truth with all views as projections

Future Flexibility

  • Modules can be extracted to independent services later
  • Clear boundaries enforced by architecture tests
  • New item types and integrations plug into the same pipeline

System Components

Backend (Go)

The backend is a single Go binary that includes:

  1. HTTP Server — OpenAPI 3.0 generated handlers, JWT validation, authorization middleware
  2. Domain Modules — Vault, Hubs, Spaces, Note, Agent, TTS, Auth, Setup
  3. Event Bus — in-process event routing with SSE bridge
  4. Event Store — PostgreSQL-based event storage
  5. Read Models — optimized projections for queries
  6. AI Services — embedding generation, vector search, LLM routing, MCP tool servers

Frontend (Next.js)

The web interface is built with Next.js 14+ (App Router), TypeScript, Tailwind CSS, shadcn/ui components, React Query for server state, and Server-Sent Events for real-time updates.

Database (PostgreSQL)

A single PostgreSQL database stores:

  • Event Store — all state changes as immutable events
  • Read Models — optimized views for queries (note_views, hub_nodes, hub_edges)
  • Vector Embeddings — pgvector for semantic search and hub routing

Key Data Flow

Input (note, bookmark, webhook)
→ Vault (store as item, emit item.created.v1)
→ Classification pipeline (type, tags, metadata → item.classified.v1)
→ Hub routing (assign to topic node → item.routed.v1)
→ Materialization (synthesize hub page content)
→ Note projection (populate note_views table)
→ Embedding projection (generate vectors for search)

All writes enter through the vault. Hubs, notes, and search are downstream projections of vault events. This ensures one source of truth with a complete audit trail.

Modules

ModulePurposeKey Aggregates
VaultCanonical item store, ingest and classification pipelineVaultItem
HubsTopic graph, AI routing, content materializationHubNode, HubEdge
SpacesAI conversation workspaces with personas and artifactsSpace
NoteRead model for note-type items, tags, folders, pin/unpinNote (projection)
AgentAI chat sessions, MCP tool servers, semantic searchAgentSession
TTSVoice synthesis and voice managementVoice
AuthJWT authentication, sessions, rolesUser, Session
SetupFirst-run wizard, initial data import

See Domain Modules for detailed module documentation.

AI & Voice

MemGhost includes optional AI capabilities that run entirely on your hardware:

FeatureTechnologyPurpose
AI ChatOpenRouter / Anthropic / OllamaConversational agents with tool use
Semantic SearchOllama (nomic-embed-text) + pgvectorNatural-language search across all data
Hub RoutingLLM classificationRoute items to the right topic page
Content SynthesisLLM generationMaterialize hub pages from source items
Text-to-SpeechKokoro (82M params)Spoken responses from AI agents
MCP ToolsGo SDKPer-module tool definitions for AI agents

See the AI Features and Voice guides for details.

Technology Stack

LayerTechnologies
BackendGo 1.25+, PostgreSQL 15+ (pgvector), OpenAPI 3.0
FrontendNext.js 14+, TypeScript, Tailwind CSS, shadcn/ui, React Query, Zustand
AIOllama, pgvector, MCP (Model Context Protocol), Kokoro TTS
InfrastructureDocker, Docker Compose, Caddy, OpenTelemetry
DevelopmentDev Containers, Taskfile, Air (hot reload)

Deployment

Self-hosted (Production)

  • Single Go binary + PostgreSQL
  • Docker Compose for easy deployment
  • Minimal resource requirements (1-2 CPU cores, 512 MB - 2 GB RAM without AI)

Development

  • Docker Compose for local services
  • Dev Container for consistent environment
  • Hot reload for rapid development