Skip to content

Seth724/typescript-library-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TypeScript Library Management System

πŸ“– Project Overview

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.

🎯 Learning Outcomes

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

πŸ—οΈ Project Structure

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

πŸ“‹ Class Diagram

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[]

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • pnpm (v8 or higher) - preferred package manager
  • TypeScript knowledge (basic)

Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd ts-boilerplate
  2. Install dependencies:

    pnpm install

    Or if you prefer npm:

    npm install
  3. Run the project:

    pnpm start

    This will start the TypeScript compiler in watch mode and execute the demo.

Available Scripts

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

πŸ’» Usage Example

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');

πŸ”§ Key Features

Book Management

  • βœ… Create books with unique ID, title, author, and ISBN
  • βœ… Display book information in formatted output
  • βœ… Secure access to book properties via getter methods

User Management

  • βœ… Create users with name and email
  • βœ… Simulate book borrowing functionality
  • βœ… Library management operations

Catalogue Management

  • βœ… 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

πŸ“¦ Dependencies

Production Dependencies

Currently no production dependencies (pure TypeScript implementation)

Development Dependencies

  • 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

πŸŽ“ Assignment Requirements Fulfilled

  • βœ… 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

πŸƒβ€β™‚οΈ Running the Demo

When you run pnpm start, you'll see output demonstrating:

  1. Book Creation - Individual book objects with details
  2. Catalogue Setup - Adding books to the library catalogue
  3. Complete Catalogue Display - Formatted list of all books
  4. User Creation - User objects with information
  5. User Interactions - Book borrowing and library management
  6. Book Search - Finding specific books in the catalogue

🎯 Learning Points

This project demonstrates several key OOP concepts:

Encapsulation

  • Private properties with public getter methods
  • Controlled access to object data

Classes and Objects

  • Class definitions as blueprints
  • Object instantiation with constructors

Method Implementation

  • Instance methods for object behavior
  • Static-like utility methods

Collections

  • Array management within objects
  • Iteration and search operations

TypeScript Features

  • Type annotations and type safety
  • Access modifiers (private/public)
  • Import/export module system

πŸ“ Code Quality

  • βœ… 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

πŸ”„ Next Steps

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

πŸ‘¨β€πŸ’» Author

Assignment 1 - Coder Catalyst Program
Object-Oriented Programming Session

πŸ“„ License

MIT License - Feel free to use this code for learning purposes.


This project demonstrates fundamental TypeScript and OOP concepts for educational purposes.

About

TypeScript Library Management System - OOP Assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published