This is a basic Library Management System built with TypeScript as part of the Coder Catalyst Program OOP Session Assignment 1. The project demonstrates fundamental Object-Oriented Programming (OOP) concepts including classes, objects, encapsulation, and basic class relationships.
Upon completing this project, we can understand:
- β Defining and creating classes in TypeScript
- β Understanding and implementing basic class relationships
- β Using TypeScript for developing simple applications
- β Understanding the structure of a TypeScript project
- β Working with private/public access modifiers
- β Implementing constructors and methods
- β Managing collections of objects using arrays
ts-boilerplate/
βββ src/
β βββ index.ts # Main entry point and demo
β βββ models/
β βββ index.ts # Barrel exports for all models
β βββ Book.ts # Book class implementation
β βββ User.ts # User class implementation
β βββ LibraryCatalogue.ts # Library catalogue management
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ pnpm-lock.yaml # Package manager lock file
βββ README.md # This file
The project implements the following class structure:
Book
βββ Properties: id, title, author, ISBN (all private)
βββ Constructor(id, title, author, ISBN)
βββ display(): void
βββ Getter methods for all properties
User
βββ Properties: name, email (private)
βββ Constructor(name, email)
βββ borrowBook(bookTitle): void
βββ manageLibrary(): void
βββ display(): void
βββ Getter methods
LibraryCatalogue
βββ Properties: libraryItems[] (private)
βββ Constructor() - initializes empty array
βββ addItem(book): void
βββ displayItems(): void
βββ findBookByTitle(title): Book | undefined
βββ getBookCount(): number
βββ getAllBooks(): Book[]
- Node.js (v16 or higher)
- pnpm (v8 or higher) - preferred package manager
- TypeScript knowledge (basic)
-
Clone the repository:
git clone <your-repo-url> cd ts-boilerplate
-
Install dependencies:
pnpm install
Or if you prefer npm:
npm install
-
Run the project:
pnpm start
This will start the TypeScript compiler in watch mode and execute the demo.
| Command | Description |
|---|---|
pnpm start |
Run the project with ts-node in watch mode |
pnpm build |
Compile TypeScript to JavaScript |
pnpm serve |
Run the compiled JavaScript from dist folder |
The project includes a comprehensive demo in src/index.ts that showcases all functionality:
// Creating books
const book1 = new Book(1, 'The Great Gatsby', 'F. Scott Fitzgerald', '978-0-7432-7356-5');
// Creating library catalogue
const catalogue = new LibraryCatalogue();
catalogue.addItem(book1);
// Creating users
const user1 = new User('Alice Johnson', 'alice.johnson@email.com');
// User interactions
user1.borrowBook('The Great Gatsby');
user1.manageLibrary();
// Finding books
const foundBook = catalogue.findBookByTitle('1984');- β Create books with unique ID, title, author, and ISBN
- β Display book information in formatted output
- β Secure access to book properties via getter methods
- β Create users with name and email
- β Simulate book borrowing functionality
- β Library management operations
- β Add multiple books to a central catalogue
- β Display all books in organized format
- β Search books by title (case-insensitive)
- β Get book count and access all books
Currently no production dependencies (pure TypeScript implementation)
- TypeScript (^5.2.2) - TypeScript compiler
- ts-node (^10.9.1) - TypeScript execution for Node.js
- @types/node (^20.8.10) - TypeScript definitions for Node.js
- β Project Setup: TypeScript boilerplate with proper structure
- β Basic Classes: Book and User classes with required properties
- β Constructor Implementation: Proper initialization of all classes
- β Display Methods: Formatted output for all classes
- β Library Catalogue: Collection management with add/display functionality
- β Code Documentation: Comprehensive comments and documentation
- β TypeScript Best Practices: Proper typing and access modifiers
When you run pnpm start, you'll see output demonstrating:
- Book Creation - Individual book objects with details
- Catalogue Setup - Adding books to the library catalogue
- Complete Catalogue Display - Formatted list of all books
- User Creation - User objects with information
- User Interactions - Book borrowing and library management
- Book Search - Finding specific books in the catalogue
This project demonstrates several key OOP concepts:
- Private properties with public getter methods
- Controlled access to object data
- Class definitions as blueprints
- Object instantiation with constructors
- Instance methods for object behavior
- Static-like utility methods
- Array management within objects
- Iteration and search operations
- Type annotations and type safety
- Access modifiers (private/public)
- Import/export module system
- β Clean Code: Well-organized and readable structure
- β Documentation: JSDoc comments for all classes and methods
- β Type Safety: Full TypeScript typing throughout
- β Modularity: Separated concerns with organized file structure
- β Best Practices: Following TypeScript and OOP conventions
This basic implementation can be extended with:
- Database integration for persistent storage
- Advanced search and filtering capabilities
- Book availability tracking
- User authentication and permissions
- Due dates and fine calculations
- Multiple library branch support
Assignment 1 - Coder Catalyst Program
Object-Oriented Programming Session
MIT License - Feel free to use this code for learning purposes.
This project demonstrates fundamental TypeScript and OOP concepts for educational purposes.