eventium-core: Core module for eventium

[ database, eventsourcing, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Eventium-core provides the core abstractions and utilities for building event sourcing systems in Haskell. It includes event store interfaces, command handlers, projections, read models, process managers, and Template Haskell utilities for generating boilerplate code. This is the foundational package that all other Eventium modules build upon.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0
Change log CHANGELOG.md
Dependencies aeson (>=1.5 && <2.3), base (>=4.9 && <5), containers (>=0.6 && <0.8), contravariant (>=1.5 && <1.6), http-api-data (>=0.4 && <0.7), path-pieces (>=0.2 && <0.3), template-haskell (>=2.16 && <2.22), text (>=1.2 && <2.2), transformers (>=0.5 && <0.7), uuid (>=1.3 && <1.4), x-sum-type-boilerplate (>=0.1 && <0.2) [details]
License MIT
Author
Maintainer Alexander Sidorenko
Category Database, Eventsourcing
Home page https://github.com/aleks-sidorenko/eventium#readme
Bug tracker https://github.com/aleks-sidorenko/eventium/issues
Source repo head: git clone https://github.com/aleks-sidorenko/eventium
Uploaded by aleks_sidorenko at 2025-12-15T08:51:16Z
Distributions
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 1 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for eventium-core-0.1.0

[back to package description]

Eventium Core

Core abstractions and utilities for building event sourcing systems in Haskell.

Overview

eventium-core is the foundational package of the Eventium event sourcing framework. It provides all the essential abstractions, interfaces, and utilities needed to build event-sourced applications with CQRS patterns.

Key Components

Event Store (Eventium.Store.Class)

  • EventStoreReader - Read events from streams (versioned and global)
  • EventStoreWriter - Append events with optimistic concurrency control
  • StreamEvent - Event metadata wrapper with stream keys and positions

Projection (Eventium.Projection)

Pure event fold for rebuilding state from events. Used for both domain aggregates (write model) and read models (query side).

data Projection state event = Projection
  { projectionSeed :: state
  , projectionEventHandler :: state -> event -> state
  }

Command Handler (Eventium.CommandHandler)

Implements the aggregate pattern from DDD/Event Sourcing. Processes commands, validates against current state, and emits events.

data CommandHandler state event command = CommandHandler
  { commandHandlerHandler :: state -> command -> [event]
  , commandHandlerProjection :: Projection state event
  }

Process Manager (Eventium.ProcessManager)

Coordinates long-running business processes across multiple aggregates. Implements the Saga pattern for complex workflows.

Read Model (Eventium.ReadModel.Class)

Builds denormalized views optimized for queries. Tracks processed events for eventual consistency with the write side.

Serializer (Eventium.Serializer)

Type-safe event serialization/deserialization with JSON support and Template Haskell utilities for automatic boilerplate generation.

Template Haskell Utilities (Eventium.TH)

  • deriveJSON - Generate JSON instances
  • deriveSumTypeSerializer - Generate serializers for sum types (event polymorphism)
  • makeProjection - Generate projection boilerplate

Features

  • ✅ Type-safe event sourcing abstractions
  • ✅ Optimistic concurrency control with ExpectedPosition
  • ✅ CQRS pattern support (command/query separation)
  • ✅ Process Manager (Saga) pattern
  • ✅ Projection caching for performance
  • ✅ Template Haskell for reducing boilerplate
  • ✅ Storage backend agnostic (memory, SQL, NoSQL)

Usage

Add eventium-core to your package dependencies:

dependencies:
  - eventium-core

Then choose a storage backend:

  • eventium-memory - In-memory (development/testing)
  • eventium-sqlite - SQLite (single-process apps)
  • eventium-postgresql - PostgreSQL (production systems)

Design Principles

  1. Type Safety - Phantom types prevent mixing concerns
  2. Functional Purity - Projections are pure folds
  3. Abstraction - Backend-agnostic core types
  4. CQRS - Clear command/query separation
  5. Standard Patterns - Aggregates, Sagas, Read Models

Documentation

License

MIT - see LICENSE.md