This is a full-stack library management system API and admin dashboard. The platform handles standard library operations including cataloging books, importing book data from external sources like the Open Library API, managing library members, tracking book issues and returns, and detecting overdue checkouts. It provides real-time updates via WebSockets and extensive data quality reporting.
- Backend: Node.js, Express.js
- Database: MySQL
- Frontend: React, Vite, Lucide Icons
- Real-time: Socket.IO
- Authentication: JWT (HttpOnly cookies)
.
├── backend/ # Express API server
│ ├── src/
│ │ ├── config/ # Database and environment configurations
│ │ ├── controllers/ # Route handlers and business logic
│ │ ├── middlewares/ # JWT auth and error handling
│ │ ├── models/ # MySQL database queries
│ │ ├── routes/ # Express route definitions
│ │ ├── services/ # External integrations (e.g. Open Library API)
│ │ └── server.js # Entry point
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI elements
│ │ ├── pages/ # View components (Dashboard, MyLibrary, etc.)
│ │ ├── utils/ # Helper functions for export and formatting
│ │ └── App.jsx # Main React component routing
├── database/ # SQL schemas and migration scripts
│ └── schema.sql # Core database table definitions
└── README.md # Project documentation
- Ensure MySQL is installed and running on your local machine.
- Create a new database for the project (e.g.,
library_db). - Run the schema script to initialize all required tables:
mysql -u root -p library_db < database/schema.sql - Verify that tables for users, members, books, authors, subjects, and issues have been created successfully.
-
Clone the repository
git clone <your-repo-url> cd library-api-project
-
Install Backend Dependencies
cd backend npm install -
Configure Environment Variables Create a
.envfile in thebackend/directory using the provided examples. You will need:PORT=5000 DB_HOST=localhost DB_USER=root DB_PASSWORD=your_password DB_NAME=library_db JWT_SECRET=your_jwt_secret JWT_REFRESH_SECRET=your_refresh_secret
-
Install Frontend Dependencies
cd ../frontend npm install -
Run the Application Open two terminal windows:
Terminal 1 (Backend):
cd backend npm run devTerminal 2 (Frontend):
cd frontend npm run dev
POST /api/auth/login- Authenticate user and receive tokensGET /api/auth/me- Get current authenticated user profilePOST /api/auth/refresh- Refresh access token via HttpOnly cookiePOST /api/auth/logout- Invalidate tokens and log out
GET /api/dashboard/stats- Retrieve aggregate statistics for the admin dashboard
GET /api/books/catalog- Get paginated library catalogGET /api/books/search- Search books by textGET /api/books/work/:workKey- Get specific book detailsGET /api/books/work/:workKey/editions- Get editions for a specific workPOST /api/books/existing-works- Check existence of multiple worksGET /api/books/languages- List all book languagesGET /api/books/subjects- List all book subjectsGET /api/books/authors- List all authorsPOST /api/books/author/:id- Update an author recordPOST /api/books/publishYear/:id- Update the publish year for a bookGET /api/books/:bookId/review- Get reviews for a specific bookPOST /api/books/:bookId/review- Add a reviewPATCH /api/books/:bookId/review- Update a reviewDELETE /api/books/delete/:id- Delete a specific bookDELETE /api/books/clear- Clear all books from the library (with transaction safety)
POST /api/import/:workKey- Import a single book from external catalogPOST /api/import/batch- Import multiple booksPOST /api/import/selected- Import specific selected booksGET /api/import/jobs- View history of import jobsGET /api/import/jobs/:jobId- View specific job statusGET /api/import/jobs/:jobId/logs- View system logs for an import jobGET /api/import/jobs/:jobId/items- View individual items processed in a job
GET /api/data-quality- Identify records with missing or malformed fieldsGET /api/report/report- Generate summary reporting dataGET /api/export/books- Export book catalog as CSVGET /api/export/authors- Export authors as CSVGET /api/export/subjects- Export subjects as CSVGET /api/export/languages- Export languages as CSVGET /api/export/books/author/:authorId- Export all books by a specific authorGET /api/export/books/subject/:subjectId- Export all books under a specific subject
GET /api/inventory/author- Search inventory by authorGET /api/inventory/language- Search inventory by languageGET /api/inventory/title- Search inventory by titleGET /api/inventory/subject- Search inventory by subject