Pericarp Go Library
A comprehensive Go library implementing Domain-Driven Design (DDD), Command Query Responsibility Segregation (CQRS), and Event Sourcing patterns with clean architecture principles.
Quick Start
package main
import (
"context"
"log"
"github.com/akeemphilbert/pericarp/pkg/eventsourcing"
"github.com/akeemphilbert/pericarp/pkg/application"
"go.uber.org/fx"
)
func main() {
app := fx.New(
application.Module,
fx.Invoke(func(bus application.CommandBus) {
// Use the command bus
}),
)
app.Run()
}
Features
- Clean Architecture: Strict separation between domain, application, and infrastructure layers
- CQRS Pattern: Separate command and query handling with unified middleware support
- Event Sourcing: Persist-then-dispatch pattern with event store and dispatcher
- Database Flexibility: Support for SQLite (development) and PostgreSQL (production)
- Dependency Injection: Built-in Fx modules for easy configuration
- Comprehensive Testing: Unit tests and integration tests
Installation
Prerequisites
- Go 1.21 or later
- Go modules enabled (default in Go 1.16+)
Install Latest Version
Install the latest version of Pericarp with a single command:
go get github.com/akeemphilbert/pericarp
Install Specific Version
To install a specific version, use the version tag:
# Install a specific version (e.g., v1.0.0)
go get github.com/akeemphilbert/[email protected]
# Install the latest version from a specific branch
go get github.com/akeemphilbert/pericarp@main
Verify Installation
After installation, verify the package is available:
go list -m github.com/akeemphilbert/pericarp
Documentation
Project Structure
The project follows the golang-standards/project-layout structure:
pericarp/
βββ pkg/ # Public API packages
β βββ eventsourcing/ # Event sourcing primitives (events, event stores)
β βββ application/ # Command/query handlers, CQRS bus
β βββ infrastructure/ # Event store, database implementations
βββ internal/ # Private implementation packages
βββ cmd/pericarp/ # CLI tools/demos
βββ examples/ # Runnable examples for users
βββ test/ # Integration tests
βββ docs/ # Documentation
βββ scripts/ # Build/automation scripts
βββ configs/ # Configuration templates
For detailed architecture information, see docs/ARCHITECTURE.md.
Documentation
Development
Prerequisites
- Go 1.21 or later
- Make (for using the Makefile)
Development Commands
# Set up development environment
make deps
# Run tests
make test
# Format code
make fmt
# Run linter
make lint
# Run development workflow (format, lint, test)
make dev-test
Contributing
See CONTRIBUTING.md for guidelines on contributing to the project.
License
MIT License - see LICENSE file for details.
Support