Skip to content

Event Sourcing, CRDTs, and the Architecture of Change in Phoundri

· Phoundri LLC · 14 min read

On this page

How Phoundri combines collaborative data structures, authoritative operations, audit history, and non-destructive recovery without building a universal event-sourced database.

Phoundri Architecture White Paper November 2026

Executive summary

Modern business software must do more than store information. It must support multiple people working simultaneously, devices moving between online and offline states, secure changes to shared data, and reliable recovery when mistakes happen.

These requirements introduce a fundamental challenge: how do we maintain a trustworthy representation of business data when information is continuously changing across users, devices, and network connections?

Two important approaches in distributed software architecture are event sourcing and Conflict-free Replicated Data Types (CRDTs).

Event sourcing preserves changes as a sequence of events from which application state can be reconstructed. CRDTs allow distributed copies of shared data to incorporate concurrent updates and converge without requiring every edit to pass through a centralized conflict-resolution process.

Both approaches offer valuable capabilities. Neither is a complete solution to every problem.

Phoundri takes a deliberate approach.

Rather than implementing a universal event-sourced database alongside its collaboration infrastructure, Phoundri uses a combination of:

  • Yjs, a CRDT-based collaboration framework.
  • Local-first storage and offline operation queues.
  • Cloudflare Workers and Durable Objects.
  • Authoritative, validated business-data mutations.
  • Cloudflare D1 databases dedicated to individual customer Organizations.
  • Audit projections and mutation receipts.
  • Specialized Undo, restoration, and deleted-resource recovery mechanisms.

These components serve different responsibilities and are designed to operate together.

The underlying philosophy is straightforward:

Collaboration should be immediate. Business operations should be authoritative. History should be useful. Recovery should be deliberate. Storage should remain efficient.

This paper explains the reasoning behind that architecture, the technologies involved, and the trade-offs Phoundri has chosen.


1. The problem: business data is constantly changing

Consider a small service company.

An office administrator schedules a job while a technician updates its status from a mobile device. A manager adjusts the customer's information, and someone else imports new records.

Some changes happen simultaneously. Some happen while a device is offline. Others modify the structure of the shared data itself.

A reliable system must address several questions:

  1. How can multiple people edit shared information without losing changes?
  2. How does work continue when the network becomes unavailable?
  3. Who determines whether a requested change is valid?
  4. How are duplicate requests prevented from creating duplicate effects?
  5. How can users reverse mistakes without overwriting another person's newer work?
  6. How can deleted resources be recovered?
  7. How much history should be retained, and at what storage cost?

Simply keeping the latest value in a database does not answer all these questions.

Neither does recording every interaction forever.

Phoundri's architecture separates collaboration, authoritative state, operation history, and recovery so that each requirement can be handled by the mechanism best suited to it.

2. Understanding event sourcing

2.1 What is event sourcing?

Traditional state-oriented storage primarily records what something looks like now.

Imagine a customer record with the following current status:

Job status: Completed

That value tells us the present state, but not necessarily how it became completed.

An event-sourced system might instead retain a sequence of meaningful events:

  1. Job created.
  2. Technician assigned.
  3. Job started.
  4. Job completed.

The application can reconstruct the current state by applying those events in order.

In a fully event-sourced architecture, the event stream is the authoritative historical record, and current application state is a projection derived from that record.

Event sourcing can provide:

  • Historical reconstruction.
  • Strong provenance.
  • Auditability.
  • Replay.
  • Derived views.
  • Support for compensating operations.
  • Analysis of how state changed over time.

However, it also introduces challenges.

2.2 The costs of event sourcing

Event sourcing changes how an application manages persistence.

Historical events may need to remain interpretable long after the application code has changed. Events need stable identities and schemas. Replay must be correct. Ordering and concurrency must be handled carefully.

Efficient applications generally require current-state projections or snapshots rather than rebuilding an entire data model from its beginning for every read.

Additional challenges include:

  • Retention and privacy requirements.
  • Event schema evolution.
  • Replay correctness.
  • Increased storage requirements.
  • Historical authorization context.
  • Operational complexity.
  • Event duplication and deduplication.
  • Recovery from incomplete processing.

An event-sourced architecture can be highly effective where complete historical reconstruction is a core requirement. But using it universally can add complexity without proportional business value.

2.3 Event sourcing is not the same as an audit log

This distinction is essential.

An audit log records information about changes.

An event-sourced system uses its event history to define or reconstruct authoritative application state.

An application can provide audit trails, mutation receipts, versioning, and Undo without being fully event-sourced.

Likewise, an application can use event-driven communication without making an event log its database of record.

Phoundri's existing audit and operation-history mechanisms should not be mistaken for a universal event-sourced database.

3. Understanding CRDTs

3.1 What is a CRDT?

CRDT stands for Conflict-free Replicated Data Type.

A CRDT is a data structure designed so that replicas can receive concurrent changes and converge on a consistent result when the necessary updates are exchanged.

Consider two people editing a shared document.

One person adds a sentence. Another person updates a different paragraph.

With a conventional system, concurrent edits may require locks, coordination, or explicit conflict resolution.

A CRDT-based system can represent operations in a way that allows replicas to merge supported concurrent changes deterministically.

Importantly, this does not mean every concurrent edit preserves every user's intended meaning. Two people can still make logically incompatible decisions. CRDT convergence solves a distributed-state problem, not every business conflict.

3.2 Why CRDTs matter for offline-first software

CRDTs are particularly useful when devices cannot always communicate.

A device can work with local state and later exchange updates with other replicas.

This creates opportunities for:

  • Immediate local editing.
  • Collaborative interfaces.
  • Reduced dependence on network round trips.
  • Intermittent connectivity.
  • Efficient incremental synchronization.
  • Deterministic state convergence.

For Phoundri, these properties align with a foundational requirement: cached workspaces should remain usable immediately, even when the network is slow or unavailable.

3.3 Why Phoundri uses Yjs

Yjs is an open-source CRDT implementation for collaborative applications.

It provides shared data types, document updates, state vectors, and synchronization primitives that can be integrated with an application's own communication and persistence systems.

Phoundri selected Yjs as a foundation for eligible collaborative state and offline synchronization.

Its existing architecture uses Yjs documents associated with shared resources, including Tables and Pages, together with local storage and server-side reconciliation.

Yjs offers an established implementation of difficult distributed-state algorithms rather than requiring Phoundri to develop an entirely new CRDT engine.

However, convergence is not equivalent to permission to modify authoritative business data.

That distinction determines how Yjs fits into the broader Phoundri architecture.

4. Why CRDTs and authoritative writes coexist

Imagine that two users are looking at the same Table.

User A renames a column from Company to Business Name.

At nearly the same moment, User B attempts to rename that column to Customer.

A collaborative state mechanism can communicate both attempts. But the business application still needs to decide which structural mutation is valid.

The system cannot simply accept whichever response happens to arrive last if doing so would overwrite another person's newer work.

Phoundri therefore distinguishes between collaborative state and authoritative business mutations.

Collaborative state

Yjs handles eligible local and shared-state operations, enabling immediate interaction and reconciliation.

Authoritative state

Server-side mutation handling verifies permissions, expected versions, identities, structural rules, and other business invariants before accepting consequential changes.

Cloudflare Durable Objects provide coordination mechanisms for stateful operations. Phoundri's schema-room design uses an authoritative serialization boundary for structural Table changes.

The intended result is a system where collaboration can remain responsive without sacrificing correctness.

CRDTs help distributed participants converge. Authoritative mutation validation determines whether consequential operations are permitted.

These are complementary responsibilities.

5. Phoundri's storage and execution architecture

Phoundri's architecture combines several technologies with distinct roles.

5.1 Cloudflare Workers

Cloudflare Workers provide the server-side execution environment for application APIs and associated logic.

5.2 Cloudflare Durable Objects

Durable Objects support stateful coordination and interaction among connected clients.

Phoundri uses Durable Objects in its collaboration and authoritative coordination architecture, including schema-room operations.

Durable Object coordination does not eliminate the need for correct authorization, persistence, and atomic mutation behavior.

5.3 Cloudflare D1

D1 provides relational persistence for Phoundri customer data.

A foundational Phoundri design decision is physical customer isolation at the database level.

Under this architecture:

  • Each customer Organization exclusively owns its assigned D1 databases.
  • Different customer Organizations do not share one customer-data D1 database.
  • An Organization may use multiple exclusively owned databases that function as one logical database.

This approach supports a defined isolation boundary while allowing Phoundri to evolve its storage architecture.

It does not, by itself, guarantee freedom from software vulnerabilities or operational failures. Authorization and routing must remain correct across every access path.

5.4 IndexedDB and local-first state

Browser-side storage supports immediate access to locally cached workspace information.

Local queues preserve eligible pending operations for later server reconciliation.

The objective is not to make the browser an unrestricted authority over shared business data. It is to make the interface responsive while preserving authoritative server-side validation.

5.5 Yjs

Yjs provides CRDT-based shared-state capabilities for eligible collaborative resources.

The collaboration system and authoritative database responsibilities remain deliberately distinct.

6. Why Phoundri rejected a universal event store

Phoundri's historical architecture review identified an important design decision.

An earlier implementation included a hybrid logical clock operation log for Table records. That approach was subsequently retired as responsibilities moved into more specialized systems.

The adopted design deliberately avoided creating a second universal event-sourced database alongside Yjs.

Instead, it separated four related but different capabilities:

Undo and Redo: Reversing eligible user actions while respecting current authoritative state.

Audit: Recording relevant information about changes and their provenance.

Record restoration: Recovering supported prior record data under the relevant contract.

Deleted-resource recovery: Restoring retained resources through established recovery mechanisms.

This separation is intentional.

Undo history is not necessarily a permanent audit log. Audit data is not necessarily sufficient to reconstruct a database. The Recycle Bin is not the same as version history.

A universal event log would not automatically resolve those differences.

Phoundri's decision is to reuse the appropriate existing mechanisms and improve the connections between them rather than construct a redundant storage architecture.

7. History without unlimited event accumulation

A business application should retain the information necessary to fulfill its promises.

It should not retain every transient interaction indefinitely simply because the architecture supports observing it.

Consider three kinds of activity:

Transient interaction

Moving a mouse, hovering over a menu, or dragging a resize handle through intermediate positions generally does not justify a permanent business-history entry.

Collaborative updates

Typing, shared editing, and other high-frequency operations require efficient state synchronization. CRDT updates may be batched, merged, checkpointed, or compacted where safe.

Meaningful business operations

Deleting a Table, changing permissions, importing records, or modifying consequential schema may require authoritative receipts, audit metadata, recovery state, or version preconditions.

The appropriate retention mechanism depends on the operation.

For example, importing thousands of records may represent one meaningful user transaction while still requiring multiple internal validated writes.

It should not automatically generate thousands of separate top-level Undo actions.

The architectural objective is bounded, useful history, not unlimited event accumulation.

Any compaction strategy must preserve the information required for active synchronization, unresolved offline operations, supported Undo, audit obligations, and resource recovery.

8. Undo and Redo in a collaborative system

Undo is easy to describe but surprisingly difficult to implement correctly when multiple people share data.

Suppose:

  1. User A renames a column.
  2. User B subsequently changes that same column.
  3. User A presses Undo.

A naive implementation might write User A's previous value back into the Table, destroying User B's newer change.

Phoundri's structural Undo work addresses this through authoritative version preconditions.

A structural mutation identifies the state it expects. The server validates that expectation at the authoritative mutation boundary.

If newer work makes the original assumption invalid, the operation must refuse or require appropriate conflict resolution.

This follows an essential principle:

Undo is not permission to overwrite another person's subsequent work.

Correct Undo and Redo also require distinguishing a field's expected version, the identity of the logical operation, and the resulting authoritative state.

Operation receipts support deduplication of legitimate retries, particularly when network delivery is uncertain.

These mechanisms protect correctness but are not equivalent to implementing a universal event-sourced database.

Current implementation scope

As of this paper's preparation, Phoundri's development work includes structural Undo/Redo improvements, atomic concurrency protections, operation-receipt identity hardening, and coordination of existing Table Undo mechanisms.

Not all these capabilities should be presented as generally available until they are independently certified and verified in production.

9. Non-destructive editing and recovery

Another useful influence comes from applications such as Adobe Photoshop, where certain editing techniques preserve source material independently of later transformations.

The underlying idea is valuable for business software: where practical, a user should be able to reverse an eligible change without losing the original resource and its relationships.

Phoundri applies this principle selectively through existing state-management and restoration mechanisms.

For supported soft-deleted resources, the system retains recoverable information within its established retention period.

This may include stable resource identities and associated data required for restoration.

The Recycle Bin provides recovery for supported deleted resources. Other resource types may use their own recovery interfaces.

The present soft-delete design uses a 30-day retention window for supported resources.

This is not a promise that every Phoundri action can be undone or that every deleted resource can be recovered.

Examples such as external payment processing, outbound communications, permanent deletion, and expired recovery periods require separate treatment.

Non-destructive design is a disciplined recovery philosophy, not a claim of universal reversibility.

10. Security and operational integrity

Phoundri's architecture must preserve several properties regardless of how history is represented.

Tenant isolation

Customer data and recoverable history must remain scoped to the correct Organization and its exclusive storage resources.

Authorization

A CRDT update, cached browser state, or historical mutation receipt must never independently grant permission to modify data.

Atomicity

Consequential structural changes must validate their authoritative preconditions as part of the actual mutation operation.

Idempotency

Retries must not create duplicate effects. Independent users and independent logical operations must not be incorrectly merged simply because they request similar changes.

Retention

Audit, recovery, and collaboration state require explicit policies for retention, cleanup, and privacy.

Encryption

Data protection must include encryption in transit and at rest, supported by correct identity and access controls.

Recovery correctness

A recovery interface must distinguish recoverable resources from resources that have expired or been permanently removed.

These properties require ongoing testing and verification. Selecting Yjs, Durable Objects, or D1 does not automatically prove them.

11. What this means for Phoundri customers

The architectural choices described in this paper are intended to deliver practical outcomes.

Responsive workspaces: Locally available data can render without waiting for an initial network response.

Collaboration: Eligible shared changes can synchronize among users and devices.

Intermittent connectivity: Local-first mechanisms support continued work where offline operation is available.

Reliable structural changes: Authoritative validation protects consequential data modifications from unsafe concurrency.

Useful history: Different history mechanisms support auditability, Undo, and restoration according to their specific contracts.

Data isolation: Dedicated customer databases establish an explicit physical storage boundary.

Efficient operation: Specialized mechanisms reduce the need for redundant, unlimited historical event storage.

These are architectural goals and implemented capabilities with varying maturity across the product. Specific guarantees must be evaluated against the currently released feature.

12. Architectural boundaries and future evolution

Phoundri's architectural direction is not a rejection of historical information.

It is a rejection of unnecessary duplication.

Future capabilities may expand version comparisons, collaborative editing, resource restoration, and unified Undo interfaces.

Such improvements should build on the existing architecture when possible.

The design does not require introducing an independent universal event store to achieve those goals.

Phoundri will continue to evaluate new mechanisms against measurable requirements for correctness, storage efficiency, security, and responsiveness.

If a future domain genuinely benefits from event sourcing, that should be assessed on its own merits rather than imposed across every primitive.

Conclusion

Event sourcing and CRDTs offer different ways to reason about changing information.

Event sourcing emphasizes reconstructing state through a durable history of events.

CRDTs emphasize convergence among distributed copies of shared data.

Phoundri draws from both fields but does not conflate them.

Its chosen architecture combines Yjs collaboration, local-first state, authoritative mutation handling, relational persistence, audit projections, operation receipts, and specialized recovery mechanisms.

The goal is not to implement the greatest possible number of architectural patterns.

It is to deliver software that can be responsive, collaborative, recoverable, and trustworthy without unnecessarily duplicating state or retaining endless low-level events.

Phoundri's architectural philosophy is to preserve the integrity of work while making the experience of doing that work as immediate and straightforward as possible.

Companion article: for a plain-language look at what these choices mean for a small business, read Your Business Doesn't Stop When the Internet Slows Down. Your Software Shouldn't Either.


References and further reading

  1. Martin Fowler, Event Sourcing. https://martinfowler.com/eaaDev/EventSourcing.html
  2. Martin Fowler, What Do You Mean by Event-Driven? https://martinfowler.com/articles/201701-event-driven.html
  3. Microsoft Azure Architecture Center, Event Sourcing Pattern. https://learn.microsoft.com/en-us/azure/architecture/patterns/event-sourcing
  4. Yjs, Official Documentation. https://docs.yjs.dev/
  5. Yjs, Source Repository and Technical Documentation. https://github.com/yjs/yjs
  6. Cloudflare, Durable Objects Documentation. https://developers.cloudflare.com/durable-objects/

Publication note: This paper describes architectural decisions and development direction. It should not be interpreted as a blanket assertion that every proposed history, recovery, or collaboration feature has shipped or been independently certified.

Back to White Papers