An end-to-end backend engineering project built around an e-commerce domain.
The goal is to evolve this repository over time into a complete backend engineering reference that covers API development, architecture, data, security, testing, and DevOps practices.
- Build and maintain a complete backend system using production-style patterns.
- Implement backend concepts incrementally with clear, testable architecture.
- Extend the project beyond API features into deployment, automation, and operations.
- JWT authentication with access + refresh tokens
- Role-based authorization (
Admin,Customer) - Product and category management (admin-only writes, soft delete support)
- Product listing with pagination, filtering, and sorting
- Cart management for authenticated users
- Order creation from cart with stock validation
- Mock payment endpoint to simulate success/failure
- Global exception handling with ProblemDetails (
application/problem+json) - Swagger/OpenAPI configured with Bearer auth support
- Automatic database migration + seed data on startup
This project is intended to cover backend engineering areas such as:
- API design and REST conventions
- Service-layer architecture and separation of concerns
- Data modeling and persistence with EF Core
- Validation, error handling, and logging
- Security with authentication/authorization
- Testing strategy (unit + integration)
- Performance and scalability improvements
- DevOps foundations (CI/CD, containerization, release workflows, observability)
- .NET 10 (
net10.0) - ASP.NET Core Web API
- Entity Framework Core (SQL Server)
- JWT Bearer Authentication
- BCrypt for password hashing
- Swashbuckle (Swagger UI)
E_Commerce_BackendAPI/
Controllers/ # HTTP endpoints only (thin controllers)
Services/ # Business logic + data access orchestration
DAL/ # DbContext + seed logic
Model/ # Entities
Dtos/ # Request/response models
Middleware/ # Global exception handling
Authentication/ # Token generation service
Utilities/ # Enums and helpers
The code follows a service-layer pattern:
- Controllers handle routing, model binding, and HTTP responses.
- Services contain business logic and EF Core interaction.
- Global middleware maps exceptions to consistent error responses.
Example: order creation is handled atomically in service logic to avoid partial writes.
- .NET SDK 10.x
- SQL Server LocalDB (default connection string), or any SQL Server instance
Main settings file: E_Commerce_BackendAPI/appsettings.json
Important keys:
ConnectionStrings:DefaultConnectionJwtSettings:SecretKeyJwtSettings:IssuerJwtSettings:AudienceJwtSettings:AccessTokenExpirationMinutes
For real environments, move secrets to environment variables or user-secrets.
From the repository root:
dotnet restore
dotnet build
dotnet run --project E_Commerce_BackendAPIOn startup, the app:
- Applies EF Core migrations
- Seeds sample categories/products
- Seeds initial data required for local development
Swagger UI is hosted at:
- http://localhost:5000 or https://localhost:5001 (depending on launch profile)
- Register:
POST /api/Auth/Register - Login:
POST /api/Auth/Login
ReturnsAccessToken+RefreshToken - Use access token in
Authorization: Bearer <token> - Refresh token:
POST /api/Auth/Refresh - Logout (revoke refresh token):
POST /api/Auth/Logout
POST /api/Auth/RegisterPOST /api/Auth/LoginPOST /api/Auth/RefreshPOST /api/Auth/Logout(authorized)
GET /api/CategoryGET /api/Category/{id}POST /api/Category(admin)PUT /api/Category/{id}(admin)DELETE /api/Category/{id}(admin, soft delete)
GET /api/Product(pagination/filter/sort)GET /api/Product/{id}GET /api/Product/category/{categoryId}POST /api/Product(admin)PUT /api/Product/{id}(admin)DELETE /api/Product/{id}(admin, soft delete)
GET /api/CartPOST /api/CartPUT /api/Cart/{itemId}DELETE /api/Cart/{itemId}
GET /api/Order(my orders)GET /api/Order/{id}(my order or admin)POST /api/Order(create order from cart)POST /api/Order/{id}/pay(mock payment)PUT /api/Order/{id}/status(admin)GET /api/Order/admin(admin)
Unhandled exceptions are transformed into RFC-style ProblemDetails responses by middleware:
- 400 Bad Request (
ArgumentException) - 401 Unauthorized (
UnauthorizedAccessException) - 403 Forbidden (
ForbiddenException) - 404 Not Found (
NotFoundException) - 409 Conflict (
InvalidOperationException) - 500 Internal Server Error (fallback)
Short-term:
- Add unit tests for service-layer business logic
- Add integration tests for critical API workflows
- Introduce API versioning and caching enhancements
Mid-term:
- Add structured logging and monitoring improvements
- Add rate limiting and additional security hardening
- Improve performance with query and caching optimizations
DevOps track:
- Add CI pipeline for build/test/quality checks
- Containerize the API and standardize local environments
- Add CD workflow for staged deployments
- Introduce observability dashboards and health monitoring
For educational and development purposes.