> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manthan.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# storage

> @parmana/storage — repository implementations, selected by PARMANA_STORAGE

`@parmana/storage` implements the repository interfaces defined in [`shared`](/docs/packages/shared). `packages/storage/src/index.ts` exports `StorageEngine`, `StorageBuilder`, `StorageProvider`, `StorageFactory`, `StorageConfiguration`, an append-only ledger (`AppendOnlyLedger`, `LedgerEntry`, `LedgerSerializer`), individual repository interfaces, and the in-memory provider implementations.

## Provider selection

```ts theme={null}
class StorageFactory {
  static create(configuration: StorageConfiguration): StorageProvider;
  static createFromEnvironment(): StorageProvider; // reads process.env.PARMANA_STORAGE
}
```

`createFromEnvironment()` (used by `packages/api/src/repositories.ts`) reads `PARMANA_STORAGE`, defaulting to `"memory"`:

| `PARMANA_STORAGE` value | Provider                                              |
| ----------------------- | ----------------------------------------------------- |
| `memory` (default)      | `MemoryStorageProvider`                               |
| `supabase`              | `SupabaseStorageProvider`                             |
| `postgres`              | Throws `"Postgres storage provider not implemented."` |
| `sqlite`                | Throws `"SQLite storage provider not implemented."`   |

<Note>
  `SupabaseStorageProvider` (`packages/storage/src/supabase/`) is a real, selectable implementation, but it isn't re-exported from `packages/storage/src/index.ts` — only `MemoryStorageProvider` and the individual `Memory*Repository` classes are. You can still select Supabase via `PARMANA_STORAGE=supabase` (`StorageFactory` imports it directly), you just can't `import { SupabaseStorageProvider } from "@parmana/storage"` for direct use outside the factory.
</Note>

## In-memory repositories

`packages/storage/src/memory/` — `MemoryBusinessTransactionRepository`, `MemoryExecutionTrustRecordRepository`, `MemoryPolicyRepository`, all backed by plain in-process collections with no persistence across restarts. This is what the local dev server (`PARMANA_STORAGE` unset) actually runs on.

<Note>
  `MemoryPolicyRepository` exists here, but the running API server doesn't use it — `packages/api/src/application.ts` constructs a `FilePolicyRepository` from [`@parmana/policy`](/docs/packages/policy) directly for policy loading, reading from the monorepo's `policies/` directory on disk, regardless of `PARMANA_STORAGE`. `PARMANA_STORAGE` only selects the `BusinessTransaction`/`ExecutionTrustRecord` repositories.
</Note>

## Ledger

`AppendOnlyLedger`, `LedgerEntry`, and `LedgerSerializer` model an append-only log abstraction, exported from the package but not referenced from `packages/runtime` or `packages/api` in the current wiring — the actual persistence path is the repository interfaces above, not this ledger.

## Related

<CardGroup cols={2}>
  <Card title="shared" href="/docs/packages/shared">The repository interfaces this package implements.</Card>
  <Card title="Repository Model" href="/docs/architecture/repository-model">The architectural intent behind pluggable storage.</Card>
  <Card title="Execution Trust Record" href="/docs/concepts/execution-trust-record">What `ExecutionTrustRecordRepository` actually stores.</Card>
  <Card title="policy" href="/docs/packages/policy">Where policies are actually loaded from at runtime.</Card>
</CardGroup>
