Skip to content

anaya-upadhyay/BookManagementSystem

Repository files navigation

Book Management System

A comprehensive .NET 8 C# console application for managing a book collection with full CRUD operations. Features a BIOS-style two-pane console interface, clean architecture, and SQLite database.

Features

  • Full CRUD Operations: Create, Read, Update, and Delete books
  • Clean Architecture: Organized with Interfaces/Services pattern
  • Dependency Injection: Using Microsoft.Extensions.DependencyInjection
  • SQLite Database: Lightweight, file-based database with Entity Framework Core
  • BIOS-Style UI: Two-pane console interface with box-drawing characters
  • Input Validation: Ensures data integrity with required field validation
  • Search Functionality: Find books by title or ISBN
  • ISBN Uniqueness: Enforced at database level

Project Structure

BookManagementSystem/
├── Models/              # Entity classes
│   └── Book.cs
├── Data/                # DbContext and database configuration
│   └── BookDbContext.cs
├── Interfaces/          # Service contracts
│   └── IBookService.cs
├── Services/            # Service implementations
│   └── BookService.cs
├── UI/                  # Console rendering logic
│   ├── ConsoleUI.cs
│   └── BookManager.cs
├── Program.cs           # Application entry point with DI setup
└── BookManagementSystem.csproj

Prerequisites

  • .NET 8 SDK or later
  • A terminal/command prompt that supports Unicode characters

Installation and Setup

1. Clone or Download the Project

Navigate to the project directory:

cd BookManagementSystem

2. Restore NuGet Packages

dotnet restore

3. Build the Project

dotnet build

4. Database Setup

The application uses Entity Framework Core with SQLite. The database will be created automatically on first run. However, if you want to use migrations:

Create Initial Migration (Optional)

dotnet ef migrations add InitialCreate

Apply Migrations

dotnet ef database update

Note: The application uses EnsureCreatedAsync() which automatically creates the database on first run, so manual migration is optional.

Running the Application

dotnet run

The application will launch with a BIOS-style two-pane interface.

Usage Guide

Navigation

  • ↑/↓ Arrow Keys: Navigate through menu items
  • Enter: Select/Confirm
  • ESC: Exit or Cancel current operation

Main Menu Options

1. Add Book

Adds a new book to the database.

Required Fields:

  • Title
  • Author Name
  • ISBN (must be unique)

Optional Fields:

  • Edition
  • Publisher Name
  • URL

Steps:

  1. Select "Add Book" from the main menu
  2. Enter the book details when prompted
  3. Press Enter after each field
  4. The book will be saved and you'll see a confirmation message

2. List All Books

Displays all books in the database in a tabular format.

Columns Displayed:

  • Book ID
  • Title
  • Author
  • ISBN

Features:

  • Pagination support for large datasets
  • Shows total count of books
  • Truncates long text to fit the display

3. Search Books

Search for books by title or ISBN.

Steps:

  1. Select "Search Books" from the main menu
  2. Enter your search term (title or ISBN)
  3. Matching results will be displayed in a table
  4. Shows count of matching books

Search Behavior:

  • Case-insensitive search
  • Partial matching supported
  • Searches both Title and ISBN fields

4. Edit Book

Update an existing book's information.

Steps:

  1. Select "Edit Book" from the main menu
  2. Enter the Book ID or ISBN of the book to edit
  3. Current book details will be displayed
  4. Enter new values or press Enter to keep existing values
  5. Confirmation message will be shown

Notes:

  • ISBN uniqueness is validated during edit
  • All fields can be updated except Book ID

5. Delete Book

Remove a book from the database.

Steps:

  1. Select "Delete Book" from the main menu
  2. Enter the Book ID or ISBN of the book to delete
  3. Book details will be displayed
  4. Confirm deletion by pressing 'Y' or cancel with 'N'
  5. Confirmation message will be shown

Warning: Deletion is permanent and cannot be undone.

6. Exit

Closes the application.

Book Entity Properties

Property Type Required Unique Description
BookId int Auto-generated Yes Primary key
Title string Yes No Book title (max 200 chars)
Edition string No No Book edition (max 50 chars)
AuthorName string Yes No Author name (max 150 chars)
PublisherName string No No Publisher name (max 150 chars)
ISBN string Yes Yes ISBN (max 20 chars)
URL string No No Related URL (max 500 chars)

Technical Details

Architecture

The application follows clean architecture principles:

  • Separation of Concerns: UI, Business Logic, and Data Access are separated
  • Dependency Injection: Services are registered and injected via DI container
  • Interface-Based Design: Business logic uses interfaces for loose coupling
  • Async/Await: All database operations are asynchronous

Database

  • Provider: SQLite
  • ORM: Entity Framework Core 8.0
  • Connection String: Data Source=books.db (stored in current directory)
  • Constraints: Unique index on ISBN field

Dependencies

  • Microsoft.EntityFrameworkCore (8.0.0)
  • Microsoft.EntityFrameworkCore.Sqlite (8.0.0)
  • Microsoft.EntityFrameworkCore.Design (8.0.0)
  • Microsoft.Extensions.DependencyInjection (8.0.0)

Configuration

Database Connection String

The connection string can be modified in Program.cs:

var connectionString = "Data Source=books.db";

To use a different location:

var connectionString = "Data Source=C:\\path\\to\\your\\books.db";

Console Window Size

The UI is optimized for 170x48 character display (1366x768 screen resolution). You can adjust this in ConsoleUI.cs:

private const int WindowWidth = 170;
private const int WindowHeight = 48;
private const int LeftPaneWidth = 120;

Troubleshooting

Console Display Issues

If the box-drawing characters don't display correctly:

  1. Ensure your terminal supports UTF-8 encoding
  2. On Windows, use Windows Terminal or PowerShell 7+
  3. On older Windows systems, you may need to change console font to a Unicode-compatible font

Database Issues

If you encounter database errors:

  1. Delete the books.db file
  2. Run the application again to create a fresh database

Build Errors

If you get build errors:

  1. Ensure .NET 8 SDK is installed: dotnet --version
  2. Clean the solution: dotnet clean
  3. Restore packages: dotnet restore
  4. Build again: dotnet build

Future Enhancements

Potential features for future versions:

  • Export books to CSV/JSON
  • Import books from file
  • Advanced filtering and sorting
  • Multi-author support
  • Category/Genre classification
  • Book cover image support
  • Reading status tracking

License

This project is provided as-is for educational and personal use.

Author

Book Management System v1.0. Created: Nov 30, 2025. Anaya Upadhyay

Support & Contact

If you encounter any issues or have questions, please feel free to reach out via email: Anaya Upadhyay.

For additional guidance, refer to the source code comments, which include XML documentation for all public methods.

Releases

No releases published

Packages

No packages published

Languages