5.5 KiB
5.5 KiB
Tutorials
Step-by-step tutorials for building applications with Svrnty.CQRS.
Overview
This section provides comprehensive, hands-on tutorials that walk you through building real-world applications using Svrnty.CQRS.
Tutorial Series
Modular Solution
Build a properly structured solution with separated concerns:
- Solution Structure - Create project structure (Api, CQRS, Domain, Infrastructure)
- Domain Layer - Define entities, value objects, and domain events
- CQRS Layer - Implement commands, queries, and handlers
- DAL Layer - Set up Entity Framework Core and repositories
- API Layer - Configure HTTP and gRPC endpoints
- Testing Strategy - Unit and integration testing
What You'll Learn:
- Multi-project solution architecture
- Layer separation and dependencies
- Best practices for code organization
- Testing strategies for each layer
Prerequisites:
- .NET 10 SDK
- Basic understanding of C# and ASP.NET Core
Duration: ~2-3 hours
Event Sourcing
Build an event-sourced application from scratch:
- Fundamentals - Event sourcing concepts and benefits
- Aggregate Design - Design aggregates and domain events
- Events and Workflows - Implement event workflows
- Projections - Build read models from events
- Snapshots - Optimize with snapshots
- Replay and Rebuild - Replay events to rebuild projections
What You'll Learn:
- Event sourcing pattern
- Aggregate root design
- Projection building
- Event replay
- Snapshot optimization
Prerequisites:
- Completed "Getting Started" guide
- Understanding of domain-driven design
- PostgreSQL installed
Duration: ~3-4 hours
E-Commerce Example
Build a complete e-commerce order system:
- Requirements - Define domain and requirements
- Domain Events - Design order lifecycle events
- Commands - PlaceOrder, CancelOrder, ShipOrder
- Queries - GetOrder, ListOrders, SearchOrders
- Projections - Order summaries and analytics
- Sagas - Order fulfillment saga
- HTTP API - Expose via HTTP endpoints
- gRPC API - Expose via gRPC services
- Complete Code - Full working implementation
What You'll Learn:
- Real-world CQRS application
- Event-driven workflows
- Saga pattern for distributed transactions
- Dual HTTP/gRPC endpoints
- Complete working code
Prerequisites:
- Completed "Modular Solution" tutorial
- PostgreSQL installed
- Understanding of e-commerce domain
Duration: ~4-6 hours
Quick Start Projects
Hello World CQRS
# Create new project
dotnet new webapi -n HelloCQRS
cd HelloCQRS
# Add packages
dotnet add package Svrnty.CQRS
dotnet add package Svrnty.CQRS.MinimalApi
# Create command
# Create handler
# Register services
# Run
See Getting Started for full guide.
Event Streaming Quick Start
# Add event streaming
dotnet add package Svrnty.CQRS.Events.PostgreSQL
dotnet add package Svrnty.CQRS.Events.ConsumerGroups
# Start PostgreSQL
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:16
# Configure services
# Publish events
# Consume events
See Event Streaming Getting Started for full guide.
Learning Path
Beginner
Intermediate
Advanced
Sample Code
All tutorial code is available in the Svrnty.Sample project.
Key Examples:
Community Examples
Share your tutorials and examples:
- Submit a pull request with your tutorial
- Link to your blog post or GitHub repo
- Join the discussion on GitHub