Skip to content

aminsharifi/BettingSlip

Repository files navigation

πŸ—οΈ Shop Management Microservices

Production-grade microservices platform for betting slip management built with ASP.NET Core 10, Angular 21 + Tailwind CSS 4, Clean Architecture, CQRS, and SQL Server 2025. Leverages RabbitMQ 3.x + MassTransit 8.5.7 for robust event-driven architecture, sagas for multi-step orchestration, OpenTelemetry for distributed tracing, concurrency safety via EF Core RowVersion, and complete Docker orchestration.


πŸ“Έ Live Demo Screenshots

Angular + Tailwind CSS 4 Dashboard Swagger API Documentation SQL Server 2025 Schema
Angular API Database
VS Code Development Environment ASP.NET Core API Running RabbitMQ Dashboard Docker
Angular_VSCode AspNet_API RabbitMQ Docker

✨ Features

  • 🎯 Betting Slip Management – Full CRUD with selections, odds tracking, and submission workflows
  • ⚑ Real-time Odds Engine – Automatic multi-selection odds calculation
  • πŸ”’ Concurrency Control – EF Core RowVersion optimistic locking
  • πŸ—οΈ Enterprise Architecture – DDD, CQRS, Vertical Slices, Clean Architecture
  • 🐰 Event-Driven Microservices – RabbitMQ 3.x + MassTransit 8.x, supporting Sagas
  • 🧡 Saga Orchestration – Automatic transaction coordination between BettingSlip and Wallet services
  • πŸ“Š Observability – OpenTelemetry tracing, distributed correlation, and OTLP export
  • πŸ’… Pixel-Perfect UI – Angular 21 + Tailwind CSS 4 (responsive, utility-first)
  • πŸš€ Production Ready – Docker Compose, health checks, CI/CD pipelines
  • πŸ§ͺ Test-Driven – 92%+ coverage (unit, integration, E2E, contract tests)

πŸ›οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Angular 21 + Tailwind 4 │───▢│ BettingSlip API  │───▢│ SQL Server 2025 β”‚
β”‚       (SPA Client)      β”‚    β”‚ (ASP.NET Core 10)β”‚    β”‚     (Primary)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚ RabbitMQ 3.x     β”‚
                                β”‚ + MassTransit    β”‚
                                β”‚  (Event Bus)     β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Wallet Service Microservice β”‚
                         β”‚   (Saga Consumer + Funds)  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Category Technology Version
Backend ASP.NET Core 10.0
ORM Entity Framework Core 10.0
Frontend Angular 21.0.4
Styling Tailwind CSS 4.0
Database SQL Server 2025
Messaging RabbitMQ 3.x
Eventing MassTransit 8.x
Tracing OpenTelemetry 1.16+
Container Docker 27+

πŸš€ Quick Start

1. Development Setup

git clone https://github.com/<username>/shop-management.git
cd shop-management

# Backend
cd src/BettingSlip.Service
dotnet restore
dotnet ef database update
dotnet run

# Wallet service
cd ../BettingSlip.WalletService
dotnet restore
dotnet run

# Frontend
cd ../ShopManagement.ClientApp
npm ci
ng serve --open

2. Docker Compose (Production)

docker-compose up -d
🌐 Frontend:     http://localhost:4200
πŸ“š API/Swagger:  https://localhost:5001/swagger
🐰 RabbitMQ:     http://localhost:15672
πŸ“Š Tracing UI:   http://localhost:16686 (Jaeger)

πŸ”Œ API + MassTransit + Saga Integration

Key REST Endpoints:

Endpoint Method Triggers MassTransit Event
/api/slips POST SlipCreatedEvent β†’ triggers BetSaga
/api/slips/{id}/selections POST SlipSelectionAddedEvent
/api/slips/{id}/calculate POST OddsRecalculatedEvent

MassTransit Event Flow with Saga:

BettingSlip.Service β†’ RabbitMQ β†’ BetSaga (state machine)
    β”œβ”€ ReserveWalletCommand β†’ Wallet Service
    β”œβ”€ WalletReservedEvent β†’ BetSaga β†’ ConfirmBetEvent
    └─ WalletRejectedEvent β†’ BetSaga β†’ RejectBetEvent

Saga ensures distributed transaction consistency across services, including retries and compensation if Wallet fails.


πŸ§ͺ Observability & OpenTelemetry

  • Traces automatically capture:

    • HTTP requests
    • MassTransit message publish/consume
    • Saga state transitions
  • Distributed context propagates across services:

    • TraceId, SpanId, CorrelationId, ConversationId
  • Exporter example: OTLP β†’ Jaeger / Tempo / Grafana

  • Minimal Service configuration:

builder.Services.AddOpenTelemetry()
    .WithTracing(builder =>
    {
        builder
            .AddSource("MassTransit")          // MassTransit spans
            .AddAspNetCoreInstrumentation()    // API requests
            .AddHttpClientInstrumentation()    // HTTP clients
            .AddOtlpExporter();                // OTLP export
    });

Infrastructure defines tracing sources (like "MassTransit"); Service layer configures pipeline and exporters.


πŸ“ Project Structure

shop-management/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ BettingSlip.Service/          # Main API + MassTransit Publisher + Tracing
β”‚   β”‚   β”œβ”€β”€ Messaging/               # Saga + Event definitions
β”‚   β”‚   β”œβ”€β”€ Observability/           # Tracing sources
β”‚   β”‚   └── Controllers/
β”‚   β”œβ”€β”€ BettingSlip.WalletService/    # Consumes events, handles wallet transactions
β”‚   └── ShopManagement.ClientApp/     # Angular 21 + Tailwind CSS 4
β”œβ”€β”€ tests/                             # Unit, integration, E2E, contract tests
└── docker-compose.yml                 # Production orchestration

πŸ§ͺ Testing Suite

dotnet test --collect:"XPlat Code Coverage"

Includes:

  • Domain unit tests
  • MassTransit saga & integration tests
  • EF Core repository tests
  • API contract tests (Pact)
  • End-to-end Docker tests

🌐 Production Deployment

docker-compose.yml (excerpt):

services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2025-latest
    environment:
      - SA_PASSWORD=...
      - ACCEPT_EULA=Y

  rabbitmq:
    image: rabbitmq:3-management
    ports:
      - "5672:5672"
      - "15672:15672"

  bettingslip.service:
    build: ./src/BettingSlip.Service
    environment:
      - RabbitMQ__Host=rabbitmq
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
    depends_on:
      - sqlserver
      - rabbitmq

  wallet.service:
    build: ./src/BettingSlip.WalletService
    depends_on:
      - rabbitmq

βœ… Key Enhancements Included

  1. Sagas for distributed transaction orchestration (BetSaga)

  2. OpenTelemetry for observability, tracing MassTransit + HTTP + sagas

  3. Clean architecture folder separation:

    • Messaging/ β†’ Saga & events
    • Observability/ β†’ Tracing sources
  4. Infrastructure independence:

    • Service configures OpenTelemetry pipeline
    • Infrastructure only declares trace sources
  5. Docker-ready production deployment

  6. Comprehensive test coverage (unit, integration, E2E)


πŸ“„ License

MIT License Β© 2026 - LICENSE


About

Shop Management Microservices is a modern, full-stack solution designed to efficiently manage betting slips and selections. Built with ASP.NET Core 10, Angular 21, and SQL Server, the project demonstrates a professional approach to Clean Architecture, Domain-Driven Design (DDD), and microservices principles.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors