# raulvidis/amenti architecture

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

- Interactive diagram: https://gitdiagram.com/raulvidis/amenti
- Repository: https://github.com/raulvidis/amenti

## Overview

1. **What this repo is**
   Amenti is a local, SQLite-backed persistent memory system for AI agents. The repository is organized around one core runtime path: a CLI writes and reads memory records from a database, and an optional embedding service adds semantic search.

2. **Primary entrypoint**
   `bin/amenti` is the user-facing CLI. It is the main control plane for storing memories, searching, recalling context, managing tasks/logs, stats, and reindexing vectors. The CLI is configured by environment variables like `AMENTI_DB` and `AMENTI_AGENT`, which define the database location and the active agent namespace.

3. **Core storage layer**
   `src/schema.sql` defines the base SQLite schema, including the memory model, search indexes, and trigger-driven behavior. `src/schema_vec.sql` likely extends that schema for vector-related fields or tables. The repository is built around SQLite as the single durable system of record, not an external database service.

4. **Search architecture**
   Search is hybrid:
   - **FTS5** for exact keyword retrieval
   - **LIKE / partial matching** as fallback
   - **Vector embeddings** for semantic retrieval
   The CLI merges these signals into ranked results. This means search is not a single query path; it is a composition of lexical and semantic retrieval over the same local database.

5. **Embedding subsystem**
   `src/embed_server.py` is a separate Python service that generates embeddings locally using `sentence-transformers` with `all-MiniLM-L6-v2`. The CLI talks to it over HTTP (`/embed`, `/embed_batch`, `/health`) when semantic indexing is enabled. If the server is absent, Amenti still works in non-vector mode.

6. **Lifecycle and operational scripts**
   The `scripts/` directory contains the operational boundaries of the system:
   - `init-db.sh` initializes the SQLite database
   - `reindex.sh` backfills or rebuilds embeddings
   - `migrate.sh` imports from file-based memory layouts
   - `cleanup.sh` performs retention/cleanup logic
   These scripts are the repo’s maintenance layer around the core CLI and database.

7. **Agent packaging and distribution**
   The `templates/` directory contains agent-facing artifacts such as `SKILL.md`, `MEMORY.md`, and related skill templates. The install flow copies these into the agent’s skills/workspace directory so the agent can bootstrap with a lightweight memory interface rather than a large context file.

8. **Data model and memory flow**
   The repo’s architecture centers on a staged memory pipeline: session activity becomes daily logs, then reflections, then durable memories, plus action items and open questions. The database holds multiple memory types such as facts, preferences, relationships, principles, commitments, moments, skills, and patterns. This is a single store with typed records rather than separate services per category.

9. **Multi-agent boundary**
   Amenti supports multiple agents sharing one database while remaining scoped by `agent_id`. That makes agent identity a first-class partitioning boundary: each agent can write its own memories and optionally query others explicitly. This is important for diagramming because the DB is shared infrastructure, but access is logically segmented.

10. **Installation and packaging path**
    `install.sh` is the distribution bootstrap, and `README.md` shows a curl-to-shell install flow. The repo is meant to be installed locally, with the CLI linked into PATH and the skill package copied into the agent’s skills directory. There is no central cloud backend; the architecture is intentionally local-first.

11. **Supporting docs**
    `docs/ARCHITECTURE.md` and `skill/references/distillation-guide.md` provide design and usage guidance, but they are documentation rather than runtime components. In the diagram, they belong on the side as operator/agent guidance, not on the execution path.

12. **Key architectural boundaries to draw**
    The important boundaries are:
    - **Agent/runtime boundary**: agent invokes CLI or consumes the skill package
    - **Persistence boundary**: CLI talks to local SQLite DB
    - **Semantic boundary**: optional HTTP embedding server augments writes/search
    - **Operations boundary**: shell scripts handle bootstrap, migration, reindexing, cleanup
    This repo is therefore best diagrammed as a local memory platform with a thin CLI, one durable DB, and an optional embedding microservice.

Main entry points: [`bin/amenti`](https://github.com/raulvidis/amenti/tree/main/bin/amenti) (Amenti CLI), [`src/schema.sql`](https://github.com/raulvidis/amenti/blob/main/src/schema.sql) (SQLite schema), [`src/schema_vec.sql`](https://github.com/raulvidis/amenti/blob/main/src/schema_vec.sql) (Vector schema), [`templates/SKILL.md`](https://github.com/raulvidis/amenti/blob/main/templates/SKILL.md) (Skill package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_cli["Amenti CLI<br/>entrypoint"]
  node_search{{"Hybrid search<br/>retrieval pipeline"}}
  node_embed_server["Embed server<br/>python service<br/>[embed_server.py]"]
end

subgraph group_storage["Storage"]
  node_schema[("SQLite schema<br/>db schema<br/>[schema.sql]")]
  node_schema_vec[("Vector schema<br/>db extension<br/>[schema_vec.sql]")]
  node_memory_model["Memory records<br/>typed data model"]
  node_agent_scope(("Agent namespace<br/>partitioning"))
end

subgraph group_ops["Operations"]
  node_init_db["Init DB<br/>ops script<br/>[init-db.sh]"]
  node_reindex["Reindex<br/>ops script<br/>[reindex.sh]"]
  node_migrate["Migrate<br/>ops script<br/>[migrate.sh]"]
  node_cleanup["Cleanup<br/>ops script<br/>[cleanup.sh]"]
end

subgraph group_packaging["Packaging"]
  node_install["Install<br/>bootstrap script<br/>[install.sh]"]
  node_skill_pkg["Skill package<br/>agent assets<br/>[SKILL.md]"]
  node_memory_tpl["Memory template<br/>agent assets<br/>[MEMORY.md]"]
end

subgraph group_docs["Docs"]
  node_agent_guidance["Agent guidance<br/>reference docs"]
  node_arch_docs["Architecture docs<br/>reference docs<br/>[ARCHITECTURE.md]"]
end

node_cli -->|"reads/writes"| node_schema
node_cli -->|"uses"| node_schema_vec
node_cli -->|"drives"| node_search
node_search -->|"queries"| node_schema
node_search -->|"ranks with"| node_schema_vec
node_cli -->|"HTTP /embed"| node_embed_server
node_embed_server -->|"produces vectors"| node_schema_vec
node_cli -->|"partitions by"| node_agent_scope
node_init_db -->|"initializes"| node_schema
node_reindex -->|"rebuilds"| node_schema_vec
node_migrate -->|"imports into"| node_schema
node_cleanup -->|"prunes"| node_schema
node_install -->|"installs"| node_cli
node_install -->|"copies"| node_skill_pkg
node_skill_pkg -->|"includes"| node_memory_tpl
node_skill_pkg -->|"references"| node_agent_guidance
node_arch_docs -.->|"documents"| node_cli
node_arch_docs -.->|"documents"| node_schema

click node_cli "https://github.com/raulvidis/amenti/tree/main/bin/amenti"
click node_schema "https://github.com/raulvidis/amenti/blob/main/src/schema.sql"
click node_schema_vec "https://github.com/raulvidis/amenti/blob/main/src/schema_vec.sql"
click node_embed_server "https://github.com/raulvidis/amenti/blob/main/src/embed_server.py"
click node_init_db "https://github.com/raulvidis/amenti/blob/main/scripts/init-db.sh"
click node_reindex "https://github.com/raulvidis/amenti/blob/main/scripts/reindex.sh"
click node_migrate "https://github.com/raulvidis/amenti/blob/main/scripts/migrate.sh"
click node_cleanup "https://github.com/raulvidis/amenti/blob/main/scripts/cleanup.sh"
click node_install "https://github.com/raulvidis/amenti/blob/main/install.sh"
click node_skill_pkg "https://github.com/raulvidis/amenti/blob/main/templates/SKILL.md"
click node_memory_tpl "https://github.com/raulvidis/amenti/blob/main/templates/MEMORY.md"
click node_agent_guidance "https://github.com/raulvidis/amenti/blob/main/skill/references/distillation-guide.md"
click node_arch_docs "https://github.com/raulvidis/amenti/blob/main/docs/ARCHITECTURE.md"

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_cli,node_search,node_embed_server toneBlue
class node_schema,node_schema_vec,node_memory_model,node_agent_scope toneAmber
class node_init_db,node_reindex,node_migrate,node_cleanup toneMint
class node_install,node_skill_pkg,node_memory_tpl toneRose
class node_agent_guidance,node_arch_docs toneIndigo
```

## Components

### Runtime

User-facing command path and local services

- [Amenti CLI](https://github.com/raulvidis/amenti/tree/main/bin/amenti): entrypoint · Main user-facing control plane for memory operations · `bin/amenti`
- **Hybrid search**: retrieval pipeline · FTS5, LIKE fallback, and vector ranking merged by the CLI
- [Embed server](https://github.com/raulvidis/amenti/blob/main/src/embed_server.py): python service · Local HTTP embedding service using sentence-transformers · `src/embed_server.py`

### Storage

SQLite schema and memory model

- [SQLite schema](https://github.com/raulvidis/amenti/blob/main/src/schema.sql): db schema · Base durable memory store and indexes · `src/schema.sql`
- [Vector schema](https://github.com/raulvidis/amenti/blob/main/src/schema_vec.sql): db extension · Vector-related schema additions for semantic memory · `src/schema_vec.sql`
- **Memory records**: typed data model · Facts, preferences, relationships, commitments, moments, and other typed memories
- **Agent namespace**: partitioning · agent_id boundary for multi-agent sharing and isolation

### Operations

Bootstrap, migration, reindexing, cleanup

- [Init DB](https://github.com/raulvidis/amenti/blob/main/scripts/init-db.sh): ops script · Database bootstrap and schema setup · `scripts/init-db.sh`
- [Reindex](https://github.com/raulvidis/amenti/blob/main/scripts/reindex.sh): ops script · Backfill or rebuild embeddings and search indexes · `scripts/reindex.sh`
- [Migrate](https://github.com/raulvidis/amenti/blob/main/scripts/migrate.sh): ops script · Import from file-based memory layouts · `scripts/migrate.sh`
- [Cleanup](https://github.com/raulvidis/amenti/blob/main/scripts/cleanup.sh): ops script · Retention and maintenance logic · `scripts/cleanup.sh`

### Packaging

Agent-facing templates and skill assets

- [Install](https://github.com/raulvidis/amenti/blob/main/install.sh): bootstrap script · Local installation and PATH/skill setup · `install.sh`
- [Skill package](https://github.com/raulvidis/amenti/blob/main/templates/SKILL.md): agent assets · Skill and memory templates copied into agent workspace · `templates/SKILL.md`
- [Memory template](https://github.com/raulvidis/amenti/blob/main/templates/MEMORY.md): agent assets · Agent-facing memory bootstrap template · `templates/MEMORY.md`

### Docs

Design and usage guidance

- [Agent guidance](https://github.com/raulvidis/amenti/blob/main/skill/references/distillation-guide.md): reference docs · Operational guidance for distillation and usage · `skill/references/distillation-guide.md`
- [Architecture docs](https://github.com/raulvidis/amenti/blob/main/docs/ARCHITECTURE.md): reference docs · Repository design and system overview · `docs/ARCHITECTURE.md`

## Connections

- Amenti CLI → SQLite schema: reads/writes · CLI persists memories and queries SQLite
- Amenti CLI → Vector schema: uses · CLI touches vector-backed storage when semantic mode is enabled
- Amenti CLI → Hybrid search: drives · CLI composes lexical and semantic retrieval
- Hybrid search → SQLite schema: queries · FTS5 and LIKE search run against the local database
- Hybrid search → Vector schema: ranks with · Vector fields support semantic retrieval
- Amenti CLI → Embed server: HTTP /embed · Optional local embedding calls for indexing and search
- Embed server → Vector schema: produces vectors · Embeddings are stored or used to populate vector-enabled data
- Amenti CLI → Agent namespace: partitions by · All operations are scoped to an agent identity
- Init DB → SQLite schema: initializes · Bootstrap script creates the base database schema
- Reindex → Vector schema: rebuilds · Operational backfill for vector data and search structures
- Migrate → SQLite schema: imports into · Migration script loads external memory into SQLite
- Cleanup → SQLite schema: prunes · Cleanup operates on stored memory records
- Install → Amenti CLI: installs · Bootstrap links the CLI into the local environment
- Install → Skill package: copies · Install flow deploys skill assets into the agent workspace
- Skill package → Memory template: includes · Skill package carries memory-oriented templates
- Skill package → Agent guidance: references · Skill docs point to distillation guidance
- Architecture docs → Amenti CLI: documents · Architecture docs describe the runtime path
- Architecture docs → SQLite schema: documents · Docs explain the durable storage model
