Modern, scalable, and production-ready E-Commerce API built with .NET 9, implementing Clean Architecture, CQRS, Event Sourcing, and Microservices patterns.
πΉπ· TΓΌrkΓ§e DokΓΌmantasyon | π English Documentation
- Clean Architecture with clear separation of concerns
- CQRS (Command Query Responsibility Segregation) for optimal read/write operations
- Event-Driven Architecture with real-time synchronization
- Domain-Driven Design (DDD) principles
- Repository Pattern with Unit of Work
- Mediator Pattern using MediatR
- Specification Pattern for complex queries
- .NET 9 - Latest framework with performance improvements
- Entity Framework Core 9 - Advanced ORM with change tracking
- PostgreSQL - Primary database for ACID transactions
- Elasticsearch - High-performance search and analytics
- Redis - Distributed caching and session management
- RabbitMQ - Message broker for event-driven communication
- AutoMapper - Object-to-object mapping
- FluentValidation - Input validation with fluent interface
- Serilog - Structured logging with multiple sinks
- Real-time Stock Management with event synchronization
- Advanced Product Search with faceted filtering
- Distributed Caching with Redis
- Health Checks for all services
- API Versioning with backward compatibility
- Comprehensive Logging with correlation IDs
- Exception Handling with global middleware
- Performance Monitoring with custom metrics
- Swagger/OpenAPI documentation
graph TB
subgraph "Presentation Layer"
API[Web API Controllers]
MW[Middleware Pipeline]
end
subgraph "Application Layer"
MED[MediatR]
CMD[Commands]
QRY[Queries]
VAL[Validators]
BEH[Behaviors]
end
subgraph "Domain Layer"
ENT[Entities]
VO[Value Objects]
AGG[Aggregates]
DOM[Domain Services]
end
subgraph "Infrastructure Layer"
REPO[Repositories]
CACHE[Cache Service]
MSG[Message Bus]
EXT[External Services]
end
subgraph "Data Stores"
PG[(PostgreSQL)]
ES[(Elasticsearch)]
RD[(Redis)]
RMQ[RabbitMQ]
end
API --> MW
MW --> MED
MED --> CMD
MED --> QRY
CMD --> VAL
QRY --> VAL
VAL --> BEH
BEH --> DOM
DOM --> ENT
DOM --> REPO
REPO --> PG
CACHE --> RD
MSG --> RMQ
EXT --> ES
erDiagram
CUSTOMERS {
uuid id PK
string email UK
string first_name
string last_name
string phone
timestamp created_at
timestamp updated_at
boolean is_active
}
CUSTOMER_ADDRESSES {
uuid id PK
uuid customer_id FK
string address_line1
string address_line2
string city
string state
string postal_code
string country
boolean is_default
timestamp created_at
}
CATEGORIES {
uuid id PK
string name UK
string description
uuid parent_category_id FK
int level
boolean is_active
timestamp created_at
timestamp updated_at
}
PRODUCTS {
uuid id PK
string name
string description
string sku UK
decimal price
string currency
int stock_quantity
int minimum_stock_level
uuid category_id FK
boolean is_active
boolean is_featured
decimal average_rating
int review_count
timestamp created_at
timestamp updated_at
}
PRODUCT_REVIEWS {
uuid id PK
uuid product_id FK
uuid customer_id FK
int rating
string comment
timestamp created_at
}
ORDERS {
uuid id PK
string order_number UK
uuid customer_id FK
string status
decimal total_amount
string currency
string shipping_address
string billing_address
timestamp created_at
timestamp updated_at
}
ORDER_ITEMS {
uuid id PK
uuid order_id FK
uuid product_id FK
string product_name
int quantity
decimal unit_price
string currency
decimal total_price
}
STOCK_MOVEMENTS {
uuid id PK
uuid product_id FK
int quantity_change
string movement_type
string reason
int stock_after_movement
timestamp created_at
}
CUSTOMERS ||--o{ CUSTOMER_ADDRESSES : has
CUSTOMERS ||--o{ PRODUCT_REVIEWS : writes
CUSTOMERS ||--o{ ORDERS : places
CATEGORIES ||--o{ CATEGORIES : contains
CATEGORIES ||--o{ PRODUCTS : categorizes
PRODUCTS ||--o{ PRODUCT_REVIEWS : receives
PRODUCTS ||--o{ ORDER_ITEMS : included_in
PRODUCTS ||--o{ STOCK_MOVEMENTS : tracks
ORDERS ||--o{ ORDER_ITEMS : contains
sequenceDiagram
participant Client
participant API
participant MediatR
participant Handler
participant Repository
participant EventBus
participant Elasticsearch
participant Cache
Client->>API: POST /api/v1/orders
API->>MediatR: PlaceOrderCommand
MediatR->>Handler: Handle Command
Handler->>Repository: Get Product
Repository-->>Handler: Product Data
Handler->>Repository: Update Stock
Repository->>EventBus: ProductStockUpdatedEvent
EventBus->>Elasticsearch: Sync Stock Data
EventBus->>Cache: Invalidate Cache
Handler->>Repository: Create Order
Repository-->>Handler: Order Created
Handler-->>MediatR: Success Response
MediatR-->>API: Order DTO
API-->>Client: 201 Created
Note over EventBus: Asynchronous Processing
EventBus->>Elasticsearch: Update Search Index
EventBus->>Cache: Update Product Cache
- .NET 9 SDK
- PostgreSQL 16+
- Elasticsearch 8.0+
- Redis 7.0+
- RabbitMQ 3.12+
- Docker (optional)
git clone https://github.com/Yemresalcan/ecommerce-api.git
cd ecommerce-apidocker-compose up -d postgres elasticsearch redis rabbitmqcp src/Presentation/ECommerce.WebAPI/appsettings.example.json src/Presentation/ECommerce.WebAPI/appsettings.json
# Edit connection strings and configurationsdotnet ef database update --project src/Infrastructure/ECommerce.Infrastructure --startup-project src/Presentation/ECommerce.WebAPIdotnet run --project src/Presentation/ECommerce.WebAPI- Swagger UI: http://localhost:8080/swagger
- Health Checks: http://localhost:8080/health
- API Base: http://localhost:8080/api/v1
src/
βββ Core/
β βββ ECommerce.Domain/ # Domain entities, value objects, aggregates
β βββ ECommerce.Application/ # Use cases, DTOs, interfaces
βββ Infrastructure/
β βββ ECommerce.Infrastructure/ # Data access, external services
β βββ ECommerce.ReadModel/ # Elasticsearch, read-side queries
βββ Presentation/
βββ ECommerce.WebAPI/ # Controllers, middleware, configuration
tests/
βββ ECommerce.Domain.Tests/ # Domain unit tests
βββ ECommerce.Application.Tests/ # Application unit tests
βββ ECommerce.Infrastructure.Tests/ # Infrastructure unit tests
βββ ECommerce.WebAPI.Tests/ # Integration tests
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=ecommerce;Username=postgres;Password=password"
}
}{
"Elasticsearch": {
"Uri": "http://localhost:9200",
"IndexPrefix": "ecommerce",
"Username": "",
"Password": ""
}
}{
"ConnectionStrings": {
"Redis": "localhost:6379"
}
}
Professional monitoring dashboard showing CPU, Memory, Network, and Disk metrics in real-time
Prometheus successfully collecting metrics from all monitoring targets
Detailed container resource usage and performance metrics
Professional container management interface for Docker environments
RabbitMQ management interface showing queue status and message flow
Comprehensive Swagger/OpenAPI documentation with interactive testing
| Endpoint | Avg Response Time | Throughput |
|---|---|---|
| GET /products | 45ms | 2,000 req/s |
| POST /orders | 120ms | 500 req/s |
| GET /orders/{id} | 25ms | 3,000 req/s |
| GET /search | 80ms | 1,200 req/s |
dotnet test tests/ECommerce.Domain.Tests/
dotnet test tests/ECommerce.Application.Tests/dotnet test tests/ECommerce.WebAPI.Tests/dotnet test --collect:"XPlat Code Coverage"- Database connectivity
- Elasticsearch cluster health
- Redis availability
- RabbitMQ connection
- External service dependencies
- Structured logging with Serilog
- Correlation IDs for request tracking
- Performance metrics
- Error tracking and alerting
- Request/response times
- Database query performance
- Cache hit/miss ratios
- Event processing metrics
- Input validation with FluentValidation
- SQL injection prevention with parameterized queries
- XSS protection with output encoding
- CORS configuration
- Rate limiting
- API versioning
- Health check security
docker build -t ecommerce-api .
docker run -p 8080:8080 ecommerce-apikubectl apply -f k8s/- GitHub Actions workflow
- Automated testing
- Docker image building
- Deployment to staging/production
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @Yemresalcan
- LinkedIn: Yunusemresalcan
- Email: yunusemresalcan@gmail.com
- Clean Architecture by Robert C. Martin
- Domain-Driven Design by Eric Evans
- Microsoft .NET Documentation
- Elasticsearch Documentation
- Redis Documentation
- API Documentation
- Architecture Decision Records
- Deployment Guide
- Contributing Guidelines
- Code of Conduct
| Monitoring Dashboard | Container Management | API Documentation |
|---|---|---|
![]() |
![]() |
![]() |
| Real-time Metrics | Container Control | Interactive API |
| System Health | Message Queue | Container Analytics |
|---|---|---|
![]() |
![]() |
![]() |
| Target Monitoring | Queue Management | Resource Analytics |
β If you found this project helpful, please give it a star! β
π Ready for Production β’ π Enterprise Monitoring β’ π Scalable E-Commerce