') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - MajidRS/Simple-Library-Management-System-API: 📚 A professional Library Management API built with Node.js & Express, featuring a clean Repository Pattern, centralized error handling, and an interactive API Playground. · GitHub
Skip to content

Repository files navigation

📚 Book Management System (Full-Stack API)

A professional, full-stack library management application built with Node.js and Express.js. This project implements a clean Repository Pattern and features a built-in Interactive API Playground for real-time testing and documentation.


🚀 Project Preview

Below is a screenshot of the interactive API documentation and the development environment:

📸 Click to view API Playground Screenshot


✨ Architectural Excellence

  • Repository Pattern: Decouples business logic from data access logic, making the system database-agnostic and highly maintainable.
  • Centralized Error Handling: Robust exception management using a custom AppError class and global error middleware.
  • Interactive API Playground: A custom-built interface served statically, allowing users to test endpoints directly from the browser.
  • Validation Pipeline: Request body validation (checkBody) and resource existence verification (checkID) via specialized middleware.
  • Modern JavaScript: Fully utilizes ES Modules, async/await, and the native crypto module for secure UUID generation.

🛠️ Tech Stack

Backend

  • Node.js: Runtime environment.
  • Express.js: Web framework.
  • fs/promises: Non-blocking File System operations for JSON storage.

Frontend (Built-in Docs)

  • HTML5 & CSS3: Modern, responsive Dark Mode interface.
  • Vanilla JavaScript: Fetch API for seamless client-server interaction.

🔌 API Documentation

📋 Data Model (Schema)

FieldTypeDescriptionRequired
idUUIDUnique identifier (Auto-generated)
titleStringBook title
authorStringAuthor's name
genreStringBook category
yearNumberYear of publication
availableBooleanAvailability status

🛣️ Endpoints Reference

MethodEndpointDescriptionMiddleware
GET/api/v1/booksGet all books
POST/api/v1/booksCreate a new bookcheckBody
GET/api/v1/books/:idGet book by IDcheckID
PATCH/api/v1/books/:idUpdate book detailscheckID, checkBody
DELETE/api/v1/books/:idRemove a bookcheckID

📁 Project Structure

├── server.js # Entry point
├── app.js # Express config
├── routes/ # Route definitions
├── controllers/ # Request handling logic
├── repository/ # Data Access Layer (Repository Pattern)
├── utils/ # AppError & helpers
├── public/ # Static UI (HTML/CSS)
└── dev-data/ # JSON database storage

🚀 Future Roadmap: Version 2.0

The architecture is already Database-Agnostic, which makes the transition seamless. The next planned milestones are:

  • Migration to MongoDB: Replace fs logic in bookRepository.js with Mongoose models.
  • Advanced Queries: Implement filtering, sorting, and pagination for the books collection.
  • Security Layer: Add User Authentication and Authorization using JWT.
  • Input Sanitization: Add deeper security middleware to prevent NoSQL injection.

📥 Installation & Setup

  1. Clone the repository:
    git clone [https://github.com/MajidRS/Simple-Library-Management-System-API.git](https://github.com/MajidRS/Simple-Library-Management-System-API.git)
    
  2. Install Dependencies:
    npm install
    

⚙️ Configuration (.env)

The project uses environment variables for easy configuration. Create a file named .env in the root directory and add the following variables:

PORT=3000

🚀 Running the Server

​ To start the backend server, run the following command in your terminal:

node server.js

🔗 Accessing the API

Once the server is running, you can interact with the API through the following channels:

🌐 Base URL

Access the raw API endpoints at: http://localhost:3000/

Note: If you changed the PORT in your .env file, make sure to use the updated port in the URLs above.


👨‍💻 Developed By

Hadji AbdelmadjidJunior Node.js Backend Developer

"Building efficient and scalable backend systems with passion."

About

📚 A professional Library Management API built with Node.js & Express, featuring a clean Repository Pattern, centralized error handling, and an interactive API Playground.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages