Skip to content

Book Management API built with ASP.NET Core, EF Core, and IdentityServer. Developed for the Exadel .NET Internship.

License

Notifications You must be signed in to change notification settings

makhammadsoliyev/BookManagement

Repository files navigation

Book Management API

📌 Overview

The Book Management API is a RESTful service built with ASP.NET Core that allows users to manage books and users. It includes authentication, authorization, and role-based access control (RBAC) using IdentityServer.

🛠 Tech Stack

  • ASP.NET Core 8
  • Entity Framework Core (SQL Server)
  • IdentityServer for authentication
  • Swagger for API documentation
  • N-tier architecture
  • Docker & Docker Compose

🚀 Features

  • User authentication and authorization
  • Role-based access control (Admin, User)
  • CRUD operations for books
  • Bulk operations for books
  • User management (Admin only)
  • API documentation with Swagger
  • Dockerized deployment with Docker Compose

🐜 Getting Started

Prerequisites

  • .NET SDK 8.0+
  • SQL Server (configured in appsettings.json/appsettings.Development.json)
  • Docker & Docker Compose
  • Visual Studio or VS Code

Installation & Setup

  1. Clone the repository

    git clone https://github.com/makhammadsoliyev/BookManagement.git
    cd BookManagement
  2. Install dependencies

    dotnet restore
  3. Configure database (update appsettings.json/appsettings.Development.json with your database connection string)

  4. Apply migrations

    dotnet ef database update
  5. Run the application

    dotnet run

🐳 Running with Docker Compose

  1. Build and start the services

    docker-compose up --build
  2. Stop the services

    docker-compose down
  3. Check running containers

    docker ps

🔒 Authentication & Authorization

  • Uses IdentityServer for authentication.
  • JWT tokens required for accessing protected endpoints.
  • Roles: Admin, User.
  • Admin credentials are located in appsettings.json/appsettings.Developmenet.json.

Register a New User

POST /api/auth/register
{
  "username": "testuser",
  "email": "[email protected]",
  "password": "SecurePassword123!"
}

Login

POST /api/auth/login
{
  "email": "[email protected]",
  "password": "SecurePassword123!"
}

This returns a JWT token to be used in Authorization: Bearer <token> header.

📚 API Endpoints

Books

Method Endpoint Description Role
POST /api/books Add a new book User, Admin
POST /api/books/bulk Add multiple books User, Admin
GET /api/books/{id} Get book by ID User, Admin
GET /api/books/{title} Get book by title User, Admin
GET /api/books Get paginated book titles User, Admin
PUT /api/books/{id} Update a book User, Admin
DELETE /api/books/{id} Soft delete a book User, Admin
DELETE /api/books/bulk Bulk delete books User, Admin
PUT /api/books/{title}/restore Restore a soft-deleted book Admin
GET /api/books/soft-deleted-books-titles Retrieve soft-deleted book titles Admin

Users (Admin Only)

Method Endpoint Description
GET /api/users/{id} Get user by ID
GET /api/users Get all users

📝 API Documentation

  • Run the project and navigate to:
    https://localhost:18081/swagger/index.html
    
  • The Swagger UI will show all available endpoints with request and response examples.

📝 License

This project is licensed under the MIT License.


Feel free to reach out if you have any questions!

👤 Contact

About

Book Management API built with ASP.NET Core, EF Core, and IdentityServer. Developed for the Exadel .NET Internship.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published