Skip to content

GoldLion123RP/Library_DBMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“š Library Management System

A full-stack cloud-deployed Library Management System built as a DBMS Lab Project for Brainware University

Live Demo Backend API License: MIT Mobile Responsive


๐ŸŒ Live Demo

๐Ÿ”— Application: https://goldlion123rp.github.io/Library_DBMS/

๐Ÿ”— Backend API: https://library-dbms-1tp2.onrender.com

๐Ÿ”— Source Code: https://github.com/goldlion123rp/Library_DBMS

Note: First load may take 30-60 seconds as the free backend server wakes up. Subsequent requests are fast.


๐Ÿ” Demo Credentials

Admin Account (Full Access)

  • Username: rahul.pal
  • Password: rahul123
  • Permissions: Complete system access, staff management, all CRUD operations

Librarian Account

  • Username: ajay.das
  • Password: ajay123
  • Permissions: Book & member management, loan operations, reports

Assistant Account

  • Username: santunu.mog
  • Password: santunu123
  • Permissions: View access, basic loan operations

โœจ Features

๐Ÿ“– Core Functionality

  • โœ… User Authentication - Secure login with role-based access control (RBAC)
  • โœ… Book Management - Complete CRUD operations with search and filtering
  • โœ… Member Management - Track members, memberships, and borrowing history
  • โœ… Loan Tracking - Issue and return books with automatic due date calculation (14-day period)
  • โœ… Fine Management - Automatic fine calculation (โ‚น5/day for overdue books)
  • โœ… Reports & Analytics - Real-time statistics and performance insights
  • โœ… Staff Management - Admin-only staff and role management

๐ŸŽจ User Experience

  • โœ… Fully Responsive Design - Seamless experience on desktop, tablet, and mobile
  • โœ… Mobile Hamburger Menu - Touch-friendly navigation with slide-in sidebar
  • โœ… Real-time Search - Instant search and filtering across all modules
  • โœ… Clean Modern UI - Intuitive interface with color-coded elements
  • โœ… Interactive Dashboard - Real-time statistics and quick insights
  • โœ… Smooth Animations - Polished user interactions and transitions

๐Ÿ”’ Security & Access Control

  • โœ… Role-Based Access Control (RBAC)
    • Admin: Full system access + staff management
    • Librarian: Book/member management + loan operations
    • Assistant: View access + basic operations
  • โœ… Token-based Authentication - Secure session management
  • โœ… Secure API Endpoints - Protected routes with authorization
  • โœ… Input Validation - Client and server-side validation
  • โœ… CORS Protection - Configured cross-origin policies
  • โœ… Login Audit Logging - Tracks all login attempts with IP, user agent, and status

๐Ÿ“ฑ Mobile Features

  • โœ… Hamburger Menu - Animated slide-in navigation
  • โœ… Touch Optimized - Large touch targets and swipe gestures
  • โœ… Responsive Tables - Horizontal scroll for data tables
  • โœ… Adaptive Layouts - Optimized for all screen sizes
  • โœ… No Content Overlap - Perfect mobile viewing experience

๐Ÿ› ๏ธ Tech Stack

Frontend

  • HTML5 - Semantic markup and accessibility
  • CSS3 - Custom styling with CSS variables and media queries
  • Vanilla JavaScript (ES6+) - Modern JavaScript features
  • Responsive Design - Mobile-first approach with breakpoints
  • Hosted on: GitHub Pages (Free CDN hosting)

Backend

  • Python 3.9+ - Core programming language
  • Flask 3.0.0 - Lightweight web framework
  • Flask-CORS 4.0.0 - Cross-origin resource sharing
  • PyMySQL 1.1.0 - MySQL database connector
  • Gunicorn 21.2.0 - Production WSGI server
  • Hosted on: Render.com (Free tier with auto-deploy)

Database

  • MySQL 8.4 - Relational database management system
  • 11 Normalized Tables - 3NF schema design
  • Indexed Queries - Optimized performance
  • Foreign Keys - Referential integrity
  • Hosted on: Clever Cloud (Free tier - 256MB storage)

๐Ÿ“Š Database Schema

Tables (12 total)

  1. Roles - User role definitions (Admin, Librarian, Assistant)
  2. Users - System users with role assignments
  3. Staff - Library staff information and credentials
  4. AuthenticationSystem - Login authentication data
  5. Author - Book authors with biography
  6. BookDetails - Book metadata (ISBN, title, author, category, price)
  7. Books - Physical inventory (location, quantity)
  8. Members - Library members and membership details
  9. Loans - Borrowing transactions and status tracking
  10. Fines - Overdue fine calculations and payment status
  11. BorrowHistory - Historical data for analytics
  12. LoginAuditLog - Security logging for login attempts

Relationships & Integrity

  • Foreign key constraints for referential integrity
  • Indexed columns (book_id, member_id, isbn, membership_no)
  • Normalized to Third Normal Form (3NF)
  • CASCADE and RESTRICT rules for data consistency

๐Ÿš€ Deployment Architecture


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   USER DEVICES                          โ”‚
โ”‚         (Desktop | Tablet | Mobile)                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ HTTPS
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   GitHub Pages             โ”‚
โ”‚   (Static Frontend)        โ”‚
โ”‚   โœ“ HTML/CSS/JavaScript    โ”‚
โ”‚   โœ“ CDN Delivery           โ”‚
โ”‚   โœ“ SSL Certificate        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ REST API (HTTPS)
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Render.com               โ”‚
โ”‚   (Backend API)            โ”‚
โ”‚   โœ“ Flask Application      โ”‚
โ”‚   โœ“ Gunicorn Server        โ”‚
โ”‚   โœ“ Auto Deploy from Git   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ MySQL Connection
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Clever Cloud             โ”‚
โ”‚   (MySQL Database)         โ”‚
โ”‚   โœ“ Managed MySQL 8.4      โ”‚
โ”‚   โœ“ Automatic Backups      โ”‚
โ”‚   โœ“ 256MB Free Tier        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


๐Ÿ“ฆ Installation & Setup

Prerequisites

  • Python 3.9 or higher
  • MySQL 8.0 or higher
  • Git
  • Modern web browser

Local Development Setup

1. Clone the Repository

git clone [https://github.com/goldlion123rp/Library_DBMS.git](https://github.com/goldlion123rp/Library_DBMS.git)
cd Library_DBMS

2. Backend Setup

# Navigate to backend folder
cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows PowerShell:
venv\Scripts\Activate.ps1
# Windows CMD:
venv\Scripts\activate.bat
# Mac/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

3. Database Setup

# Using MySQL Command Line
mysql -u root -p

# Create database
CREATE DATABASE LibraryDB;
exit;

# Import schema
mysql -u root -p LibraryDB < ../database/schema.sql

# Or use phpMyAdmin:
# 1. Open http://localhost/phpmyadmin
# 2. Create database "LibraryDB"
# 3. Import database/schema.sql

4. Configure Environment Variables

Create backend/.env file:

DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=LibraryDB
DB_PORT=3306
SECRET_KEY=your-secret-key-here
DEBUG=True
CORS_ORIGINS=*

5. Run Backend Server

# Make sure venv is activated
python app.py

Backend will run on http://localhost:5000

Test backend:

# Visit in browser
http://localhost:5000
# Should show JSON response

6. Run Frontend

# Open new terminal
# Navigate to project root
cd Library_DBMS

# Start HTTP server
python -m http.server 8000

Frontend will run on http://localhost:8000

7. Access Application


๐ŸŒ Production Deployment

For complete deployment guide, see DEPLOYMENT.md

Quick Deployment Summary

Database (Clever Cloud)

  1. Create free MySQL add-on at https://clever-cloud.com
  2. Get database credentials
  3. Import database/schema_cloud.sql via phpMyAdmin
  4. Note connection details for backend

Backend (Render.com)

  1. Sign up at https://render.com
  2. Connect GitHub repository
  3. Create Web Service:
    • Root Directory: backend
    • Build Command: pip install -r requirements.txt
    • Start Command: gunicorn app:app
  4. Add environment variables (DB credentials)
  5. Deploy and get backend URL

Frontend (GitHub Pages)

  1. Push code to GitHub
  2. Go to repository Settings โ†’ Pages
  3. Source: main branch, / (root) folder
  4. Update js/config.js with backend URL
  5. Site will be live at https://username.github.io/repo-name/

๐Ÿ“ˆ Features Overview

Dashboard

  • Statistics Cards: Total books, members, active loans, overdue books
  • Books by Category: Visual breakdown with progress bars
  • Recent Loan Activity: Real-time transaction feed
  • Financial Summary: Unpaid fines and counts
  • Quick Actions: Navigate to key modules

Books Module

  • Add Books: ISBN, title, author, category, location, quantity, price
  • Edit Books: Update all book details and inventory
  • Delete Books: With validation (prevent deletion of loaned books)
  • Search & Filter: By title, author, ISBN, or category
  • Category Management: Automatic category detection
  • Availability Status: Real-time quantity tracking

Members Module

  • Register Members: Membership number, name, contact, join date
  • Edit Members: Update member information
  • View History: Complete borrowing history per member
  • Status Tracking: Active/Inactive membership status
  • Search Members: By name, email, or membership number

Loans Module

  • Issue Books: Select book and member, auto-calculate due date
  • Return Books: Mark as returned, automatic fine calculation
  • Track Status: Issued, Returned, Overdue with visual indicators
  • Due Date Alerts: Highlight overdue items
  • Filter Options: By status (issued/returned/overdue)
  • Validation: Prevent issuing to members with overdue books

Fines Module

  • Auto-calculation: โ‚น5 per day for late returns
  • View All Fines: Paid and unpaid with details
  • Mark as Paid: Update payment status
  • Total Summary: Unpaid fines amount and count
  • Filter by Status: Paid/Unpaid filtering

Reports & Analytics

  • Top 10 Most Borrowed Books: Ranked by popularity
  • Top 10 Most Active Members: Based on borrowing frequency
  • Late Return Trends: Average late days per member
  • Monthly Statistics: Issues vs returns over time
  • Visual Insights: Charts and trend analysis

Staff Management (Admin Only)

  • Add Staff: Create new staff accounts with roles
  • Edit Staff: Update details and change roles
  • Delete Staff: With validation (prevent deletion of active issuers)
  • Role Assignment: Admin, Librarian, Assistant
  • Credential Management: Username and password setup

Security & Auditing

  • Login Audit Logs: New admin-only page to monitor all successful and failed login attempts.
  • Detailed Logging: Captures username, timestamp, IP address, user agent, and failure reason.
  • Security Dashboard: Displays stats like today's logins and failed attempts.
  • Role Protection: The new page is strictly for Admin users.

๐Ÿงช Testing

Manual Testing Checklist

  • โœ… User login (all three roles)
  • โœ… Dashboard statistics display
  • โœ… Book CRUD operations
  • โœ… Member CRUD operations
  • โœ… Issue and return books
  • โœ… Fine calculation accuracy
  • โœ… Search and filter functionality
  • โœ… Reports data accuracy
  • โœ… Staff management (Admin)
  • โœ… Responsive design on mobile
  • โœ… Hamburger menu functionality

API Testing

Test endpoints using browser or Postman:

# Health check
GET /

# Authentication
POST /api/auth/login
GET  /api/auth/verify

# Books
GET    /api/books
GET    /api/books/{id}
POST   /api/books
PUT    /api/books/{id}
DELETE /api/books/{id}

# Members
GET    /api/members
POST   /api/members
PUT    /api/members/{id}
DELETE /api/members/{id}

# Loans
GET  /api/loans
POST /api/loans/issue
PUT  /api/loans/{id}/return

# Fines
GET /api/fines
PUT /api/fines/{id}/pay
GET /api/fines/total

# Reports
GET /api/reports/dashboard
GET /api/reports/most-borrowed
GET /api/reports/active-members
GET /api/reports/monthly-stats

# Staff (Admin only)
GET    /api/staff
POST   /api/staff
PUT    /api/staff/{id}
DELETE /api/staff/{id}

๐Ÿ“š API Documentation

Base URLs

  • Production: https://library-dbms-1tp2.onrender.com/api
  • Local: http://localhost:5000/api

Authentication

All protected endpoints require authentication header:

Authorization: Bearer {token}

Login Audit (Admin Only)

  • GET /api/auth/login-logs - Get all login logs
  • GET /api/auth/login-stats - Get login statistics

Response Format

{
  "success": true,
  "data": { ... },
  "message": "Operation successful"
}

Error Format

{
  "success": false,
  "error": "Error message description"
}

๐Ÿ‘ฅ Team

Project Lead & Developer:

Team Contributors:

  • Subhadip Jana
  • Ajay Kumar Das
  • Pritam Maity
  • Santunu Mog

Institution: Brainware University
Department: Computer Science & Engineering
Course: DBMS Lab (PCC-CSG591)
Semester: 5
Academic Year: 2024-2025


๐Ÿ“ Project Structure

Library_DBMS/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py          # Authentication endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ books.py          # Book management
โ”‚   โ”‚   โ”œโ”€โ”€ members.py        # Member management
โ”‚   โ”‚   โ”œโ”€โ”€ loans.py          # Loan operations
โ”‚   โ”‚   โ”œโ”€โ”€ fines.py          # Fine management
โ”‚   โ”‚   โ”œโ”€โ”€ reports.py        # Analytics & reports
โ”‚   โ”‚   โ””โ”€โ”€ staff.py          # Staff management
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ helpers.py        # Helper functions
โ”‚   โ”œโ”€โ”€ app.py                # Main Flask application
โ”‚   โ”œโ”€โ”€ config.py             # Configuration settings
โ”‚   โ”œโ”€โ”€ database.py           # Database connections
โ”‚   โ””โ”€โ”€ requirements.txt      # Python dependencies
โ”œโ”€โ”€ database/
โ”‚   โ”œโ”€โ”€ schema.sql            # Local database schema
โ”‚   โ””โ”€โ”€ schema_cloud.sql      # Cloud deployment schema
โ”œโ”€โ”€ css/
โ”‚   โ””โ”€โ”€ style.css             # Complete styling with responsive design
โ”œโ”€โ”€ js/
โ”‚   โ”œโ”€โ”€ config.js             # API configuration
โ”‚   โ”œโ”€โ”€ auth.js               # Authentication logic
โ”‚   โ”œโ”€โ”€ mobile.js             # Mobile hamburger menu โญ NEW
โ”‚   โ”œโ”€โ”€ dashboard.js          # Dashboard functionality
โ”‚   โ”œโ”€โ”€ books.js              # Book operations
โ”‚   โ”œโ”€โ”€ members.js            # Member operations
โ”‚   โ”œโ”€โ”€ loans.js              # Loan operations
โ”‚   โ”œโ”€โ”€ fines.js              # Fine operations
โ”‚   โ”œโ”€โ”€ reports.js            # Reports & analytics
โ”‚   โ””โ”€โ”€ staff.js              # Staff management
โ”œโ”€โ”€ index.html                # Login page
โ”œโ”€โ”€ dashboard.html            # Dashboard
โ”œโ”€โ”€ books.html                # Books module
โ”œโ”€โ”€ members.html              # Members module
โ”œโ”€โ”€ loans.html                # Loans module
โ”œโ”€โ”€ login-logs.html           # Login audit log page โญ NEW
โ”œโ”€โ”€ fines.html                # Fines module
โ”œโ”€โ”€ reports.html              # Reports module
โ”œโ”€โ”€ staff.html                # Staff module
โ”œโ”€โ”€ favicon.svg               # Favicon
โ”œโ”€โ”€ .gitignore                # Git ignore rules
โ”œโ”€โ”€ README.md                 # This file
โ”œโ”€โ”€ DEPLOYMENT.md             # Deployment guide
โ””โ”€โ”€ LICENSE                   # MIT License

โš ๏ธ Known Issues & Limitations

Free Tier Limitations

Backend (Render.com):

  • โฑ๏ธ Spins down after 15 minutes of inactivity
  • โฑ๏ธ First request takes 30-60 seconds to wake up
  • โฑ๏ธ Subsequent requests are fast (normal speed)
  • ๐Ÿ’ก Solution: Use UptimeRobot to ping every 5 minutes

Database (Clever Cloud):

  • ๐Ÿ’พ 256MB storage limit (~10,000+ records)
  • ๐Ÿ’พ Sufficient for small to medium libraries

GitHub Pages:

  • ๐Ÿ“„ Static files only (no backend processing)
  • ๐Ÿ“„ 100GB bandwidth/month

Browser Compatibility

  • โœ… Chrome 90+
  • โœ… Firefox 88+
  • โœ… Safari 14+
  • โœ… Edge 90+
  • โŒ IE11 not supported

Mobile Experience

  • โœ… Fully responsive on all devices
  • โœ… Touch-optimized controls
  • โœ… Hamburger navigation menu
  • โš ๏ธ Tables scroll horizontally on small screens due to large data content.

๐Ÿ”ฎ Future Enhancements

Planned Features

  • Email notifications for due dates and overdue books
  • QR code generation for books and membership cards
  • Book reservation system
  • Advanced analytics with interactive charts (Chart.js)
  • Export reports to PDF/Excel
  • Barcode scanner integration
  • Multi-language support (i18n)
  • Dark mode theme toggle
  • Progressive Web App (PWA) support
  • Real-time notifications with WebSocket

Technical Improvements

  • Implement JWT refresh tokens
  • Add unit tests (pytest)
  • API rate limiting
  • Database query optimization
  • Implement caching (Redis)
  • Add API versioning
  • Implement logging system
  • Add data backup automation

Mobile App

  • React Native mobile application
  • Offline mode support
  • Push notifications
  • Biometric authentication

AI/ML Features

  • Book recommendation system
  • Demand prediction
  • Automatic categorization
  • Chatbot support

๐Ÿค Contributing

This is an academic project, but suggestions and feedback are welcome!

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8 for Python code
  • Use meaningful variable names
  • Comment complex logic
  • Write descriptive commit messages

๐Ÿ“„ License

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

Third-Party Licenses

  • Flask (BSD License)
  • Flask-CORS (MIT License)
  • PyMySQL (MIT License)
  • Gunicorn (MIT License)

๐Ÿ™ Acknowledgments

  • Brainware University - For the opportunity and academic support
  • Department of Computer Science & Engineering - For project guidance
  • Render.com - Free backend hosting platform
  • GitHub Pages - Free frontend hosting and CDN
  • Clever Cloud - Free MySQL database hosting
  • Stack Overflow Community - For troubleshooting assistance
  • MDN Web Docs - For web development references

๐Ÿ“ž Contact & Support

Developer: Rahul Pal
Email: goldlion123.rp@gmail.com
GitHub: @goldlion123rp
Project Link: https://github.com/goldlion123rp/Library_DBMS

Issues & Bug Reports

Found a bug? Open an issue

Questions?

Have questions? Check Discussions


๐ŸŒŸ Show Your Support

If you found this project helpful:

  • โญ Star this repository
  • ๐Ÿด Fork for your own use
  • ๐Ÿ“ข Share with others
  • ๐Ÿ’ฌ Provide feedback via issues
  • ๐Ÿค Contribute improvements

๐Ÿ“Š Project Stats


๐Ÿ† Achievements

  • โœ… Full-stack cloud deployment
  • โœ… RESTful API architecture
  • โœ… Normalized database design (3NF)
  • โœ… Role-based access control
  • โœ… Responsive mobile-first design
  • โœ… Production-ready application
  • โœ… Complete documentation
  • โœ… Open-source contribution

Made with โค๏ธ by Rahul Pal & Team

Brainware University | Department of CSE | 2024-2025

๐ŸŒ Live Demo โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ› Report Bug โ€ข โœจ Request Feature


โญ If this project helped you, please give it a star! โญ