---
question: "Can one module read another module's document collections?"
kind: overview
---

# Documents

The document service stores mutable JSON-like records by collection, with declared fields, versions and cursor queries. It is the kernel service `services.document`. Each module gets its own namespace: the collections it creates are invisible to other modules. ABI keeps agent memory and job runs there too.

Super admins can browse namespaces, collections and documents in Nexus, under System › Data › Documents. Queries with filters are Python only.

:::note Not Nexus Documents
The Documents screen of a workspace edits rich-text documents, which are kept in Git. It does not read this service.
:::

<!-- matrix -->

## Backends

`services.document` in `config.yaml` picks one adapter:

| Adapter | Storage | Used by |
|---|---|---|
| `sqlite` | A SQLite file (`path`, default `storage/documents.sqlite`) | `config.yaml` of a new project (`abi dev up`), and the engine default |
| `postgresql` | A PostgreSQL database (`dsn`, tables in schema `abi_document`) | `config.local.yaml` (Docker stack) |
| `nats_rpc` | Another engine's document service, over NATS | Engines that share one store |

The keys of each adapter are in the [Configuration Reference](/user-guide/get-started/configuration#document-and-dataset).

## Key concepts

- **Namespace.** The module's name under `modules:` in `config.yaml`. The engine binds it when the module reads `self.engine.services.document`; you never pass it.
- **Collection.** Declared with `ensure_collection(CollectionSpec(...))` before the first write. A module can have as many as it needs. Declarations add fields; they never change a field's type.
- **Fields.** Declared fields have a type (`string`, `int`, `float`, `bool`, `datetime`, `bytes`, `json`) and can be indexed or unique. Undeclared keys are stored as well. Datetimes must be timezone-aware.
- **Versions.** Every document has a `version`, 1 on create, plus one per write. `if_version` makes a write or a delete conditional on it.
- **Queries.** `find` takes `(field, operator, value)` predicates combined with AND, an optional order and a cursor. Fields are top-level keys.
- **Who else uses it.** Agent conversation checkpoints (namespace `naas_abi_core.services.agent`), job run records, and the activity log in NATS mode.
- **Dependency.** A module lists `DocumentService` in `ModuleDependencies.services`. Without it, `self.engine.services.document` raises `ValueError`.
