A modern, event-driven multi-tenant Loyalty & Rewards SaaS platform built with .NET 9.0
LoyaltyForge is a production-ready microservices-based loyalty and rewards platform designed for e-commerce businesses. It features a complete Event-Driven Architecture (EDA) with CQRS, Saga patterns, and comprehensive testing.
- β Event-Driven Architecture - RabbitMQ-based async communication
- β Multi-Tenant SaaS - Complete tenant isolation
- β Saga Pattern - Distributed transaction orchestration
- β CQRS - Command/Query separation
- β Outbox Pattern - Reliable event publishing
- β Comprehensive Testing - 28+ unit tests with CI/CD integration
- β E-commerce Integration - Shopify webhooks support
- β Points Engine - Flexible points earning and redemption
- β Rewards Catalog - Configurable reward management
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Auth & Tenant ββββββΆβ API Gateway βββββββ E-commerce β
β Service β β (Ocelot) β β Integration β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
β βΌ
ββββββββΌβββββββββββ βββββββββββββββββββ
β Points Engine ββββββββ RabbitMQ β
β Service β β Message Bus β
βββββββββββββββββββ βββββββββββββββββββ
β β²
β β
ββββββββΌβββββββββββ β
β Rewards βββββββββββββββββ
β Service β
βββββββββββββββββββ
Order Processing Flow:
Shopify β OrderPlacedEvent β Points Engine β PointsEarnedEvent
Reward Redemption Flow (Saga):
Customer β RedemptionSaga β DeductPointsCommand β Points Engine
β
PointsDeductedEvent / PointsDeductionFailedEvent
β
Redemption Complete/Failed
- .NET 9.0 - Latest .NET framework
- ASP.NET Core - Web API framework
- Entity Framework Core - ORM
- PostgreSQL - Primary database
- RabbitMQ - Message broker
- Serilog - Structured logging
- xUnit - Testing framework
- Moq - Mocking framework
- FluentAssertions - Fluent test assertions
- Codecov - Code coverage tracking
- Docker & Docker Compose - Containerization
- GitHub Actions - CI/CD pipeline
- Dependabot - Automated dependency updates
- .NET 9.0 SDK
- Docker Desktop
- PostgreSQL 16
- RabbitMQ 3.x
See QUICKSTART.md for detailed commands and options.
# Build and run everything in one command
./scripts/run.sh -b
# Or run in background
./scripts/run.sh -b -d
# Run tests
./scripts/test.shService URLs:
- API Gateway: http://localhost:5000
- Auth+Tenant: http://localhost:5001
- Points Engine: http://localhost:5003
- Rewards: http://localhost:5004
- RabbitMQ UI: http://localhost:15672 (guest/guest)
For detailed documentation on all available commands, see QUICKSTART.md.
-
Clone the repository
git clone https://github.com/iaashu98/LoyaltyForge.git cd LoyaltyForge -
Start infrastructure services
docker-compose up -d postgres rabbitmq
-
Run database migrations
dotnet ef database update --project src/Services/AuthTenant/AuthTenant.Infrastructure dotnet ef database update --project src/Services/PointsEngine/PointsEngine.Infrastructure dotnet ef database update --project src/Services/Rewards/Rewards.Infrastructure
-
Start all services
# Terminal 1 - Auth & Tenant dotnet run --project src/Services/AuthTenant/AuthTenant.Api # Terminal 2 - E-commerce Integration dotnet run --project src/Services/EcommerceIntegration/EcommerceIntegration.Api # Terminal 3 - Points Engine dotnet run --project src/Services/PointsEngine/PointsEngine.Api # Terminal 4 - Rewards Service dotnet run --project src/Services/Rewards/Rewards.Api
-
Access services
- Auth & Tenant: http://localhost:5001
- E-commerce Integration: http://localhost:5002
- Points Engine: http://localhost:5003
- Rewards Service: http://localhost:5004
- RabbitMQ Management: http://localhost:15672 (guest/guest)
# Run all tests
dotnet test tests/Unit/**/*.csproj
# Run specific service tests
dotnet test tests/Unit/Rewards.Application.Tests/Rewards.Application.Tests.csproj
dotnet test tests/Unit/PointsEngine.Application.Tests/PointsEngine.Application.Tests.csproj
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"- Total Tests: 28+ unit tests
- Coverage Goal: 70% overall, 90% for critical business logic
- CI/CD: Tests run automatically on every push/PR
Tested Components:
- β Command Handlers (DeductPointsCommandHandler)
- β Event Handlers (OrderPlacedEventHandler)
- β Saga Orchestration (RedemptionSaga)
- β Domain Entities (RewardRedemption)
- EDA Implementation Guide - Complete EDA architecture
- Architecture Analysis - System design decisions
- Testing Strategy - Comprehensive testing approach
- Testing Guide - End-to-end testing scenarios
- Unit Testing Summary - Test implementation details
- CI/CD Update Summary - Pipeline configuration
- Auth & Tenant API Tests
- Swagger UI available at
/swaggeron each service
Main Pipeline (.NET CI/CD)
- β Full solution build
- β Unit test execution with coverage
- β Multi-service parallel builds
- β Test result publishing
- β Codecov integration
Quick Feedback (Unit Tests Only)
- β Fast test execution on feature branches
- β PR test result comments
Automation (Dependabot)
- β Weekly dependency updates
- β Security vulnerability patches
- Main/Develop: Full CI/CD pipeline
- Feature Branches: Quick unit tests
- Pull Requests: Both workflows + test results
LoyaltyForge/
βββ src/
β βββ Services/
β β βββ AuthTenant/ # Authentication & tenant management
β β βββ EcommerceIntegration/ # Shopify webhook integration
β β βββ PointsEngine/ # Points earning & deduction
β β βββ Rewards/ # Reward catalog & redemption
β β βββ ApiGateway/ # API gateway (Ocelot)
β βββ Shared/
β βββ LoyaltyForge.Common/ # Shared utilities
β βββ LoyaltyForge.Contracts/ # Event & command contracts
β βββ LoyaltyForge.Messaging/ # RabbitMQ infrastructure
βββ tests/
β βββ Unit/
β βββ Rewards.Application.Tests/
β βββ PointsEngine.Application.Tests/
β βββ LoyaltyForge.Messaging.Tests/
βββ docs/ # Comprehensive documentation
βββ .github/workflows/ # CI/CD pipelines
- Asynchronous communication via RabbitMQ
- Event sourcing ready
- Loose coupling between services
- Orchestration-based distributed transactions
- Compensation logic for failures
- Idempotency handling
- Atomic message publishing
- Guaranteed event delivery
- Database transaction consistency
- Command/Query separation
- Optimized read/write models
- Event-driven updates
# Database
ConnectionStrings__DefaultConnection=Host=localhost;Database=loyaltyforge_auth;...
# RabbitMQ
RabbitMQ__HostName=localhost
RabbitMQ__Port=5672
RabbitMQ__UserName=guest
RabbitMQ__Password=guest
# Logging
Serilog__MinimumLevel__Default=InformationEach service has its own appsettings.json for service-specific configuration.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write unit tests for new features
- Follow existing code patterns
- Update documentation
- Ensure CI/CD passes
- Multi-tenant architecture
- Event-Driven Architecture (EDA)
- Saga pattern implementation
- Outbox pattern for reliability
- Unit testing infrastructure (28+ tests)
- CI/CD pipeline with automated testing
- E-commerce integration (Shopify)
- Points earning and redemption
- Reward catalog management
- Integration tests
- E2E tests
- Analytics service
- Admin dashboard
- Mobile API optimization
- Event sourcing implementation
- Read model optimization
- Advanced reporting
- Multi-platform integrations
- Performance optimization
This project is licensed under the MIT License - see the LICENSE file for details.
Ashutosh Ranjan
- GitHub: @iaashu98
- Event-Driven Architecture patterns from industry best practices
- RabbitMQ for reliable message brokering
- .NET community for excellent tooling and support
Built with β€οΈ using .NET 9.0 and Event-Driven Architecture