This project is a Proof of Concept (PoC) built with .NET, aiming to demonstrate the application of the Event Sourcing pattern using RavenDB as the database.
The PoC explores concepts such as event persistence, state rehydration, and query projections (read models), showing how RavenDB can be leveraged as an Event Store in distributed applications.
- Validate the use of RavenDB as an event store.
- Demonstrate how to implement Event Sourcing in .NET.
- Simulate write and read operations based on events.
- Provide a starting point for applications adopting event-driven architectures.
The PoC follows the principles of CQRS + Event Sourcing:
- Command Side (Write Model): handles commands and generates events that describe state changes.
- Event Store (RavenDB): stores all events immutably.
- Projections (Read Model): built by applying events to provide optimized queries.
- .NET
- RavenDB (Event Store and Projections)
- gRPC (service communication)
- CQRS(MediatR) + Event Sourcing
- Swagger (API documentation)
- Validation (FluentValidation)
- Error Handling: Pattern Result
- Automatic Validation: ValidationBehavior
- DTOs: Data Transfer Objects
- Repository Pattern: Data access abstraction (RavenDB)
Vault.Gps/
├── Application/ # Application layer (CQRS)
│ ├── Commands/ # Command definitions
│ ├── CommandHandlers/ # Handlers for commands
│ ├── Queries/ # Query definitions
│ ├── QueryHandlers/ # Handlers for queries
│ ├── DTOs/ # Data Transfer Objects
│ ├── Behaviors/ # MediatR behaviors (validation)
│ └── Common/ # Utilities (Result<T>, etc)
│
├── Controllers/ # API Endpoints
│ └── GpsPositionController.cs
│
├── Domain/ # Business rules
│ ├── Validators/ # FluentValidation validators
│ └── Enums/
│
├── Infra/ # Infrastructure layer
│ └── Database/
│ ├── Repositories/ # Data access implementations
│ └── DocumentStoreHolder.cs # RavenDB session management
│
├── Contracts/ # Shared interfaces and models
│ ├── Models/
│ ├── Services/
│ └── Enums/
│
├── Extensions/ # Extension methods for DI
│ ├── ApplicatonService/
│ ├── Database/
│ └── Validations/
│
├── Program.cs # DI and middleware configuration
└──appsettings.json # Configuration
- .NET 9+ SDK
- RavenDB running locally (can be via Docker).
- Clone the repository:
git clone https://github.com/Note45/poc-ravendb-vault-gps.git
cd ravendb-vault-grps-
Create base vault-gps in RavenDB
-
Configure the RavenDB connection string in appsettings.json.
-
Run the project:
dotnet run --project Vault.Gps/Vault.Gps.csproj - The RavenDB Vault GRPS API will be available at: