Skip to content

Comprehensive Library Management System built with C# demonstrating OOP, SOLID principles, design patterns, async programming, and modern development practices. Features book/member management, loan operations, reporting, and extensive logging. Perfect portfolio project showcasing advanced C# concepts.

Notifications You must be signed in to change notification settings

ygtpy/-LibManagementSystem

Repository files navigation

πŸ“š Library Management System - Console Application

A comprehensive console-based library management system built with C# demonstrating advanced programming concepts and best practices.

.NET C# License

🎯 Project Overview

This Library Management System is a feature-rich console application designed to demonstrate advanced C# programming concepts including Object-Oriented Programming, SOLID principles, design patterns, and modern development practices. The system manages books, members, and loan operations with a focus on clean architecture and maintainable code.

✨ Key Features

πŸ“– Book Management

  • βœ… Add new books with author information
  • βœ… Search books by title, author, ISBN, or category
  • βœ… List all available books
  • βœ… Automatic ISBN validation
  • βœ… Category-based organization
  • βœ… Status tracking (Available, Borrowed, Reserved, Lost)

πŸ‘₯ Member Management

  • βœ… Register new members with different types (Student, Teacher, Staff, External)
  • βœ… Automatic membership number generation
  • βœ… Search members by name, email, or membership number
  • βœ… View detailed member profiles with loan history
  • βœ… Fine tracking and management
  • βœ… Member type-based borrowing limits

πŸ”„ Loan Operations

  • βœ… Book borrowing with business rule validation
  • βœ… Automated due date calculation based on member type
  • βœ… Book return processing with fine calculation
  • βœ… Overdue loan tracking and notifications
  • βœ… Active loan management
  • βœ… Member-specific loan limits

πŸ“Š Comprehensive Reporting

  • βœ… Book statistics and collection overview
  • βœ… Member statistics by type and activity
  • βœ… Loan statistics and trends
  • βœ… Popular books report
  • βœ… Member activity analysis
  • βœ… Financial reporting with fine tracking

πŸ› οΈ Advanced Features

  • βœ… Event-driven architecture with real-time notifications
  • βœ… JSON-based data persistence
  • βœ… Colored console output for better user experience
  • βœ… Input validation and error handling
  • βœ… Clean, organized menu system

πŸ—οΈ Architecture & Design Patterns

Object-Oriented Programming Concepts:

  • Inheritance - Person base class for Author and Member
  • Polymorphism - Virtual methods and interface implementations
  • Encapsulation - Private fields with public properties
  • Abstraction - Abstract base classes and interfaces

SOLID Principles Applied:

  • βœ… Single Responsibility - Each class has one clear purpose
  • βœ… Open/Closed - Extensible without modification
  • βœ… Liskov Substitution - Proper inheritance hierarchy
  • βœ… Interface Segregation - Focused interfaces like IRepository<T>
  • βœ… Dependency Inversion - Service layer depends on abstractions

Design Patterns Implemented:

  • Repository Pattern - Data access abstraction
  • Strategy Pattern - Different loan policies for member types
  • Observer Pattern - Event-driven notifications
  • Factory Pattern - Entity creation and validation

πŸš€ Getting Started

Prerequisites

Installation & Setup

  1. Clone the repository

    git clone https://github.com/ygtpy/library-management-console.git
    cd library-management-console
  2. Restore dependencies

    dotnet restore
  3. Build the project

    dotnet build
  4. Run the application

    dotnet run

First Run Setup

The application will automatically:

  • Create necessary data directories (Data/, Logs/)
  • Generate sample data for testing
  • Initialize JSON storage files
  • Display the main menu

πŸ“‹ Usage Guide

Main Menu Navigation

═══════════════════════════════════════
   LIBRARY MANAGEMENT SYSTEM
═══════════════════════════════════════

1. Book Management
2. Member Management
3. Loan Operations
4. Reports
5. Exit

Book Management Operations

  • Add New Book: Enter book details including title, ISBN, author, and category
  • Search Books: Find books by any criteria (title, author, ISBN, category)
  • List Available Books: View all books currently available for borrowing

Member Management Operations

  • Register New Member: Create member accounts with type-specific privileges
  • Search Members: Find members by name, email, or membership number
  • View Member Details: See complete member profile with active loans and history

Loan Operations

  • Borrow Book: Process book loans with automatic validation
  • Return Book: Handle book returns with fine calculation
  • View Overdue Loans: Monitor and track late returns
  • View All Active Loans: Complete overview of current borrowings

Reports & Analytics

  • Book Statistics: Collection overview and status breakdown
  • Member Statistics: Demographics and activity analysis
  • Loan Statistics: Borrowing patterns and trends
  • Popular Books Report: Most borrowed titles
  • Member Activity Report: Top active users
  • Financial Report: Fine collection and outstanding amounts

πŸ—‚οΈ Project Structure

LibraryManagementSystem/
β”œβ”€β”€ πŸ“ Models/
β”‚   β”œβ”€β”€ πŸ“ Abstract/          # Base classes (BaseEntity, Person)
β”‚   β”œβ”€β”€ πŸ“ Concrete/          # Entity implementations (Book, Member, Loan, Author)
β”‚   └── πŸ“ Enums/             # Enumeration types (BookStatus, MemberType, LoanStatus)
β”œβ”€β”€ πŸ“ Interfaces/            # Service contracts (ILibraryService, IRepository<T>)
β”œβ”€β”€ πŸ“ Repositories/          # Data access layer (BookRepository, MemberRepository, LoanRepository)
β”œβ”€β”€ πŸ“ Services/              # Business logic layer (LibraryService)
β”œβ”€β”€ πŸ“ Utilities/             # Helper classes (ConsoleHelper)
β”œβ”€β”€ πŸ“ Data/                  # JSON data storage (books.json, members.json, loans.json)
β”œβ”€β”€ πŸ“ Logs/                  # Application logs (auto-generated)
└── πŸ“„ Program.cs             # Application entry point and UI logic

πŸ§ͺ Key C# Concepts Demonstrated

Modern C# Features

// Pattern Matching
private int GetMaxBooksLimit(MemberType memberType) => memberType switch
{
    MemberType.Student => 3,
    MemberType.Teacher => 10,
    MemberType.Staff => 5,
    MemberType.External => 2,
    _ => 3
};

// Nullable Reference Types
public Author? Author { get; set; }

// Expression-bodied Members
public string FullName => $"{FirstName} {LastName}";
public bool IsAvailable => Status == BookStatus.Available;

Async Programming

public async Task<Book> AddBookAsync(Book book)
{
    var result = await _bookRepository.AddAsync(book);
    Console.WriteLine($"βœ… Book '{result.Title}' added successfully.");
    return result;
}

LINQ Queries

var popularBooks = allLoans.GroupBy(l => new { l.Book.Id, l.Book.Title })
                          .Select(g => new { Title = g.Key.Title, Count = g.Count() })
                          .OrderByDescending(b => b.Count)
                          .Take(10);

Events & Delegates

public event Action<Book> BookBorrowed;
public event Action<Loan> BookReturned;
public event Action<Member> MemberRegistered;

// Event firing
BookBorrowed?.Invoke(book);

Exception Handling

try
{
    var loan = await _libraryService.BorrowBookAsync(membershipNumber, bookId);
    ConsoleHelper.WriteSuccess("Book borrowed successfully!");
}
catch (InvalidOperationException ex)
{
    ConsoleHelper.WriteError($"Error: {ex.Message}");
}

πŸ“Š Business Rules & Logic

Member Type Privileges

Member Type Max Books Loan Period
Student 3 books 14 days
Teacher 10 books 30 days
Staff 5 books 21 days
External 2 books 7 days

Fine Calculation

  • Rate: β‚Ί0.50 per day for overdue books
  • Automatic Calculation: Applied when book is returned late
  • Member Tracking: Total fines accumulated per member

Validation Rules

  • ISBN Uniqueness: No duplicate ISBN numbers allowed
  • Email Uniqueness: One email per member
  • Membership Numbers: Auto-generated unique identifiers
  • Book Availability: Only available books can be borrowed
  • Loan Limits: Enforced based on member type

πŸ’Ύ Data Persistence

JSON Storage

The application uses JSON files for data persistence:

  • books.json - Book collection data
  • members.json - Member information
  • loans.json - Loan transaction records

Sample Data Structure

{
  "books": [
    {
      "Id": 1,
      "Title": "C# Programming",
      "ISBN": "978-1234567890",
      "Author": {
        "FirstName": "John",
        "LastName": "Doe"
      },
      "Status": "Available",
      "Category": "Programming"
    }
  ]
}

🎨 User Interface Features

Colored Console Output

  • βœ… Green: Success messages and confirmations
  • ❌ Red: Error messages and warnings
  • ⚠️ Yellow: Warning and information messages
  • πŸ“Š Formatted Tables: Clean data presentation

Interactive Menus

  • Numbered selection system
  • Input validation and error handling
  • Clear navigation paths
  • "Press any key to continue" prompts

πŸ“ˆ Performance Features

  • Efficient LINQ Queries: Optimized data filtering and searching
  • Memory Management: Proper object disposal and cleanup
  • Lazy Loading: Data loaded only when needed
  • Caching: In-memory storage for session duration

πŸ”„ Extensibility

The architecture supports easy extension:

  • New Entity Types: Add new models inheriting from BaseEntity
  • Additional Repositories: Implement IRepository<T> interface
  • New Business Rules: Extend service layer methods
  • UI Enhancements: Modify ConsoleHelper and menu systems

πŸŽ“ Educational Value

This project demonstrates proficiency in:

  • C# Language Features: Modern syntax and capabilities
  • Object-Oriented Design: Proper class hierarchies and relationships
  • Software Architecture: Clean separation of concerns
  • Design Patterns: Industry-standard implementation patterns
  • Best Practices: Code organization and maintainability
  • Problem Solving: Real-world business logic implementation

πŸš€ Future Enhancements

Planned Features:

  • Database integration (Entity Framework Core)
  • Web API endpoints (ASP.NET Core)
  • Authentication and authorization
  • Email notification system
  • Book reservation system
  • Barcode scanning integration
  • Export functionality (PDF, Excel)
  • Advanced search filters
  • Multi-language support

Technical Improvements:

  • Unit testing implementation
  • Logging framework integration
  • Configuration management
  • Dependency injection container
  • Performance monitoring
  • Error tracking and reporting

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Guidelines:

  1. Follow C# coding standards and conventions
  2. Maintain SOLID principles in design
  3. Write meaningful commit messages
  4. Update documentation for new features
  5. Test thoroughly before submitting

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Clean Architecture principles by Robert C. Martin
  • Microsoft .NET documentation and best practices
  • C# programming community for inspiration and guidance
  • Design Patterns: Elements of Reusable Object-Oriented Software

πŸ“ž Contact

Yiğit Ali Sunal - [email protected]


🌟 If you found this project helpful, please give it a star!

Made with ❀️ using C# and .NET - A comprehensive demonstration of modern software development practices

About

Comprehensive Library Management System built with C# demonstrating OOP, SOLID principles, design patterns, async programming, and modern development practices. Features book/member management, loan operations, reporting, and extensive logging. Perfect portfolio project showcasing advanced C# concepts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages