Rating & Notification Microservices
Two-service microservices architecture with Clean Architecture
This project implements a production-grade .NET 8 microservices architecture with two independent services communicating via HTTP in a service marketplace context. The RatingService (port 5000) manages customer ratings for service providers using ASP.NET Core Minimal APIs with PostgreSQL persistence via EF Core code-first migrations, and publishes rating events to the NotificationService (port 5001). The NotificationService stores notifications in thread-safe in-memory data structures and guarantees exactly-once delivery per polling request through a queue-draining mechanism. Both services expose /health endpoints for monitoring and ship with OpenAPI/Swagger documentation. Each service strictly follows Clean Architecture with four layers: Domain (entities, value objects, domain services), Application (use cases, interfaces, DTOs), Infrastructure (data access, external service clients), and API (Minimal API endpoints with input validation). The system uses Polly for HTTP retry policies with exponential backoff, ensuring the rating creation flow succeeds even if the notification service is temporarily unavailable,a deliberate fire-and-forget pattern where rating persistence is never blocked by notification delivery. The rating score is validated between 1-5 with a proper database index on service_provider_id for efficient average calculations. The project includes 46 tests,unit tests covering entity validation, business logic, use case functionality, and repository behavior, plus integration tests for full API workflows with in-memory database. Docker Compose orchestrates the complete system: PostgreSQL with initialization, NotificationService with health checks, and RatingService with automatic database migrations and internal networking. The README provides detailed trade-off documentation explaining design decisions (HTTP vs message broker, in-memory vs persistent storage, exactly-once vs at-least-once delivery, synchronous vs asynchronous processing) with a concrete evolution path toward RabbitMQ/Kafka, Redis persistence, CQRS, event sourcing, and Prometheus/Grafana observability.
▹ Key Features
▹ Architecture
RatingService (.NET 8 API → EF Core → PostgreSQL) → HTTP → NotificationService (.NET 8 API → In-Memory Store) · Docker Compose · Polly Retry