# arc-es-postgres
Postgres storage adapters for Arc event sourcing.
This crate implements Arc's `EventStore`, `ReadModelStore`, and snapshot persistence on Postgres.
It is intended for production deployments and multi-process Arc applications.
## What It Provides
- `PostgresEventStore`: append-only event store with optimistic concurrency.
- `PostgresReadModelStore`: JSONB read-model storage for projections.
- Self-initializing schema helpers for events, snapshots, and read models.
- Optional HMAC integrity-chain enforcement for persisted events.
## Example
```rust
use arc_core::audit::AuditMetadata;
use arc_core::event::{Event, NewEvent};
use arc_core::event_store::{EventStore, VersionCheck};
use arc_es_postgres::PostgresEventStore;
use serde_json::json;
# async fn example() -> Result<(), Box<dyn std::error::Error>> {
let store = PostgresEventStore::new("postgres://arc:password@localhost:5432/arc").await?;
store.initialize_schema().await?;
let event = Event::new(NewEvent {
aggregate_type: "User",
aggregate_id: "user-123",
sequence: 1,
event_type: "UserRegistered",
payload: json!({ "email": "ada@example.test" }),
})
.with_audit(AuditMetadata::system());
store
.append("user-123", VersionCheck::New, vec![event])
.await?;
# Ok(())
# }
```
## Integrity Mode
Use `PostgresEventStore::new_with_integrity_key` or
`PostgresEventStore::with_pool_and_integrity_key` to sign new events and verify events on
load/stream. Existing unsigned data must be replayed or migrated before enabling integrity
verification.
## Stability
This crate is pre-1.0 and follows `arc-core`'s compatibility line. Breaking changes may ship in
minor versions until `1.0`.
## License
MIT