A comprehensive console-based library management system built with C# demonstrating advanced programming concepts and best practices.
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.
- β 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)
- β 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
- β 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
- β 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
- β 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
- Inheritance -
Person
base class forAuthor
andMember
- Polymorphism - Virtual methods and interface implementations
- Encapsulation - Private fields with public properties
- Abstraction - Abstract base classes and interfaces
- β 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
- Repository Pattern - Data access abstraction
- Strategy Pattern - Different loan policies for member types
- Observer Pattern - Event-driven notifications
- Factory Pattern - Entity creation and validation
- .NET 6.0 SDK or later
- Visual Studio 2022, VS Code, or any C# compatible IDE
-
Clone the repository
git clone https://github.com/ygtpy/library-management-console.git cd library-management-console
-
Restore dependencies
dotnet restore
-
Build the project
dotnet build
-
Run the application
dotnet run
The application will automatically:
- Create necessary data directories (
Data/
,Logs/
) - Generate sample data for testing
- Initialize JSON storage files
- Display the main menu
βββββββββββββββββββββββββββββββββββββββ
LIBRARY MANAGEMENT SYSTEM
βββββββββββββββββββββββββββββββββββββββ
1. Book Management
2. Member Management
3. Loan Operations
4. Reports
5. Exit
- 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
- 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
- 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
- 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
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
// 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;
public async Task<Book> AddBookAsync(Book book)
{
var result = await _bookRepository.AddAsync(book);
Console.WriteLine($"β
Book '{result.Title}' added successfully.");
return result;
}
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);
public event Action<Book> BookBorrowed;
public event Action<Loan> BookReturned;
public event Action<Member> MemberRegistered;
// Event firing
BookBorrowed?.Invoke(book);
try
{
var loan = await _libraryService.BorrowBookAsync(membershipNumber, bookId);
ConsoleHelper.WriteSuccess("Book borrowed successfully!");
}
catch (InvalidOperationException ex)
{
ConsoleHelper.WriteError($"Error: {ex.Message}");
}
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 |
- Rate: βΊ0.50 per day for overdue books
- Automatic Calculation: Applied when book is returned late
- Member Tracking: Total fines accumulated per member
- 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
The application uses JSON files for data persistence:
books.json
- Book collection datamembers.json
- Member informationloans.json
- Loan transaction records
{
"books": [
{
"Id": 1,
"Title": "C# Programming",
"ISBN": "978-1234567890",
"Author": {
"FirstName": "John",
"LastName": "Doe"
},
"Status": "Available",
"Category": "Programming"
}
]
}
- β Green: Success messages and confirmations
- β Red: Error messages and warnings
β οΈ Yellow: Warning and information messages- π Formatted Tables: Clean data presentation
- Numbered selection system
- Input validation and error handling
- Clear navigation paths
- "Press any key to continue" prompts
- 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
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
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
- 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
- Unit testing implementation
- Logging framework integration
- Configuration management
- Dependency injection container
- Performance monitoring
- Error tracking and reporting
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.
- Follow C# coding standards and conventions
- Maintain SOLID principles in design
- Write meaningful commit messages
- Update documentation for new features
- Test thoroughly before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
YiΔit Ali Sunal - [email protected]
Made with β€οΈ using C# and .NET - A comprehensive demonstration of modern software development practices