Engram Codebase Guide

May 4, 2026 · View on GitHub

← Back to README

Engram Codebase Guide

This guide is for maintainers and contributors who need to understand where Engram responsibilities live, which invariants are non-negotiable, and which file to open when something needs to change.

Engram is a local-first persistent memory system for coding agents. The center of the product is a Go binary that writes to SQLite + FTS5; the CLI, MCP, HTTP API, TUI, plugins, sync, cloud, and dashboard are interfaces around that core.

90-second mental model

Coding agent
  Claude Code / OpenCode / Gemini CLI / Codex / VS Code / Antigravity / Cursor / Windsurf

        │ MCP stdio, plugin hooks, or local API

cmd/engram
  CLI + local runtime + cloud runtime

        ├── internal/mcp        mem_* tools for agents
        ├── internal/server     local JSON API: engram serve
        ├── internal/tui        Bubbletea terminal UI
        ├── internal/setup      automated integration installation


internal/store
  SQLite + FTS5 + sessions + observations + prompts + relations + sync mutations

        ├── internal/sync                   git-friendly chunks / transport
        └── internal/cloud/autosync         optional background push/pull


        internal/cloud/remote ── HTTP ── engram cloud serve

                                      ├── internal/cloud/cloudserver
                                      ├── internal/cloud/cloudstore  Postgres
                                      ├── internal/cloud/dashboard   HTML/HTMX
                                      └── internal/cloud/auth        bearer + dashboard session

The sentence that organizes the whole repo:

Local SQLite is the source of truth. Cloud is opt-in replication and shared access, not the owner of the data.

StepPageRead this when...
1Mental ModelYou need the product shape before opening code.
2Repository MapYou need to decide which package owns a change.
3Memory CoreYou are touching SQLite, FTS5, prompts, observations, sessions, relations, or sync mutations.
4InterfacesYou are changing CLI, MCP, local API, or TUI behavior.
5Sync and CloudYou are changing chunks, remote sync, autosync, transport, or cloud persistence.
6DashboardYou are changing browser UI, HTMX partials, cloud dashboard routes, or dashboard policy controls.
7IntegrationsYou are changing agent setup, plugins, or MCP configuration docs.
8Maintainer PlaybookYou are reviewing a PR or planning a large change.
9Reference MapYou need a traceable appendix from docs/source files to purpose.

Quick map: if you need X, read Y

If you need to...Open firstThen check
Understand the product in 5 minutesREADME.mdMental Model
See the full technical referenceDOCS.mdThis guide for ownership and guardrails
Change MCP toolsinternal/mcp/mcp.goInterfaces, internal/mcp/*_test.go, docs/AGENT-SETUP.md
Change local persistenceinternal/store/store.goMemory Core, internal/store/*_test.go, DOCS.md#database-schema
Change the local APIinternal/server/server.goInterfaces, internal/server/*_test.go, DOCS.md#http-api-endpoints
Change chunk syncinternal/sync/sync.goSync and Cloud, internal/sync/*_test.go, README.md#git-sync
Change cloud autosyncinternal/cloud/autosync/manager.goSync and Cloud, internal/cloud/remote/transport.go, DOCS.md#cloud-autosync
Change the dashboardinternal/cloud/dashboard/dashboard.goDashboard, internal/cloud/dashboard/*_templ.go, internal/cloud/dashboard/static/styles.css
Change agent setupinternal/setup/setup.goIntegrations, plugin/, docs/AGENT-SETUP.md, docs/PLUGINS.md
Prepare or review a large featureopenspec/changes/*Maintainer Playbook, openspec/specs/*, CONTRIBUTING.md

Full technical reference stays in DOCS.md

This guide explains ownership, flows, and guardrails. It intentionally does not duplicate the complete API reference. For endpoints, schemas, MCP parameters, and CLI flags, use DOCS.md.


Next: Mental Model →