Modern microservices-based e-commerce platform for online courses. This repository demonstrates end-to-end architecture with identity, API gateway, domain-driven ordering, messaging, and a server-rendered web frontend.
- Identity & Authorization: Duende IdentityServer with OAuth2/OIDC, Resource Owner Password and Client Credentials flows, refresh tokens, role claims
- API Gateway: Ocelot for routing/aggregation, JWT validation, and RFC 8693 Token Exchange
- Microservices: Catalog (MongoDB), Basket (Redis), Discount (PostgreSQL), Order (SQL Server, DDD), PhotoStock, FakePayment
- Messaging: MassTransit + RabbitMQ for event-driven communication (e.g., course-name-changed, create-order)
- Web Application: ASP.NET Core MVC + Razor Views, cookie auth, OpenIdConnect token management, FluentValidation
- Operability: Docker Compose to orchestrate services; Swagger for service contracts
- Frontend (
Frontends/CourseMarket.Web): MVC, HttpClient + delegating handlers, calls services via the API gateway - API Gateway (
Gateways/CourseMarket.Gateways.Web): Ocelot,TokenExchangeDelegateHandlerfor token exchange and JWT validation - Identity (
IdentityServer/CourseMarket.IdentityServer): ApiResource/Scope/Client configuration and user management - Services (
Services/*): Independent microservices with their own storage and contracts- Catalog: MongoDB, JWT-protected REST API
- Basket: Redis, MassTransit consumer, JWT authorization
- Discount: PostgreSQL, JWT authorization
- Order: DDD (Domain, Application, Infrastructure), EF Core + SQL Server, MediatR, MassTransit consumers
- PhotoStock: File/image operations
- FakePayment: Simulated payment workflow
- Shared (
Shared/CourseMarket.Shared): Shared DTOs, messages, and utilities
- Identity: IdentityServer with
ApiResource/ApiScope/Clientconfiguration; ROPC for user flow, Client Credentials for service-to-service access - Gateway: Ocelot as a single entry point;
TokenExchangeDelegateHandlerto securely calldiscountandpaymentservices via token exchange - DDD (Order Service):
- Domain:
Order,OrderItem,Address,IAggregateRoot,Entityabstractions - Application: AutoMapper profiles, MediatR commands/handlers, message consumers
- Infrastructure: EF Core, migrations, SQL Server connection, and
OrderDbContext
- Domain:
- Messaging: MassTransit with RabbitMQ; queues/endpoints for
course-name-changedandcreate-order - Data Access: Catalog (MongoDB), Basket (Redis), Discount (PostgreSQL), Order (SQL Server)
- Validation: FluentValidation for view model validation
- HttpClient Factory: Typed service proxies with delegating handlers to inject access tokens
- .NET 5 / ASP.NET Core, MVC/Razor
- Duende IdentityServer, Duende IdentityModel
- Ocelot API Gateway
- MassTransit, RabbitMQ
- Entity Framework Core (SQL Server), MongoDB Driver, Npgsql (PostgreSQL), StackExchange.Redis
- MediatR, AutoMapper, FluentValidation, Swashbuckle (Swagger)
- Docker / Docker Compose
- Catalog: MongoDB (
catalogdb) - Basket: Redis (
basketdb) - Discount: PostgreSQL (
discountdb) - Identity & Order: SQL Server (
identitydb,orderdb) - Messaging: RabbitMQ (
rabbitmq:management)
IdentityServer Config.cs summary:
- ApiResources:
resource_catalog,resource_basket,resource_discount,resource_order,resource_payment,resource_photo_stock,resource_gatewayweb - Scopes:
*_fullpermission,gatewayweb_fullpermission,IdentityServerConstants.LocalApi - Clients:
WebMvcClient(Client Credentials)WebMvcClientForUser(ROPC, offline access, refresh tokens)TokenExchangeClient(Token Exchange grant)
Frontend uses Cookie Authentication; service calls use ClientCredentialTokenHandler and ResourceOwnerPasswordTokenHandler to attach tokens.
- Basket Service:
course-name-changed-event-basket-servicequeue,CourseNameChangedEventConsumer - Order Service:
create-order-serviceandcourse-name-changed-event-order-servicequeues, corresponding consumers
Frontends/CourseMarket.Web: MVC app,Startup.cs, service proxiesGateways/CourseMarket.Gateways.Web: Ocelot configuration, token exchange handlerIdentityServer/CourseMarket.IdentityServer: IdentityServer configs and UIServices/*: Independent microservices and layered architecture (notablyOrder)Shared/CourseMarket.Shared: Shared DTOs/messages and helpers
Prerequisite: Docker Desktop
# Run from repository root
docker compose up --build -dComponents and ports are built from the docker-compose file. On first run, seed/migrations are applied automatically by the services (e.g., Order API calls Database.Migrate).
For local development you can also run services individually (VS/VS Code F5). Update connection strings and IdentityServerUrl values in the corresponding appsettings.Development.json files.
- Order API:
MediatRcommand handlers,EF Coremigration pipeline,DbContextconfiguration - Catalog API: JWT audience validation (
resource_catalog), AutoMapper, MongoDatabaseSettings - Basket API:
RedisServicesingleton, MassTransit hosted service, audienceresource_basket - Frontend: FluentValidation, cookie auth and token management, HttpClient via API Gateway
- Demonstrates microservices end-to-end: identity, gateway, messaging, polyglot persistence, DDD, and layered architecture
- Mirrors real-world scenarios: course rename events, basket updates, order creation, and payment workflow
- Observability: Health Checks, OpenTelemetry, centralized logs/metrics
- Resilience: Polly retry, Circuit Breaker
- Deployment: Kubernetes manifests/Helm charts
- UI: Modern SPA (React/Angular/Vue) alongside MVC
This repository highlights my professional skills across microservices, identity, and messaging in .NET. Feel free to open issues for questions or feedback.