# pramodsultane/copilotmemory architecture

> Architecture diagram of the GitHub repository pramodsultane/copilotmemory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pramodsultane/copilotmemory
- Repository: https://github.com/pramodsultane/copilotmemory

## Overview

1. **Repository purpose**
   - `copilotmemory` is a local-first Python package for storing and retrieving coding “memories” to improve Copilot context.
   - The architecture centers on a memory pipeline: capture/store content, embed it, retrieve similar items, and expose results through CLI and HTTP API.

2. **Top-level package boundary**
   - All runtime code lives under `src/copilotmemory/`, split into `memory`, `api`, `cli`, and `utils`.
   - This is a clean separation of core domain logic from delivery channels: the same memory subsystem is reused by both the FastAPI layer and the Typer CLI.

3. **Core memory subsystem**
   - `src/copilotmemory/memory/` is the heart of the project.
   - `store.py` likely owns persistence and CRUD for memory records.
   - `embedder.py` transforms code/text into vector embeddings.
   - `retriever.py` runs semantic lookup and relevance ranking over stored memories.
   - For an architecture diagram, this subsystem should be shown as the central service layer that both interfaces depend on.

4. **Data persistence model**
   - The README describes a dual-store design: vector storage for semantic search and SQLite for metadata.
   - Environment variables such as `MEMORY_DB_PATH` and `VECTOR_STORE_PATH` imply local filesystem-backed persistence rather than remote services.
   - The architecture boundary here is important: embeddings/search data are separated from operational metadata like timestamps, tags, and paths.

5. **Embedding and retrieval flow**
   - New memories flow from raw code/snippets into normalization and embedding generation, then into the store.
   - Query flow goes the other direction: natural-language search requests are embedded, compared against stored vectors, then filtered/ranked by threshold and limit.
   - The retriever is the key coordination point for turning low-level similarity scores into user-facing context.

6. **API delivery layer**
   - `src/copilotmemory/api/routes.py` exposes the HTTP surface, documented as FastAPI in the README.
   - The API is thin: it validates requests, delegates to memory services, and formats responses for clients.
   - Main endpoints are memory CRUD plus semantic search and health checking, making the API a façade over the memory subsystem.

7. **CLI delivery layer**
   - `src/copilotmemory/cli/commands.py` provides local user operations with Typer.
   - CLI commands mirror the API capabilities: store, search, prompt generation, list, show, delete, and serve.
   - This suggests a single domain backend with two entry points: human-oriented local commands and programmatic HTTP access.

8. **Configuration and cross-cutting utilities**
   - `src/copilotmemory/utils/config.py` centralizes environment-driven settings such as storage paths, host/port, embedding model, and retention policies.
   - `src/copilotmemory/utils/logger.py` handles logging as a shared cross-cutting concern.
   - These utilities are not core business logic, but they define operational behavior and deployment constraints.

9. **Deployment and runtime shape**
   - The project is a Python 3.10+ package with local runtime dependencies on ChromaDB, sentence-transformers, FastAPI, and Typer.
   - The README indicates a service mode (`copilotmemory serve`) and a containerized deployment path via Docker.
   - In a diagram, the runtime boundary should show a single Python application with optional API server mode and local data directories.

10. **Tests and quality gates**
   - `tests/test_memory.py` indicates direct testing of core memory behavior; the README also references API and CLI tests.
   - Tooling in `pyproject.toml` is likely organized around pytest plus lint/type checks (`ruff`, `black`, `mypy`).
   - The test boundary matters because the memory layer is the most critical and should be isolated from interface concerns.

11. **Documentation and architecture intent**
   - `docs/architecture.md` likely expands the intended system design beyond what is implemented.
   - The README’s architecture section describes the intended layering: capture, embedding, vector store, metadata, retrieval, and integrations.
   - If you are drawing the diagram, use the README as the conceptual model, but anchor concrete components to the actual package layout in `src/copilotmemory/`.

12. **Important implementation boundary to note**
   - The project is explicitly privacy-first and local-first: there is no required cloud dependency in the documented architecture.
   - That means the main external dependencies are libraries, not hosted services; the primary “integration” boundaries are the API and CLI entry points rather than networked backends.

Main entry points: [`src/copilotmemory/memory/store.py`](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/store.py) (store), [`src/copilotmemory/api/routes.py`](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/api/routes.py) (API routes), [`src/copilotmemory/cli/commands.py`](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/cli/commands.py) (CLI commands), [`src/copilotmemory/__init__.py`](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/__init__.py) (copilotmemory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_pkg["copilotmemory<br/>python package<br/>[__init__.py]"]
  node_api_routes["API routes<br/>FastAPI facade<br/>[routes.py]"]
  node_cli_cmds["CLI commands<br/>Typer entrypoint<br/>[commands.py]"]
end

subgraph group_core["Core memory"]
  node_memory_pkg["memory<br/>domain package<br/>[__init__.py]"]
  node_store[("store<br/>persistence service<br/>[store.py]")]
  node_embedder(("embedder<br/>embedding service<br/>[embedder.py]"))
  node_retriever{{"retriever<br/>semantic search<br/>[retriever.py]"}}
  node_vector_store[("vector store<br/>local vectors")]
  node_sqlite_meta[("SQLite meta<br/>local metadata")]
end

subgraph group_support["Support"]
  node_config["config<br/>settings<br/>[config.py]"]
  node_logger["logger<br/>logging<br/>[logger.py]"]
  node_pyproject["pyproject<br/>tooling config<br/>[pyproject.toml]"]
  node_env_example["env example<br/>env template<br/>[.env.example]"]
end

subgraph group_quality["Quality"]
  node_docs_arch["architecture doc<br/>design doc<br/>[architecture.md]"]
  node_readme["README<br/>project docs<br/>[README.md]"]
  node_tests_memory["memory tests<br/>pytest<br/>[test_memory.py]"]
end

node_pkg -->|"reuses"| node_memory_pkg
node_pkg -->|"serves"| node_api_routes
node_pkg -->|"serves"| node_cli_cmds
node_api_routes -->|"search"| node_retriever
node_api_routes -->|"crud"| node_store
node_cli_cmds -->|"store"| node_store
node_cli_cmds -->|"search"| node_retriever
node_retriever -->|"embed query"| node_embedder
node_retriever -->|"read memory"| node_store
node_store -->|"vectors"| node_vector_store
node_store -->|"metadata"| node_sqlite_meta
node_embedder -->|"write vectors"| node_vector_store
node_config -->|"binds"| node_api_routes
node_config -->|"drives"| node_cli_cmds
node_config -->|"paths"| node_store
node_logger -->|"logs"| node_api_routes
node_logger -->|"logs"| node_cli_cmds
node_logger -->|"logs"| node_memory_pkg
node_readme -.->|"describes"| node_docs_arch
node_tests_memory -.->|"verifies"| node_memory_pkg
node_pyproject -.->|"builds"| node_pkg
node_env_example -.->|"documents"| node_config

click node_pkg "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/__init__.py"
click node_api_routes "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/api/routes.py"
click node_cli_cmds "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/cli/commands.py"
click node_memory_pkg "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/__init__.py"
click node_store "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/store.py"
click node_embedder "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/embedder.py"
click node_retriever "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/retriever.py"
click node_config "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/utils/config.py"
click node_logger "https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/utils/logger.py"
click node_docs_arch "https://github.com/pramodsultane/copilotmemory/blob/main/docs/architecture.md"
click node_readme "https://github.com/pramodsultane/copilotmemory/blob/main/README.md"
click node_tests_memory "https://github.com/pramodsultane/copilotmemory/blob/main/tests/test_memory.py"
click node_pyproject "https://github.com/pramodsultane/copilotmemory/blob/main/pyproject.toml"
click node_env_example "https://github.com/pramodsultane/copilotmemory/blob/main/.env.example"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pkg,node_api_routes,node_cli_cmds toneBlue
class node_memory_pkg,node_store,node_embedder,node_retriever,node_vector_store,node_sqlite_meta toneAmber
class node_config,node_logger,node_pyproject,node_env_example toneMint
class node_docs_arch,node_readme,node_tests_memory toneRose
```

## Components

### Runtime

Application entry points and delivery surfaces

- [copilotmemory](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/__init__.py): python package · Top-level package boundary for the local-first memory system · `src/copilotmemory/__init__.py`
- [API routes](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/api/routes.py): FastAPI facade · HTTP surface for memory operations and health checks · `src/copilotmemory/api/routes.py`
- [CLI commands](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/cli/commands.py): Typer entrypoint · Local command interface for storing, searching, and serving memories · `src/copilotmemory/cli/commands.py`

### Core memory

Domain services for storing, embedding, and retrieving memories

- [memory](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/__init__.py): domain package · Core memory subsystem reused by API and CLI · `src/copilotmemory/memory/__init__.py`
- [store](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/store.py): persistence service · CRUD and persistence for memory records · `src/copilotmemory/memory/store.py`
- [embedder](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/embedder.py): embedding service · Converts code and text into vector representations · `src/copilotmemory/memory/embedder.py`
- [retriever](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/memory/retriever.py): semantic search · Coordinates similarity lookup, ranking, and result filtering · `src/copilotmemory/memory/retriever.py`
- **vector store**: local vectors · Filesystem-backed semantic index used for embedding search
- **SQLite meta**: local metadata · Local metadata store for timestamps, tags, and paths

### Support

Configuration, logging, and package-level helpers

- [config](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/utils/config.py): settings · Environment-driven storage, model, and server configuration · `src/copilotmemory/utils/config.py`
- [logger](https://github.com/pramodsultane/copilotmemory/blob/main/src/copilotmemory/utils/logger.py): logging · Shared logging setup for runtime components · `src/copilotmemory/utils/logger.py`
- [pyproject](https://github.com/pramodsultane/copilotmemory/blob/main/pyproject.toml): tooling config · Build, dependency, and quality-check configuration · `pyproject.toml`
- [env example](https://github.com/pramodsultane/copilotmemory/blob/main/.env.example): env template · Sample environment variables for local runtime configuration · `.env.example`

### Quality

Documentation and tests that shape behavior

- [architecture doc](https://github.com/pramodsultane/copilotmemory/blob/main/docs/architecture.md): design doc · Conceptual architecture and intended layering · `docs/architecture.md`
- [README](https://github.com/pramodsultane/copilotmemory/blob/main/README.md): project docs · User-facing overview of setup, usage, and system flow · `README.md`
- [memory tests](https://github.com/pramodsultane/copilotmemory/blob/main/tests/test_memory.py): pytest · Direct tests for core memory behavior · `tests/test_memory.py`

## Connections

- copilotmemory → memory: reuses · Package exposes the shared domain subsystem
- copilotmemory → API routes: serves · Package includes HTTP delivery layer
- copilotmemory → CLI commands: serves · Package includes CLI delivery layer
- API routes → retriever: search · HTTP requests delegate to semantic retrieval
- API routes → store: crud · HTTP requests delegate to record persistence
- CLI commands → store: store · CLI writes memories through the domain store
- CLI commands → retriever: search · CLI search and prompt generation use retrieval
- retriever → embedder: embed query · Retrieval embeds natural-language queries
- retriever → store: read memory · Retrieval reads persisted records and vectors
- store → vector store: vectors · Semantic embeddings are kept in local vector storage
- store → SQLite meta: metadata · Operational fields are kept in SQLite metadata
- embedder → vector store: write vectors · Generated embeddings are stored for later similarity search
- config → API routes: binds · Config provides host and port settings
- config → CLI commands: drives · Config controls CLI behavior and serve mode
- config → store: paths · Config defines local database and vector paths
- logger → API routes: logs · Shared logging used by the API layer
- logger → CLI commands: logs · Shared logging used by CLI commands
- logger → memory: logs · Core services emit structured logs
- README → architecture doc: describes · README and architecture doc express intended system design
- memory tests → memory: verifies · Tests focus on core memory behavior
- pyproject → copilotmemory: builds · Project configuration defines packaging and quality tooling
- env example → config: documents · Example environment variables mirror runtime settings
