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.
- ASP.NET Core 8
- Entity Framework Core (SQL Server)
- IdentityServer for authentication
- Swagger for API documentation
- N-tier architecture
- Docker & Docker Compose
- 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
- .NET SDK 8.0+
- SQL Server (configured in
appsettings.json/appsettings.Development.json
) - Docker & Docker Compose
- Visual Studio or VS Code
-
Clone the repository
git clone https://github.com/makhammadsoliyev/BookManagement.git cd BookManagement
-
Install dependencies
dotnet restore
-
Configure database (update
appsettings.json/appsettings.Development.json
with your database connection string) -
Apply migrations
dotnet ef database update
-
Run the application
dotnet run
-
Build and start the services
docker-compose up --build
-
Stop the services
docker-compose down
-
Check running containers
docker ps
- Uses IdentityServer for authentication.
- JWT tokens required for accessing protected endpoints.
- Roles:
Admin
,User
. - Admin credentials are located in
appsettings.json/appsettings.Developmenet.json
.
POST /api/auth/register
{
"username": "testuser",
"email": "[email protected]",
"password": "SecurePassword123!"
}
POST /api/auth/login
{
"email": "[email protected]",
"password": "SecurePassword123!"
}
This returns a JWT token to be used in Authorization: Bearer <token>
header.
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 |
Method | Endpoint | Description |
---|---|---|
GET |
/api/users/{id} |
Get user by ID |
GET |
/api/users |
Get all users |
- 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.
This project is licensed under the MIT License.
Feel free to reach out if you have any questions!
- LinkedIn: makhammadsoliyev
- Telegram: @hope3538
- Email: [email protected]