A full-stack application for managing library operations, including book inventory, member registration, and book borrowing/returning processes.
The project is structured into two main directories:
backend/: Express.js application handling the REST API.frontend/: React application built with Vite for the user interface.
Before setting up the project, ensure you have the following installed on your machine:
- Node.js (v16.0.0 or higher recommended)
- MySQL Server
- Start your MySQL service.
- Create a new database named
library_db(or a name of your choice).CREATE DATABASE library_db;
- Create the necessary tables. The application uses the following tables:
users: (id, nama, email, password)books: (id, judul, penulis, tahun)loans: (id, user_id, book_id, tanggal_pinjam, tanggal_kembali, status)
- Navigate to the backend directory:
cd backend - Install the necessary dependencies:
npm install
- Create a
.envfile in thebackenddirectory based on your local database credentials:PORT=5000 DB_HOST=localhost DB_USER=root DB_PASS=your_mysql_password DB_NAME=library_db JWT_SECRET=supersecretkey_beginner_friendly_123
- Start the backend development server:
The backend server should now be running on
npm start
http://localhost:5000.
To set up an initial administrator account to log into the application using the front-end, run the provided utility script in the backend directory.
- Ensure your database is running and credentials are correct in the
.envfile. - In the
backenddirectory, run:This will create (or reset) the admin user with:node fix-admin.js
- Email:
admin@lib.com - Password:
admin123
- Email:
- Open a new terminal window/tab and navigate to the frontend directory:
cd frontend - Install the necessary dependencies:
npm install
- Start the frontend development server:
The frontend application should now be accessible. The terminal will output the local development URL, usually
npm run dev
http://localhost:5173.
- Navigate to the frontend URL in your browser.
- Log in using the admin configuration generated during the Administrator Setup step.
- Access the Dashboard to manage Users, Books, and Library Loans.