A comprehensive library management system built with ASP.NET Core Web API that provides functionality for managing books, students, librarians, and book lending operations.
- JWT-based authentication for students and librarians
- Role-based authorization (Student, Librarian)
- Secure password hashing using Argon2id
- Password reset functionality via email
- Student registration and login
- Book search and browsing
- View issued books
- Profile management
- Password change functionality
- Reply to notifications
- Student management (add, activate, deactivate, verify, delete)
- Book management (add, update, delete, activate/deactivate)
- Book lending and return operations
- Notification system
- Library settings management
- PDF file upload for books
- Real-time book stock management
- Automatic penalty calculation for late returns
- Email notifications via SendGrid
- File upload and management
- Comprehensive API documentation with Swagger
LibraryManagement/
βββ LibraryManagement.API/ # Main API project
β βββ Controllers/ # API controllers
β β βββ LibrarianController.cs # Librarian operations
β β βββ StudentController.cs # Student operations
β βββ Data/ # Database context
β β βββ LibraryContext.cs # Entity Framework context
β βββ DTOs/ # Data Transfer Objects
β β βββ AddBookFormDto.cs
β β βββ BookDto.cs
β β βββ BookIssueDto.cs
β β βββ LoginDto.cs
β β βββ NotificationDto.cs
β β βββ StudentDto.cs
β β βββ UpdatePasswordDto.cs
β βββ Models/ # Entity models
β β βββ Book.cs
β β βββ BookIssue.cs
β β βββ Librarian.cs
β β βββ LibrarySettings.cs
β β βββ Notification.cs
β β βββ Student.cs
β βββ Services/ # Business logic services
β β βββ AuthService.cs # Authentication & authorization
β β βββ FileService.cs # File upload operations
β β βββ LibraryService.cs # Core library operations
β βββ Migrations/ # Entity Framework migrations
β βββ wwwroot/ # Static files
β β βββ uploads/ # PDF file storage
β βββ Program.cs # Application entry point
β βββ appsettings.json # Configuration
βββ LibraryManagement.sln # Solution file
- Framework: ASP.NET Core 9.0
- Database: SQL Server with Entity Framework Core
- Authentication: JWT Bearer Tokens
- Password Hashing: Argon2id (Konscious.Security.Cryptography)
- Email Service: SendGrid
- API Documentation: Swagger/OpenAPI
- File Storage: Local file system with PDF support
- .NET 9.0 SDK
- SQL Server (LocalDB or full instance)
- SendGrid account (for email functionality)
- Visual Studio 2022 or VS Code
-
Clone the repository
git clone <repository-url> cd LibraryManagement
-
Configure the database connection
- Update the connection string in
appsettings.json:
"ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=LibraryDb;Trusted_Connection=True;" }
- Update the connection string in
-
Configure SendGrid (optional)
- Get your SendGrid API key from SendGrid Dashboard
- Update the API key in
appsettings.json:
"SendGrid": { "ApiKey": "YourSendGridApiKey" }
-
Run database migrations
cd LibraryManagement.API dotnet ef database update -
Run the application
dotnet run
-
Access the API
- API Base URL:
https://localhost:7001orhttp://localhost:5001 - Swagger Documentation:
https://localhost:7001/swagger
- API Base URL:
POST /api/student/register- Register a new studentPOST /api/student/login- Student loginPOST /api/student/forgot-password- Request password resetPUT /api/student/change-password/{email}- Change password
POST /api/librarian/login- Librarian login
GET /api/student/books/search?query={query}- Search booksGET /api/student/books/list- Get all booksGET /api/student/issued-books/{email}- Get issued books
PATCH /api/student/profile-update/{email}- Update profilePOST /api/student/notifications/reply/{id}- Reply to notification
GET /api/librarian/students- Get all studentsPOST /api/librarian/students- Add new studentPUT /api/librarian/students/{id}/activate- Activate studentPUT /api/librarian/students/{id}/deactivate- Deactivate studentPUT /api/librarian/students/{id}/verify- Verify studentDELETE /api/librarian/students/{id}- Delete student
GET /api/librarian/books- Get all booksPOST /api/librarian/books- Add new book (with PDF upload)PUT /api/librarian/books/{id}- Update bookDELETE /api/librarian/books/{id}- Delete bookPUT /api/librarian/books/{id}/activate- Activate bookPUT /api/librarian/books/{id}/deactivate- Deactivate book
POST /api/librarian/issue-book- Issue book to studentPOST /api/librarian/return-book- Return bookGET /api/librarian/notifications- Get notificationsPUT /api/librarian/settings- Update library settings
The API uses JWT Bearer tokens for authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
sub: User emailrole: User role (Student/Librarian)jti: Unique token identifier
- Students: User accounts with email, password, name, verification status
- Librarians: Admin accounts for library management
- Books: Book information with title, author, publication, stock, PDF URL
- BookIssues: Lending records with issue/return dates and penalties
- Notifications: Communication system between librarians and students
- LibrarySettings: System configuration (book limits, penalties)
- Argon2id Password Hashing: Industry-standard password hashing with salt
- JWT Authentication: Secure token-based authentication
- Role-based Authorization: Different access levels for students and librarians
- PDF Upload: Books can have associated PDF files
- Secure Storage: Files stored with unique GUIDs
- File Cleanup: Automatic cleanup when books are updated/deleted
- Stock Management: Automatic stock tracking for book lending
- Penalty System: Automatic calculation of late return penalties
- Book Limits: Configurable maximum books per student
- Email Notifications: Password reset and system notifications
The API includes comprehensive Swagger documentation for testing:
- Navigate to
/swaggerin your browser - Use the interactive documentation to test endpoints
- Authenticate using the login endpoints first
- Copy the JWT token and use the "Authorize" button
Key configuration settings in appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Your_Database_Connection_String"
},
"Jwt": {
"Key": "Your_JWT_Secret_Key_32_Characters_Minimum",
"Issuer": "Your_Issuer",
"Audience": "Your_Audience"
},
"SendGrid": {
"ApiKey": "Your_SendGrid_API_Key"
}
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE.txt file for details.
For support and questions:
- Create an issue in the repository
- Check the Swagger documentation at
/swagger - Review the API endpoints documentation above
Note: This is a development-ready library management system. For production use, ensure proper security configurations, SSL certificates, and environment-specific settings.