A complete Library Management System built with FastAPI (Python) backend and HTML/CSS/JavaScript frontend.
- β RESTful API architecture
- β SQLite database with SQLAlchemy ORM
- β Pydantic models for data validation
- β CORS enabled for frontend communication
- β Proper error handling and status codes
- β Well-organized folder structure
- β Pure HTML, CSS, and JavaScript (no frameworks)
- β Responsive and modern UI design
- β Separate pages for each operation
- β Dynamic data rendering with Fetch API
- β Real-time alerts and notifications
- β Clean and professional styling
- Add Books - Add new books with Book ID, Title, Author, Category, and Quantity
- View Books - Browse all available books with their current stock status
- Issue Books - Issue books to students with automatic quantity management
- Return Books - Process book returns and update inventory automatically
- Track Records - View all issued books and return history
Library_Management_System/
βββ backend/
β βββ main.py # FastAPI application with all endpoints
β βββ models.py # SQLAlchemy database models
β βββ schemas.py # Pydantic validation schemas
β βββ database.py # Database configuration
β βββ requirements.txt # Python dependencies
β βββ library.db # SQLite database (created automatically)
β
βββ frontend/
βββ index.html # Home page
βββ add-book.html # Add book page
βββ add-book.js # Add book JavaScript
βββ view-books.html # View books page
βββ view-books.js # View books JavaScript
βββ issue-book.html # Issue book page
βββ issue-book.js # Issue book JavaScript
βββ return-book.html # Return book page
βββ return-book.js # Return book JavaScript
βββ styles.css # Global CSS styles
Before you begin, ensure you have the following installed on your system:
- Python 3.8 or higher - Download Python
- pip (Python package manager) - Usually comes with Python
- Git - Download Git
- A modern web browser - Chrome, Firefox, Edge, or Safari
Follow these steps to get the Library Management System up and running on your local machine:
Open your terminal/command prompt and clone the repository:
git clone https://github.com/Prabhat9801/Library_Management_System.gitNavigate to the project directory:
cd Library_Management_Systemcd backendFor Windows:
python -m venv venv
venv\Scripts\activateFor macOS/Linux:
python3 -m venv venv
source venv/bin/activateYou should see (venv) in your terminal prompt, indicating the virtual environment is active.
Install all required Python packages:
pip install -r requirements.txtThis will install:
- FastAPI
- Uvicorn
- SQLAlchemy
- Pydantic
- python-multipart
Run the FastAPI server using Uvicorn:
uvicorn main:app --reloadExpected Output:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [xxxxx]
INFO: Started server process [xxxxx]
INFO: Waiting for application startup.
INFO: Application startup complete.
β
Backend is now running at: http://localhost:8000
π API Documentation available at: http://localhost:8000/docs
Note: Keep this terminal window open. The backend server must remain running for the frontend to work.
Open a new terminal/command prompt window (keep the backend server running in the previous terminal).
From the project root directory:
cd frontendYou have three options to run the frontend:
- Simply double-click on
index.htmlin thefrontendfolder - It will open in your default web browser
- Right-click on
index.html - Select "Open with" β Choose your preferred browser
For Windows:
start index.htmlFor macOS:
open index.htmlFor Linux:
xdg-open index.htmlFor a more production-like environment, you can use Python's built-in HTTP server:
python -m http.server 3000Then open your browser and navigate to: http://localhost:3000
- Open your browser and go to:
http://localhost:8000/docs - You should see the FastAPI interactive documentation (Swagger UI)
- Try the health check endpoint by clicking on
GET /β Try it out β Execute - You should receive a response with status 200
- The home page should load with a purple gradient header
- You should see navigation links: Home, Add Book, View Books, Issue Book, Return Book
- All navigation links should work without errors
-
Add a Book:
- Go to "Add Book" page
- Fill in: Book ID:
B001, Title:Python Programming, Author:John Doe, Category:Technology, Quantity:5 - Click "Add Book"
- You should see a success message
-
View Books:
- Go to "View Books" page
- You should see the book you just added in the table
-
Issue a Book:
- Go to "Issue Book" page
- Enter: Student Name:
Alice Smith, Book ID:B001, Issue Date: (today's date) - Click "Issue Book"
- The book quantity should decrease to 4
-
Return a Book:
- Go to "Return Book" page
- Find the issued book in the table
- Click "Return Book"
- The book quantity should increase back to 5
- Go to the terminal running the backend
- Press
Ctrl + C(Windows/Linux) orCmd + C(macOS)
- Simply close the browser tab
deactivateAfter the initial setup, you only need to:
-
Start Backend:
cd backend # Activate virtual environment (if using one) venv\Scripts\activate # Windows # or source venv/bin/activate # macOS/Linux # Start server uvicorn main:app --reload
-
Open Frontend:
- Double-click
frontend/index.htmlor use any method from Step 3.3
- Double-click
Library_Management_System/
βββ backend/
β βββ venv/ # Virtual environment (if created)
β βββ main.py # FastAPI application
β βββ models.py # Database models
β βββ schemas.py # Pydantic schemas
β βββ database.py # Database configuration
β βββ requirements.txt # Python dependencies
β βββ library.db # SQLite database (auto-created)
β
βββ frontend/
βββ index.html # Home page
βββ add-book.html # Add book page
βββ add-book.js # Add book logic
βββ view-books.html # View books page
βββ view-books.js # View books logic
βββ issue-book.html # Issue book page
βββ issue-book.js # Issue book logic
βββ return-book.html # Return book page
βββ return-book.js # Return book logic
βββ styles.css # Global styles
- Navigate to Add Book page
- Fill in the book details:
- Book ID (unique identifier, e.g., B001)
- Title
- Author
- Category
- Quantity
- Click Add Book
- You'll see a success message if the book is added
- Navigate to View Books page
- All books in the library will be displayed in a table
- You can see the availability status of each book
- Click Refresh Books to reload the data
- Navigate to Issue Book page
- Enter:
- Student Name
- Book ID (must exist in the library)
- Issue Date
- Click Issue Book
- The book quantity will automatically decrease
- View currently issued books in the table below
- Navigate to Return Book page
- Find the book in the "Books Pending Return" table
- Click the Return Book button
- Confirm the return
- The book quantity will automatically increase
- View the return history in the table below
POST /api/books/- Add a new bookGET /api/books/- Get all booksGET /api/books/{book_id}- Get a specific book
POST /api/issue/- Issue a book to a studentGET /api/issued-books/- Get all currently issued booksGET /api/all-issue-records/- Get all issue records (issued + returned)PUT /api/return/{issue_record_id}- Return a book
GET /- API health check
id- Primary key (auto-increment)book_id- Unique book identifier (string)title- Book titleauthor- Book authorcategory- Book categoryquantity- Available quantity
id- Primary key (auto-increment)student_name- Name of the studentbook_id- Foreign key to books tableissue_date- Date when book was issuedreturn_date- Date when book was returned (nullable)status- Status: "issued" or "returned"
- Modern Gradient UI - Beautiful purple gradient theme
- Responsive Design - Works on desktop, tablet, and mobile
- Smooth Animations - Hover effects and transitions
- Status Badges - Color-coded status indicators
- Loading States - Spinner animations while fetching data
- Alert System - Success/error notifications
- Clean Typography - Professional and readable fonts
- FastAPI - Modern Python web framework
- SQLAlchemy - SQL toolkit and ORM
- Pydantic - Data validation using Python type hints
- Uvicorn - ASGI server
- SQLite - Lightweight database
- HTML5 - Structure
- CSS3 - Styling with gradients and animations
- JavaScript (ES6+) - Logic and API communication
- Fetch API - HTTP requests
- The SQLite database (
library.db) is created automatically when you first run the backend - All data is stored locally in the database file
- The frontend uses the Fetch API to communicate with the backend
- CORS is enabled to allow cross-origin requests
- Form validation is implemented both on frontend and backend
- The system automatically manages book quantities when issuing/returning
- Make sure Python 3.8+ is installed
- Ensure all dependencies are installed:
pip install -r requirements.txt - Check if port 8000 is already in use
- Verify the backend server is running at http://localhost:8000
- Check browser console for error messages
- Ensure CORS is enabled in the backend (already configured)
- Delete
library.dbfile and restart the backend to create a fresh database - Check file permissions in the backend folder
To modify the project:
-
Backend changes: Edit files in the
backend/folder- The server will auto-reload if you used the
--reloadflag
- The server will auto-reload if you used the
-
Frontend changes: Edit HTML/CSS/JS files in the
frontend/folder- Simply refresh the browser to see changes
This project is created for educational purposes as part of a Software Development Life Cycle (SDLC) project.
This Library Management System was developed following the Iterative Development Model as part of understanding the phases of Software Development Life Cycle (SDLC):
- Requirements Gathering - Identified library management needs
- Design - Created database schema and API structure
- Development - Built backend and frontend incrementally
- Testing - Validated functionality and error handling
- Deployment - Local deployment with clear instructions
- Maintenance - Designed for easy updates and improvements
# Clone repository
git clone https://github.com/Prabhat9801/Library_Management_System.git
cd Library_Management_System
# Setup backend
cd backend
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
uvicorn main:app --reload
# Open frontend (in new terminal)
cd frontend
start index.html # Windows
open index.html # macOS
xdg-open index.html # Linux# Start backend
cd backend
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linux
uvicorn main:app --reload
# Open frontend
Double-click frontend/index.html- Frontend: Open
frontend/index.htmlin browser - Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- GitHub Repository: https://github.com/Prabhat9801/Library_Management_System
Built with β€οΈ using FastAPI and Vanilla JavaScript