PHPackages                             azaharizaman/nexus-event-stream - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-event-stream

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-event-stream
===============================

Nexus EventStream Package - Event sourcing for critical domains (Finance GL, Inventory)

v0.1.0-alpha1(1mo ago)02↓100%MITPHPPHP ^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-event-stream)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-event-stream)[ RSS](/packages/azaharizaman-nexus-event-stream/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Nexus EventStream Package
=========================

[](#nexus-eventstream-package)

**Event Sourcing Engine for Critical Domains (Finance GL, Inventory)**

The EventStream package provides an immutable, append-only event store for domains requiring complete audit trails and state replay capability. This is NOT a general-purpose event bus—it's specifically designed for event sourcing in compliance-critical domains.

🎯 Purpose
---------

[](#-purpose)

Event Sourcing is **RESERVED** for critical domains where you need to answer: *"What was the exact state of this entity on \[date\]?"*

**Use EventStream for:**

- ✅ **Finance (GL)**: Every debit/credit is an event (SOX/IFRS compliance)
- ✅ **Inventory**: Every stock change is an event (stock accuracy verification)
- ✅ **Large Enterprise AP/AR**: Payment lifecycle tracking (optional)

**Do NOT use EventStream for:**

- ❌ HRM, Payroll, CRM, Procurement (use `Nexus\AuditLogger` for timeline views)
- ❌ User activity logs (use `Nexus\AuditLogger`)
- ❌ General application events (use Laravel events or message queue)

🏗️ Architecture
---------------

[](#️-architecture)

This package follows the **Hybrid Approach** described in ARCHITECTURE.md:

### The "Feed" View (AuditLogger) vs. "Replay" Capability (EventStream)

[](#the-feed-view-auditlogger-vs-replay-capability-eventstream)

FeatureAuditLoggerEventStreamPurposeUser-facing timeline ("what happened")State reconstruction ("replay history")StorageOutcome-based logsImmutable event logQuery"Show me changes to Customer #123""What was GL Account 1000 balance on 2024-10-15?"ComplexityLowHigh (snapshots, projections, upcasters)Use Case95% of domainsCritical domains only### Key Concepts

[](#key-concepts)

1. **Event**: Immutable fact that happened (AccountCreditedEvent, StockReservedEvent)
2. **Stream**: Ordered sequence of events for an aggregate
3. **Aggregate**: Entity whose state is rebuilt from events (e.g., GL Account, Inventory Item)
4. **Projection**: Read model built from event stream (e.g., CurrentBalanceProjection)
5. **Snapshot**: Cached aggregate state to optimize replay performance
6. **Temporal Query**: Query state at specific point in time

📦 Framework-Agnostic Design
---------------------------

[](#-framework-agnostic-design)

This package is **pure PHP** with no Laravel dependencies. All persistence operations are defined via interfaces:

- `EventStoreInterface`: Append events to streams
- `StreamReaderInterface`: Read events from streams
- `SnapshotRepositoryInterface`: Store/retrieve aggregate snapshots
- `ProjectorInterface`: Rebuild state from events
- `EventSerializerInterface`: Serialize event payloads

🔧 Installation
--------------

[](#-installation)

```
composer require azaharizaman/nexus-event-stream:"*@dev"
```

📋 Requirements Satisfied
------------------------

[](#-requirements-satisfied)

This package satisfies 104 requirements across 7 categories:

- **14 Architectural Requirements** (ARC-EVS-7001 to ARC-EVS-7014)
- **13 Business Requirements** (BUS-EVS-7101 to BUS-EVS-7113)
- **28 Functional Requirements** (FUN-EVS-7201 to FUN-EVS-7228)
- **9 Performance Requirements** (PER-EVS-7301 to PER-EVS-7309)
- **10 Reliability Requirements** (REL-EVS-7401 to REL-EVS-7410)
- **10 Security Requirements** (SEC-EVS-7501 to SEC-EVS-7510)
- **10 Integration Requirements** (INT-EVS-7601 to INT-EVS-7610)
- **8 Usability Requirements** (USA-EVS-7701 to USA-EVS-7708)

🚀 Usage Example
---------------

[](#-usage-example)

### Publishing Events

[](#publishing-events)

```
use Nexus\EventStream\Contracts\EventStoreInterface;
use Nexus\Finance\Events\AccountCreditedEvent;

// In Nexus\Finance\Services\LedgerManager
public function __construct(
    private readonly EventStoreInterface $eventStore
) {}

public function postJournalEntry(JournalEntry $entry): void
{
    foreach ($entry->getLines() as $line) {
        if ($line->isCredit()) {
            $this->eventStore->append(
                $line->getAccountId(),
                new AccountCreditedEvent(
                    accountId: $line->getAccountId(),
                    amount: $line->getAmount(),
                    journalEntryId: $entry->getId()
                )
            );
        }
    }
}
```

### Temporal Queries

[](#temporal-queries)

```
use Nexus\EventStream\Services\EventStreamManager;

// Get account balance at specific date
$balance = $manager->getStateAt(
    aggregateId: 'account-1000',
    timestamp: new \DateTimeImmutable('2024-10-15')
);
```

### Building Projections

[](#building-projections)

```
use Nexus\EventStream\Contracts\ProjectorInterface;

// Projection rebuilds current balance from events
class CurrentBalanceProjector implements ProjectorInterface
{
    public function project(EventInterface $event): void
    {
        if ($event instanceof AccountCreditedEvent) {
            $this->balances[$event->accountId] += $event->amount;
        }
    }
}
```

🔒 Security &amp; Compliance
---------------------------

[](#-security--compliance)

- **Immutable Streams**: Events cannot be modified or deleted (append-only)
- **Tenant Isolation**: All streams are tenant-scoped
- **Encryption**: Event payloads encrypted at rest and in transit
- **Audit Trail**: Event store operations logged via `Nexus\AuditLogger`
- **SOX Compliance**: Immutable financial event trails
- **GDPR**: Support for event anonymization (not deletion)

📊 Performance Characteristics
-----------------------------

[](#-performance-characteristics)

OperationTargetNotesEvent Append&lt; 50ms (p95)With database transactionStream Read (1000 events)&lt; 100msFrom databaseSnapshot Restoration&lt; 10msIn-memory cacheReplay 10K events&lt; 5sFor state reconstructionTemporal Query&lt; 3sFor &lt; 10K events📖 Documentation
---------------

[](#-documentation)

### Package Documentation

[](#package-documentation)

- **[Getting Started Guide](docs/getting-started.md)** - Quick start guide with prerequisites, concepts, and first integration
- **[API Reference](docs/api-reference.md)** - Complete documentation of all interfaces, value objects, and exceptions
- **[Integration Guide](docs/integration-guide.md)** - Laravel and Symfony integration examples
- **[Basic Usage Example](docs/examples/basic-usage.php)** - Simple event publishing and reading patterns
- **[Advanced Usage Example](docs/examples/advanced-usage.php)** - Snapshots, temporal queries, and concurrency control

### Additional Resources

[](#additional-resources)

- `IMPLEMENTATION_SUMMARY.md` - Implementation progress and metrics (122 tests, 100% pass rate)
- `REQUIREMENTS.md` - 104 detailed requirements across 7 categories
- `TEST_SUITE_SUMMARY.md` - Test coverage and results
- `VALUATION_MATRIX.md` - Package valuation metrics (estimated value: $85,296)
- See root `ARCHITECTURE.md` section "Hybrid Approach: Feed vs. Replay"

🤝 Integration Points
--------------------

[](#-integration-points)

- **Nexus\\Finance**: Publishes journal entry events (AccountCreditedEvent, AccountDebitedEvent)
- **Nexus\\Inventory**: Publishes stock events (StockReservedEvent, StockShippedEvent)
- **Nexus\\AuditLogger**: Logs event store operations (meta-auditing)
- **Nexus\\Storage**: Stores snapshots and archived events
- **Nexus\\Notifier**: Sends alerts for projection failures

⚠️ When NOT to Use
------------------

[](#️-when-not-to-use)

If you only need to show "a timeline of changes" to users, use `Nexus\AuditLogger` instead. EventStream adds complexity and should only be used when state replay is legally or operationally required.

📝 License
---------

[](#-license)

MIT License - see LICENSE file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (459 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (139 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-event-stream/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-event-stream/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-event-stream)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M117](/packages/web-auth-webauthn-lib)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M195](/packages/sulu-sulu)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51090.8k2](/packages/web-auth-webauthn-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
