{"id":25981498,"url":"https://github.com/mreshboboyev/book-management-api","last_synced_at":"2025-08-01T08:37:55.296Z","repository":{"id":278570277,"uuid":"936032758","full_name":"MrEshboboyev/book-management-api","owner":"MrEshboboyev","description":"Scalable Book Management API built with ASP.NET Core , following Clean Architecture, Domain-Driven Design (DDD), CQRS. Features JWT authentication, pagination, soft deletion, logging, validation pipelines, popularity score calculation, idempotent request handling. Built with SQL Server, EF Core, Quartz background jobs, and Polly retry mechanisms","archived":false,"fork":false,"pushed_at":"2025-07-09T18:37:49.000Z","size":180,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-10T03:39:22.452Z","etag":null,"topics":["asp-net-core-web-api","clean-architecture","cqrs","ddd","exception-handling","idempotence","logging","outbox-pattern","permission-based-authorization","polly","retry-mechanism","rich-domain-model"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrEshboboyev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-20T12:23:06.000Z","updated_at":"2025-07-09T18:37:53.000Z","dependencies_parsed_at":"2025-07-10T00:25:35.831Z","dependency_job_id":"20244805-6b36-47d3-9a7a-b06fbccb9d72","html_url":"https://github.com/MrEshboboyev/book-management-api","commit_stats":null,"previous_names":["mreshboboyev/book-management-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrEshboboyev/book-management-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrEshboboyev%2Fbook-management-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrEshboboyev%2Fbook-management-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrEshboboyev%2Fbook-management-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrEshboboyev%2Fbook-management-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrEshboboyev","download_url":"https://codeload.github.com/MrEshboboyev/book-management-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrEshboboyev%2Fbook-management-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266076036,"owners_count":23872729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core-web-api","clean-architecture","cqrs","ddd","exception-handling","idempotence","logging","outbox-pattern","permission-based-authorization","polly","retry-mechanism","rich-domain-model"],"created_at":"2025-03-05T08:34:14.045Z","updated_at":"2025-07-20T06:04:28.478Z","avatar_url":"https://github.com/MrEshboboyev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📚 Book Management API – Scalable \u0026 Secure REST API 🚀  \n\n![.NET 9](https://img.shields.io/badge/.NET%209-blue?style=for-the-badge)\n![SQL Server](https://img.shields.io/badge/SQL%20Server-%F0%9F%93%9A-red?style=for-the-badge)\n![CQRS](https://img.shields.io/badge/CQRS-%E2%9C%85-green?style=for-the-badge)\n![Clean Architecture](https://img.shields.io/badge/Clean%20Architecture-%F0%9F%9A%80-purple?style=for-the-badge)\n![JWT Authentication](https://img.shields.io/badge/JWT%20Authentication-%F0%9F%94%92-yellow?style=for-the-badge)\n\n## 🎯 Overview  \n\nThis **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**.  \n\n**Key Features:**  \n✅ **Secure** – JWT-based authentication with role-based authorization.  \n✅ **Efficient** – Implements **pagination, caching, and retry mechanisms**.  \n✅ **Scalable** – Built with **CQRS, Event-Driven Architecture, and Outbox Pattern**.  \n✅ **Reliable** – Uses **Quartz for background jobs** and **Polly for resiliency**.  \n\n---\n\n## 🏛️ Architecture \u0026 Design Patterns  \n\nThis project follows **Clean Architecture** with **Domain-Driven Design (DDD)** principles:  \n\n📌 **Domain Layer** – Entities, Value Objects, Aggregates, and Domain Events.  \n📌 **Application Layer** – Commands, Queries, Services, and Event Handlers.  \n📌 **Persistence Layer** – EF Core, SQL Server, Interceptors, Repository implementations.  \n📌 **Infrastructure Layer** – Quartz Background Jobs, JWT, Idempotence.  \n📌 **Presentation Layer** – ASP.NET Core Web API with Swagger Documentation.  \n\n### **🔹 Key Patterns \u0026 Technologies Used**  \n🔹 **CQRS** – Segregates commands (writes) and queries (reads).  \n🔹 **Outbox Pattern** – Ensures reliable event-driven architecture.  \n🔹 **Rich Domain Model** – Encapsulates behavior within entities.  \n🔹 **Retry Mechanism (Polly)** – Ensures reliability for external calls.  \n🔹 **Idempotence** – Prevents duplicate API requests.  \n🔹 **Logging \u0026 Validation Pipelines** – Ensures clean, validated, and logged API requests.  \n🔹 **Global Exception Handling Middleware** – Centralized error handling.  \n\n---\n\n## 🛠️ Technologies \u0026 Tools  \n\n- **Framework** – ASP.NET Core 8 / 9 Web API  \n- **Database** – SQL Server, EF Core  \n- **Caching \u0026 Resiliency** – Polly for retry mechanism  \n- **Background Jobs** – Quartz.NET  \n- **Security** – JWT-based authentication and permission-based authorization  \n- **API Documentation** – Swagger / OpenAPI  \n- **Logging \u0026 Monitoring** – Serilog  \n- **Validation** – FluentValidation  \n- **Dependency Injection** – Built-in .NET DI container  \n\n---\n\n## 📖 Functional Features  \n\n### **1️⃣ CRUD Operations**  \n✅ **Add Books** – Supports **single \u0026 bulk inserts**.  \n✅ **Update Books** – Modify book details with proper validation.  \n✅ **Soft Delete Books** – Books can be restored if needed.  \n✅ **Retrieve Books** – Fetch books **by popularity** (most-viewed first) with pagination.  \n✅ **Get Book Details** – Includes **real-time popularity score calculation**.  \n\n### **2️⃣ Popularity Score Calculation**  \n📌 **Formula:**  \n```\nPopularity Score = (BookViews * 0.5) + (YearsSincePublished * 2)\n```\n📌 **How it works:**  \n- **BookViews** – Counts the number of times a book’s details are retrieved.  \n- **YearsSincePublished** – Older books receive a smaller score boost.  \n- **Live Computation** – Popularity is calculated **on the fly** (not stored in DB).  \n\n### **3️⃣ Security \u0026 Authentication**  \n✅ **JWT-based authentication** – Secures all API endpoints.  \n✅ **Role-based authorization** – Restricts access based on user permissions.  \n\n### **4️⃣ Pagination \u0026 Filtering**  \n✅ **Retrieve books in order of popularity** with pagination support.  \n\n---\n\n## 🚀 Getting Started  \n\n### **📌 Prerequisites**  \n✅ [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)  \n✅ [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)  \n✅ [Docker](https://www.docker.com/) (optional for running SQL Server container)  \n\n### **Step 1: Clone the Repository**  \n```bash\ngit clone https://github.com/MrEshboboyev/book-management-api.git\ncd book-management-api\n```\n\n### **Step 2: Configure Database**  \nSet up **SQL Server** and update connection strings in `appsettings.json`:  \n```json\n\"ConnectionStrings\": {\n  \"SqlServerDatabase\": \"Server=localhost;Database=BookManagement_DB;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;\"\n}\n```\n\n### **Step 3: Run Database Migrations**  \n```bash\ndotnet ef database update\n```\n\n### **Step 4: Run the Application**  \n```bash\ndotnet run --project src/BookManagement.App\n```\n\n---\n\n## 🔗 API Endpoints  \n\nAuth: \n| Method | Endpoint             | Description |\n|--------|---------------------|-------------|\n| **POST** | `/api/auth/login`       | Logs in a user by validating their credentials and generating a token. |\n| **POST**  | `/api/auth/register`  | Registers a new user by creating their account with the provided details. |\n\nUsers: \n| Method | Endpoint             | Description |\n|--------|---------------------|-------------|\n| **GET**  | `/api/users`  | Retrieves the details of a current user. |\n\nBooks: \n| Method | Endpoint             | Description |\n|--------|---------------------|-------------|\n| **POST** | `/api/books`       | Adds a new book. |\n| **POST** | `/api/books/bulk`       | Adds multiple books in bulk. |\n| **PUT**  | `/api/books/{id:guid}`  | Updates an existing book. |\n| **DELETE** | `/api/books/{id:guid}` | Soft delete a book |\n| **DELETE** | `/api/books/bulk` | Soft deletes multiple books in bulk |\n| **GET**  | `/api/books`       | Retrieve books by popularity (paginated) |\n| **GET**  | `/api/books/{id}`  | Retrieves the details of a book by its unique identifier \u0026 popularity score |\n\n---\n\n## 🧪 Testing  \n\n### **Unit Tests**  \nRun unit tests for validation, application layer, and controllers:  \n```bash\ndotnet test\n```\n\n### **Manual API Testing**  \n📌 **Use Postman** or any REST client to:  \n✅ **Register/Login** → Obtain a JWT Token  \n✅ **Add Books** → `/api/books`  \n✅ **Retrieve Books** → `/api/books?PageNumber=1\u0026PageSize=10`  \n✅ **Get Book Details** → `/api/books/{id}` (track popularity score)  \n\n---\n\n## 🎯 Why Use This Project?  \n\n✅ **Enterprise-Grade Architecture** – Clean, scalable, and maintainable.  \n✅ **Performance-Oriented** – Optimized with CQRS, caching, and indexing.  \n✅ **Security-First Approach** – Uses JWT authentication and role-based access.  \n✅ **Ready for Production** – Implements industry best practices.  \n\n---\n\n## 📜 License  \n\nThis project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.  \n\n---\n\n## 📞 Contact  \n\nFor feedback, contributions, or questions:  \n📧 **Email**: mreshboboyev@gmail.com\n\n💻 **GitHub**: [MrEshboboyev](https://github.com/MrEshboboyev)  \n\n---\n\n🚀 **Build high-performance, scalable APIs with .NET!** Clone the repo \u0026 start coding today!  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmreshboboyev%2Fbook-management-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmreshboboyev%2Fbook-management-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmreshboboyev%2Fbook-management-api/lists"}