A RESTful API built with ASP.NET Core for managing library operations, including books, customers, borrowing, and authentication. This project demonstrates secure, scalable, and efficient backend development practices.
- User Management:
- Registration and Login with JWT-based authentication.
- Role-based access control (Admin, User).
- Book Management:
- CRUD operations for books.
- Track book details such as title, author, publisher, and published date.
- Customer Management:
- Manage customer profiles and their borrowing history.
- Link customers with user accounts for secure access.
- Borrowing System:
- Allow customers to borrow and return books.
- Keep track of borrowing status and due dates.
- Book Copies:
- Manage individual book copies to track their availability.
- Monitor book statuses such as available, borrowed, or reserved.
- Framework: ASP.NET Core
- Database: SQL Server
- ORM: Entity Framework Core
- Authentication: JWT (JSON Web Token)
- Version Control: Git
- Tools: Visual Studio, Postman (for API testing)
POST /api/Users/register: Register a new user.POST /api/Users/login: Authenticate and log in a user.
GET /api/Books: Retrieve all books.GET /api/Books/{id}: Retrieve a single book by ID.POST /api/Books: Add a new book.PUT /api/Books/{id}: Update a book's details.DELETE /api/Books/{id}: Delete a book.
GET /api/Customers: Retrieve all customers.GET /api/Customers/{id}: Retrieve a customer by ID.PUT /api/Customers/{id}: Update customer details.
POST /api/Borrowings: Get All Borrowing Records.POST /api/Borrowings: Borrow A Book.POST /api/Borrowings/return: Return a borrowed book.
GET /api/BookCopies: Retrieve all book copies.POST /api/BookCopies: Add a new book copy.PUT /api/BookCopies: Update A book copy.DELETE /api/BookCopies: Delete book copy.
Make sure you have the following installed before proceeding:
- .NET SDK 8.0+
- SQL Server (or SQL Server Express)
- Git
- Visual Studio 2022 or VS Code
git clone https://github.com/Eldax23/BookLibraryApi.git
cd BookLibraryApiOpen appsettings.json and update the connection string to match your SQL Server setup:
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER_NAME;Database=LibraryDb;Trusted_Connection=True;TrustServerCertificate=True;"
}If you're using SQL Server Express, your server name is typically
.\SQLEXPRESS.
In appsettings.json, set your JWT secret key and token settings:
"JWT": {
"Key": "your_super_secret_key_here",
"Issuer": "LibraryManagementAPI",
"Audience": "LibraryManagementClient",
"DurationInDays": 7
}
⚠️ Make sure theKeyis at least 32 characters long for proper signing.
dotnet restoredotnet ef database updateIf the
Migrationsfolder doesn't exist yet, run this first:dotnet ef migrations add InitialCreate
dotnet runThe API will start on https://localhost:{port} by default.
Navigate to the Swagger UI in your browser to explore and test all endpoints:
https://localhost:{port}/swagger
Alternatively, import the API into Postman and start making requests.
This project is licensed under the MIT License.