A robust backend API for the BBook warehouse management system. This server provides secure endpoints for managing book inventory, user authentication, and sales tracking with JWT-based security and MongoDB integration.
- Features
- Technologies Used
- Prerequisites
- Installation
- Environment Variables
- API Endpoints
- Project Structure
- Book Inventory Management: Full CRUD operations for book inventory
- User Authentication: JWT-based secure authentication system
- User-specific Data: Personal book collections with user verification
- Inventory Tracking: Real-time quantity and sales tracking
- Review System: User review management functionality
- Secure APIs: Protected endpoints with token verification
- MongoDB Integration: Persistent storage with optimized queries
- Node.js: JavaScript runtime environment
- Express.js: Web application framework
- MongoDB: NoSQL database for storing book and user data
- JSON Web Token (JWT): Secure authentication and authorization
- dotenv: Environment variable management
- CORS: Cross-Origin Resource Sharing support
- body-parser: HTTP request body parsing middleware
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher)
- MongoDB Atlas account or local MongoDB installation
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/azizurrahman-zero/bbook_server-side.git cd bbook_server-side
-
Install dependencies:
npm install # or yarn install
-
Create a
.env
file in the root directory with your credentials:DB_User=your_mongodb_username DB_UPass=your_mongodb_password ACCESS_TOKEN_SECRET=your_jwt_secret_key PORT=5000
-
Start the server:
npm start # or for development npm run start-dev
-
The server will be running at
http://localhost:5000
Variable | Description |
---|---|
DB_User | MongoDB Atlas username |
DB_UPass | MongoDB Atlas password |
ACCESS_TOKEN_SECRET | Secret key for JWT token generation |
PORT | Server port (defaults to 5000) |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | / |
Server health check endpoint | No |
POST | /token |
Generate JWT access token | No |
GET | /books |
Get all books in inventory | No |
GET | /inventory/:id |
Get specific book by ID | No |
GET | /my-books |
Get user's personal book collection | Yes |
POST | /books |
Add a new book to inventory | No |
PUT | /inventory/:id |
Update book quantity and sales | No |
DELETE | /inventory/:id |
Delete a book from inventory | No |
GET | /user-reviews |
Get all user reviews | No |
bbook_server-side/
├── node_modules/
├── .env
├── .gitignore
├── index.js
├── package-lock.json
├── package.json
└── README.md