Welcome to BookNest β a comprehensive library management system designed to simplify the organization and management of books and authors. Whether you're managing a small personal library or a large collection, BookNest provides all the essential tools you need.
BookNest is a powerful web application built using ASP.NET Core and Entity Framework Core. It allows users to manage books and authors, perform CRUD operations, search through the collection, and ensure data integrity. The project follows the MVC (Model-View-Controller) architecture, promoting a clean, maintainable, and scalable codebase.
- π Book Management: Create, Read, Update, and Delete (CRUD) operations for books.
- π€ Author Management: Manage author information with full CRUD capabilities.
- π Search Functionality: Easily search for books and authors in the collection.
- π± Responsive Design: The user interface is built with Bootstrap, ensuring a seamless experience across devices.
- β Data Validation: Ensures data integrity and consistency with built-in validation.
- π Security: Protects user data with authentication and secure handling of sensitive information.
Before running this project, ensure you have the following installed:
- π₯οΈ Visual Studio (with ASP.NET and web development workload)
- βοΈ .NET Core SDK
- πΎ SQL Server
Follow these steps to get the project up and running on your local machine:
-
π₯ Clone the Repository
git clone https://github.com/your-username/BookNest.git
-
π Navigate to the Project Directory
cd BookNest
-
π¦ Restore Dependencies
dotnet restore
-
π Update Database
- Ensure your SQL Server is running.
- Update the
appsettings.json
with your database connection string. - Run the following command to create the database:
dotnet ef database update
-
βΆοΈ Run the Applicationdotnet run
The application should now be running on
http://localhost:5000
.
The project follows the MVC (Model-View-Controller) pattern:
- π Model: Represents the application data (e.g., Books, Authors).
- π¨ View: Handles the user interface (HTML, CSS, and Razor views).
- π§ Controller: Manages the interaction between Model and View, processing user input and returning the appropriate response.
The database schema was created using Entity Framework Core's Code-First approach. The main entities are:
- π Book: Represents a book in the library.
- π€ Author: Represents an author who has written one or more books.
- π One-to-Many Relationship: An author can write multiple books, but each book is written by one author.
Security is a key consideration in BookNest:
- βοΈ Data Validation: Ensures that user inputs are correctly formatted and prevents invalid data from being saved.
- π Authentication: User authentication is managed through ASP.NET Core Identity, ensuring that only authorized users can access sensitive data.
- π‘οΈ SQL Injection Protection: All database interactions are handled through Entity Framework Core, which automatically protects against SQL injection attacks.
Performance is optimized using:
- π Asynchronous Programming: Improves application responsiveness by handling multiple requests concurrently.
- βοΈ Optimized Queries: Efficient database queries using LINQ, with eager loading to minimize the number of database calls.
The application is tested using:
- π Unit Testing: Ensures that individual components work as expected.
- π Integration Testing: Tests the interaction between different components.
- π¨βπ» Manual Testing: Ensures the user interface behaves as expected.
The application can be deployed on any platform that supports .NET Core. The recommended deployment method is using Azure App Service for a cloud-based deployment:
- βοΈ Build the Application
dotnet publish -c Release
- βοΈ Deploy to Azure
- Use the Azure CLI or Azure Portal to deploy the application.
- Set up CI/CD pipelines for automated deployment.
- π : Declares the document type and version of HTML.
- π€ : Sets the character encoding to UTF-8.
- π± : Ensures responsive design.
- π¨ : Links Bootstrap CSS.
- π» <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>: Links Bootstrap JS for interactive components.
- π navbar, navbar-expand-lg, navbar-dark, bg-dark: Bootstrap classes for styling and responsive behavior.
- π·οΈ navbar-brand: Brand link.
- π² navbar-toggler: Button for mobile view.
- π οΈ asp-action: Specifies the action method in the controller.
- π¨ form-control: Applies Bootstrap styling to form controls.
- β text-danger: Styles validation error messages.
- π±οΈ btn, btn-dark, btn-primary: Bootstrap button classes for styling.
- π table, table-striped, table-bordered, table-dark: Bootstrap classes for table styling.
- π¦ container: Centers content and adds responsive padding.
- π² row: Creates a horizontal group of columns.
- π col-md-*: Defines column width based on screen size.
- π navbar, navbar-expand-lg, navbar-dark, bg-dark: Navbar styling and behavior.
- π form-group: Wraps form controls with margin and padding.
- π¨ form-control: Styles input fields, textareas, and selects.
- π±οΈ btn, btn-dark, btn-primary: Button styling.
- π table, table-striped, table-bordered, table-dark: Table styling and behavior.
- β text-danger: Styles text as red for error messages.
- π§ asp-action: Specifies the action method to handle form submissions.
- π asp-for: Binds form elements to model properties.
- β asp-validation-for: Displays validation error messages.
EPPlus is used to generate Excel files in BookNest. Here's a summary of its usage in the DownloadExcel
method:
- Fetching Data: Retrieves all books from the
bookService
. - License Context: Sets the EPPlus license context to
NonCommercial
for non-commercial use. For commercial use, you need a valid license. - Excel Package Creation: Creates a new Excel package and adds a worksheet named "Books".
- Header Row: Sets the first row of the worksheet with column headers such as "Title", "Genre", "ISBN", etc.
- Populating Data: Iterates through the list of books and fills the worksheet with data starting from the second row.
- Saving the File: Saves the data to a memory stream, which is then returned as a file download response with the appropriate content type for an Excel file.
- EPPlus License: Ensure compliance with the EPPlus license terms. Use
LicenseContext.NonCommercial
for non-commercial projects orLicenseContext.Commercial
with a valid commercial license. - Error Handling: Consider adding error handling to manage exceptions during the Excel generation process.
We welcome contributions to improve BookNest! To contribute:
- π΄ Fork the repository.
- πΏ Create a new branch for your feature or bugfix.
- π Submit a pull request once your changes are complete.
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions, feel free to reach out via:
- βοΈ Email: coder.deepak44@gmail.com
- π GitHub: DeepakScripter