Skip to content

ASP.NET Core Web API for book library management with EF Core. Features books, authors, categories, reviews, and advanced LINQ queries with a clean architecture.

Notifications You must be signed in to change notification settings

NickiMash17/BookLibrarySystem

Repository files navigation

📚 Book Library System

.NET Core EF Core SQL Server Swagger LINQ

An advanced ASP.NET Core Web API for managing a book library, demonstrating best practices in routing, middleware, caching, authorization, logging, documentation, testing, and performance.

✨ Features

  • 📖 Complete Book Management - Create, read, update, and delete books with all details
  • 👩‍💻 Author Tracking - Link books to authors with biographical information
  • 🏷️ Category Organization - Assign multiple categories to books
  • Review System - Store and retrieve book reviews with ratings
  • 🔍 Advanced Search - Find books by title, author, or description using LINQ
  • 📊 Rating Analytics - Calculate average ratings across books
  • 📘 API Documentation - Auto-generated Swagger/OpenAPI documentation
  • Advanced Routing: Attribute routing, route constraints, and custom routes.
  • Middleware & Filters: Custom request logging middleware and action logging filter.
  • Caching: Response caching, in-memory caching, and distributed Redis caching.
  • Role-Based Authorization: Restrict endpoints to roles (e.g., Admin for create/update/delete).
  • Logging & Monitoring: Serilog integration, health check endpoint (/health).
  • Automated Testing: xUnit and Moq for unit testing controllers and repositories.
  • Performance Tuning: AsNoTracking, pagination, and profiling guidance.
  • Pagination: All major endpoints support paginated responses with metadata (total count, page, size, total pages).

🏗️ Architecture

graph TD A[Controllers] --> B[Repositories] B --> C[DbContext] C --> D[(SQL Database)] subgraph "Data Models" E[Book] <--> F[Author] E <--> G[Category] E <--> H[Review] end 
Loading

📋 Database Schema

Entity Description Relations
📕 Book Core book information Belongs to Author, Has many Categories, Has many Reviews
👤 Author Writer details with bio Has many Books
🏷️ Category Genre classification Has many Books
💬 Review User feedback and ratings Belongs to Book

🚀 Quick Start

Prerequisites

Installation in 5 Easy Steps

  1. Clone & Navigate:

    git clone https://github.com/NickiMash17/BookLibrarySystem.git cd BookLibrarySystem
  2. Restore Packages:

    dotnet restore
  3. Set Up Database:

    dotnet ef database update
  4. Launch the API:

    dotnet run
  5. Explore with Swagger:

    https://localhost:7001/swagger/index.html 

🔌 API Endpoints

Book Operations

Method Endpoint Description
GET /api/Books 📋 List all books
GET /api/Books/{id} 📕 Get book details
GET /api/Books/author/{id} 👤 Get author's books
GET /api/Books/category/{id} 🏷️ Get books by category
GET /api/Books/search?term={query} 🔍 Search books
GET /api/Books/ratings ⭐ Get books with ratings
POST /api/Books ➕ Add new book
PUT /api/Books/{id} 📝 Update book
DELETE /api/Books/{id} 🗑️ Delete book

📂 Project Structure

BookLibrarySystem/ ├── 🎮 Controllers/ │ └── BooksController.cs ├── 💾 Data/ │ ├── BookLibraryContext.cs │ └── DbInitializer.cs ├── 📋 Models/ │ ├── Author.cs │ ├── Book.cs │ ├── BookCategory.cs │ ├── Category.cs │ └── Review.cs ├── 🔄 Repositories/ │ ├── BookRepository.cs │ └── IBookRepository.cs ├── 🔀 Migrations/ ├── ⚙️ appsettings.json └── 🚀 Program.cs 

🧠 Design Patterns Used

  • Repository Pattern - Separation of data access logic
  • Dependency Injection - Built-in .NET Core DI container
  • LINQ Query Objects - For complex database queries with strong typing
  • Entity Framework Core - ORM for database operations
  • OpenAPI/Swagger - For automatic API documentation and testing

💡 Sample Usage

// Get all books with ratings above 4.0 var highlyRatedBooks = await _context.Books .Include(b => b.Author) .Include(b => b.Reviews) .Where(b => b.Reviews.Average(r => r.Rating) >= 4.0) .ToListAsync();

🤝 Contributing

Contributions make the open-source community amazing! Follow these steps:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ for book lovers and developers alike

⭐ Star this repository if you find it useful! ⭐

About

ASP.NET Core Web API for book library management with EF Core. Features books, authors, categories, reviews, and advanced LINQ queries with a clean architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages