This repository hosts BookStoreMicroserviceApp, an ecommerce platform where sellers can list both paper and electronic books, and customers can browse and purchase them. The project is designed with a microservice architecture to ensure scalability, maintainability, and resiliency.
- Microservice Architecture: The application consists of independent services, ensuring scalability and resilience.
- Clean Architecture: Each service follows Clean Architecture principles.
- Identity Server: Built using Blazor component architecture.
- Domain-Driven Design (DDD): Rich domain entities with a focus on domain logic.
- Event-Driven: Services communicate via events.
- Result + Error Pattern: For handling operations with clear success or failure results.
- REPR Pattern: Request-Endpoint-Response programming pattern.
- Outbox & Inbox Patterns: Ensures reliable message delivery across services.
- Repository and Unit of Work Patterns: For data management consistency.
- Railway Programming: Streamlines error handling in complex business logic.
- Decorator Pattern: Adds functionality dynamically to objects.
- Factory Method: Provides flexible object creation mechanisms.
- Adapter Pattern: Ensures compatibility between services.
- IOptions Pattern: For handling configuration options.
- Global Exception Pattern: Centralized exception handling for better error management.
- ASP.NET Core 8
- EF Core 8
- AutoMapper
- FluentValidation
- MediatR + CQRS
- Ardalis
- Permission-Based Authorization
- OAuth 2.0 + Duende IdentityServer
- Redis
- MassTransit + RabbitMQ
- gRPC
- Serilog
- Quartz
- OpenTelemetry
- Azurite (for local Azure Blob Storage emulation)
- Stripe.NET (for payment processing)
- YARP (for API Gateway)
- Polly (for resilience policies)
- ASP.NET Core HealthChecks
- Swagger (for API documentation)
- Microsoft Identity
- GraphQL + HotChocolate
- Docker & Docker Compose
- Resilience: Leveraging retry policies, database duplication, and idempotent event handling.
- Scalability: Microservices architecture allows horizontal scaling.
- Maintainability: Clean code principles, layered architecture, and clear separation of concerns.
- Install Visual Studio 2022 or newer: Installation Guide
- Clone the repository:
git clone https://github.com/GeorgeRitchie/BookStoreMicroserviceApp
- Configure project settings:
- Open the solution in Visual Studio.
- Modify the
appsettings.json
of each project according to your environment:- Service.Identity: Set mailing credentials.
- Service.Payments.WebApi: Set Stripe API key.
- Service.Catalog.WebApi: Set Azure Blob Storage connection string and container name.
- All Projects: Update SQL connection strings.
- Build and run the solution in Visual Studio.
- Install Docker & Docker Compose:
- Start Docker.
- Clone the repository:
git clone https://github.com/GeorgeRitchie/BookStoreMicroserviceApp
- Configure Docker Compose:
- Navigate to the folder containing
docker-compose.yml
. - Update environment variables in the
docker-compose.yml
file as needed:- Mailing credentials.
- Stripe API key.
- Azure Blob Storage connection string & container name.
- SQL database connection strings.
- Navigate to the folder containing
- Run Docker Compose:
docker compose up -d
-
SSL Setup: To run in a secure environment, set up SSL certificates for HTTPS either locally or within the containers. Alternatively, run in HTTP (note that gRPC will not work over HTTP).
-
Azure Blob Storage: For local development, you can use Azurite. You can also switch to local file storage by modifying the
InfrastructureServiceInstaller.cs
file here.Example modification:
public void Install(IServiceCollection services, IConfiguration configuration) => services .AddSingleton<IFileManager, LocalFileManager>() .TryAddTransient<IEventBus, EventBus>();
Note: Using local file storage is not recommended for production.
This project is licensed under the GPL-3.0 license - see the LICENSE file for details.
Feel free to submit pull requests or open issues to contribute to the project.