Skip to content

gradyzhuo/KurrentDB-Swift

Repository files navigation

KurrentDB-Swift

License Swift Package Index Swift-build-testing

A modern, type-safe Swift client for Kurrent (formerly EventStoreDB)

Built with ❤️ for Server-Side Swift and Event Sourcing

📚 Documentation🚀 Getting Started💬 Discussions


✨ Why KurrentDB-Swift?

Event Sourcing is a powerful pattern for building scalable, auditable systems. KurrentDB-Swift brings this capability to the Swift ecosystem with a modern, type-safe client.

  • 🎯 Native Swift - Designed for Swift from the ground up, not a wrapper
  • Modern Concurrency - Full async/await support with Swift 6 compatibility
  • 🔒 Type-Safe - Leverages Swift's type system for compile-time safety
  • 🚀 Production-Ready - Over 1 year of development, 425+ commits, 46 releases
  • 📖 Well-Documented - Comprehensive guides on Swift Package Index
  • 🔧 Actively Maintained - Regular updates and responsive to issues

🎬 Quick Start

Installation

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/gradyzhuo/KurrentDB-Swift.git", from: "1.11.2")
]

Your First Event

import KurrentDB

// 1. Connect to Kurrent
let client = KurrentDBClient(settings: .localhost())

// 2. Create an event
let event = EventData(
    eventType: "OrderPlaced",
    model: ["orderId": "order-123", "total": 99.99] // or any Codable instance.
)

// 3. Append to stream
try await client.appendStream("orders", events: [event]) {
    $0.revision(expected: .any)
}

// 4. Read events back
let events = try await client.readStream("orders") {
    $0.backward().startFrom(revision: .start)
}

for try await response in events {
    if let event = try response.event {
        print("Event: \(event.eventType)")
    }
}

That's it! You're now using Event Sourcing in Swift. 🎉

📖 Learn More

Check out our comprehensive documentation on Swift Package Index:

🎯 Features

  • ✅ Stream operations (append, read, delete)
  • ✅ Subscriptions (catch-up and persistent)
  • ✅ Projections management
  • ✅ Optimistic concurrency control
  • ✅ TLS/SSL support
  • ✅ Cluster configuration
  • ✅ Connection management with auto-reconnection
  • ✅ Swift 6 ready (zero data-race safety)

📦 Requirements

  • Swift 6.0 or later
  • macOS 15+ / iOS 18+ / Linux
  • Kurrent 24.2+ (or EventStoreDB 23.10+)

🏗️ Used in Production?

We'd love to hear about your experience! Share your story in Discussions or add your project to our showcase.

🤝 Contributing

Contributions are welcome! Whether it's:

  • 🐛 Bug reports
  • 💡 Feature requests
  • 📖 Documentation improvements
  • 🔧 Code contributions

Check out our Contributing Guide to get started.

💬 Community

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

Built with these excellent libraries:

Inspired by official Kurrent/EventStoreDB clients.


⭐ If you find KurrentDB-Swift useful, please consider giving it a star! ⭐

Made with ❤️ by Grady Zhuo and contributors

About

Kurrent Databse gRPC Client SDK in Swift.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •