This Book Management API is a high-performance, scalable REST API built with ASP.NET Core and C#, implementing Clean Architecture, Domain-Driven Design (DDD), and CQRS. It supports CRUD operations, soft deletion, pagination, JWT authentication, popularity score calculation, and logging with validation pipelines.
Key Features:
✅ Secure – JWT-based authentication with role-based authorization.
✅ Efficient – Implements pagination, caching, and retry mechanisms.
✅ Scalable – Built with CQRS, Event-Driven Architecture, and Outbox Pattern.
✅ Reliable – Uses Quartz for background jobs and Polly for resiliency.
This project follows Clean Architecture with Domain-Driven Design (DDD) principles:
📌 Domain Layer – Entities, Value Objects, Aggregates, and Domain Events.
📌 Application Layer – Commands, Queries, Services, and Event Handlers.
📌 Persistence Layer – EF Core, SQL Server, Interceptors, Repository implementations.
📌 Infrastructure Layer – Quartz Background Jobs, JWT, Idempotence.
📌 Presentation Layer – ASP.NET Core Web API with Swagger Documentation.
🔹 CQRS – Segregates commands (writes) and queries (reads).
🔹 Outbox Pattern – Ensures reliable event-driven architecture.
🔹 Rich Domain Model – Encapsulates behavior within entities.
🔹 Retry Mechanism (Polly) – Ensures reliability for external calls.
🔹 Idempotence – Prevents duplicate API requests.
🔹 Logging & Validation Pipelines – Ensures clean, validated, and logged API requests.
🔹 Global Exception Handling Middleware – Centralized error handling.
- Framework – ASP.NET Core 8 / 9 Web API
- Database – SQL Server, EF Core
- Caching & Resiliency – Polly for retry mechanism
- Background Jobs – Quartz.NET
- Security – JWT-based authentication and permission-based authorization
- API Documentation – Swagger / OpenAPI
- Logging & Monitoring – Serilog
- Validation – FluentValidation
- Dependency Injection – Built-in .NET DI container
✅ Add Books – Supports single & bulk inserts.
✅ Update Books – Modify book details with proper validation.
✅ Soft Delete Books – Books can be restored if needed.
✅ Retrieve Books – Fetch books by popularity (most-viewed first) with pagination.
✅ Get Book Details – Includes real-time popularity score calculation.
📌 Formula:
Popularity Score = (BookViews * 0.5) + (YearsSincePublished * 2)
📌 How it works:
- BookViews – Counts the number of times a book’s details are retrieved.
- YearsSincePublished – Older books receive a smaller score boost.
- Live Computation – Popularity is calculated on the fly (not stored in DB).
✅ JWT-based authentication – Secures all API endpoints.
✅ Role-based authorization – Restricts access based on user permissions.
✅ Retrieve books in order of popularity with pagination support.
✅ .NET 9 SDK
✅ SQL Server
✅ Docker (optional for running SQL Server container)
git clone https://github.com/MrEshboboyev/book-management-api.git
cd book-management-api
Set up SQL Server and update connection strings in appsettings.json
:
"ConnectionStrings": {
"SqlServerDatabase": "Server=localhost;Database=BookManagement_DB;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"
}
dotnet ef database update
dotnet run --project src/BookManagement.App
Auth:
Method | Endpoint | Description |
---|---|---|
POST | /api/auth/login |
Logs in a user by validating their credentials and generating a token. |
POST | /api/auth/register |
Registers a new user by creating their account with the provided details. |
Users:
Method | Endpoint | Description |
---|---|---|
GET | /api/users |
Retrieves the details of a current user. |
Books:
Method | Endpoint | Description |
---|---|---|
POST | /api/books |
Adds a new book. |
POST | /api/books/bulk |
Adds multiple books in bulk. |
PUT | /api/books/{id:guid} |
Updates an existing book. |
DELETE | /api/books/{id:guid} |
Soft delete a book |
DELETE | /api/books/bulk |
Soft deletes multiple books in bulk |
GET | /api/books |
Retrieve books by popularity (paginated) |
GET | /api/books/{id} |
Retrieves the details of a book by its unique identifier & popularity score |
Run unit tests for validation, application layer, and controllers:
dotnet test
📌 Use Postman or any REST client to:
✅ Register/Login → Obtain a JWT Token
✅ Add Books → /api/books
✅ Retrieve Books → /api/books?PageNumber=1&PageSize=10
✅ Get Book Details → /api/books/{id}
(track popularity score)
✅ Enterprise-Grade Architecture – Clean, scalable, and maintainable.
✅ Performance-Oriented – Optimized with CQRS, caching, and indexing.
✅ Security-First Approach – Uses JWT authentication and role-based access.
✅ Ready for Production – Implements industry best practices.
This project is licensed under the MIT License. See LICENSE for details.
For feedback, contributions, or questions:
📧 Email: mreshboboyev@gmail.com
💻 GitHub: MrEshboboyev
🚀 Build high-performance, scalable APIs with .NET! Clone the repo & start coding today!