This project is a full-stack web application designed to manage a library's inventory of books. It allows users to browse, borrow, and return books, and administrators to manage the library's collection and users. The project is built using React for the frontend and Node.js with Express for the backend. MongoDB is used as the database, and Firebase handles authentication.
- User authentication (sign up, sign in, sign out) using Firebase
- Role-based access control for users and administrators
- Book inventory management (CRUD operations)
- Borrowing and returning books
- Viewing borrowed book history
- Search functionality for books by title, author, and genre
The project is divided into two main parts: the frontend and the backend.
Located in the frontend
directory, this part of the project is built with React and includes the following:
- Components: Reusable UI elements like Navbar, Book Cards, etc.
- Pages: Different views such as Home, SignIn, SignUp, and Admin Portal.
- Context: State management using React Context API for user and book states.
- Styles: CSS files for styling components.
Located in the backend
directory, this part of the project is built with Node.js and Express and includes the following:
- Routes: Defines the API endpoints for books and users.
- Controllers: Contains the logic for handling requests and responses.
- Models: Defines the data schema for MongoDB using Mongoose.
- Middleware: Functions for authentication and error handling.
- Utilities: Helper functions such as token generation and email sending.
-
Clone the repository:
git clone https://github.com/dipto-kainin/react-library-management
-
Install dependencies for both frontend and backend:
//for backend npm install
//for frontend cd ../frontend npm install
-
Set up environment variables:
- Create a
.env
file in theroot
directory with the following variables:
PORT=your_port_number FRONTEND=your_frontend_url MONGO_URI=your_mongodb_uri JWT_SECRET=your_jwt_secret JWT_EXPIRES_IN=your_jwt_expiration_time EMAIL=your_email PASSWORD=your_email_password(app password not actual password) apiKey=your_firebase_api_key authDomain=your_firebase_auth_domain projectId=your_firebase_project_id storageBucket=your_firebase_storage_bucket messagingSenderId=your_firebase_messaging_sender_id appId=your_firebase_app_id NODE_ENV=your_node_environment
- Create a
-
Start the backend server:
npm start
-
Start the frontend development server:
cd frontend npm start
-
Open your browser and navigate to
http://localhost:3000
to use the application.
POST /api/users/signup
: Register a new userPOST /api/users/signin
: Authenticate a userGET /api/users/profile
: Get user profile (protected)PUT /api/users/profile
: Update user profile (protected)- ...and many more
GET /api/books
: Get all booksPOST /api/books
: Add a new book (admin)GET /api/books/:id
: Get a book by IDPUT /api/books/:id
: Update a book by ID (admin)DELETE /api/books/:id
: Delete a book by ID (admin)- ...and many more
- Frontend: React, React Router, Context API
- Backend: Node.js, Express, Mongoose
- Database: MongoDB
- Authentication: Firebase
- Others: JWT, CSS
Contributions are welcome! Please create an issue or submit a pull request for any enhancements or bug fixes.