https://github.com/zn-rabby/book-shop-server
Welcome to The BookStack, a robust and scalable backend API designed to power an online bookstore. Built with TypeScript, Node.js, Express.js, and MongoDB, this API provides a secure and efficient foundation for managing books, users, orders, and more. Whether you're building a small bookshop or a large-scale e-commerce platform
https://github.com/zn-rabby/book-shop-server
express jwt mongose typeorm zod
Last synced: 2 months ago
JSON representation
Welcome to The BookStack, a robust and scalable backend API designed to power an online bookstore. Built with TypeScript, Node.js, Express.js, and MongoDB, this API provides a secure and efficient foundation for managing books, users, orders, and more. Whether you're building a small bookshop or a large-scale e-commerce platform
- Host: GitHub
- URL: https://github.com/zn-rabby/book-shop-server
- Owner: zn-rabby
- Created: 2025-01-24T13:48:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-25T17:09:18.000Z (about 1 year ago)
- Last Synced: 2025-10-13T12:33:57.918Z (8 months ago)
- Topics: express, jwt, mongose, typeorm, zod
- Language: TypeScript
- Homepage: https://book-shop-client-seven.vercel.app/
- Size: 260 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# **📚 The BookStack: Backend API for an Online Bookstore**
**The BookStack** is a **scalable, secure, and efficient** backend API for an online bookstore, built with **TypeScript, Node.js, Express.js, and MongoDB**. It provides robust features for managing books, users, orders, and authentication, making it ideal for e-commerce platforms.
🔗 **Live Demo (if deployed):** [https://book-shop-client-seven.vercel.app/](https://book-shop-client-seven.vercel.app/)
---
## **✨ Key Features**
✅ **Admin Dashboard**
- Add, update, and delete books.
- Manage users, roles, and permissions.
- Track orders and transactions.
✅ **User Features**
- Browse books with **search, filtering, and sorting**.
- Place orders & view order history.
✅ **Authentication & Security**
- **JWT-based authentication** (Access & Refresh Tokens).
- **Role-based access control** (Admin vs. User).
- Password hashing with **bcrypt.js**.
✅ **Order Management**
- Seamless order placement & tracking.
- Admin-controlled order processing.
✅ **Scalable & Maintainable**
- Built with **TypeScript** for type safety.
- **MongoDB** for flexible data storage.
- **RESTful API** design for easy integration.
---
## **⚡ Quick Setup**
### **Prerequisites**
- Node.js (v16+)
- MongoDB (local or cloud)
- Git (optional)
### **1. Clone the Repository**
```bash
git clone https://github.com/YourUsername/Book-Shop-Server.git
cd Book-Shop-Server
```
### **2. Install Dependencies**
```bash
npm install
```
### **3. Configure Environment Variables**
Create a `.env` file and add:
```env
NODE_ENV=development
PORT=5000
DATABASE_URL=mongodb+srv://:@cluster.mongodb.net/book-shop?retryWrites=true&w=majority
# Auth
JWT_ACCESS_SECRET=your_access_secret
JWT_REFRESH_SECRET=your_refresh_secret
JWT_ACCESS_EXPIRES_IN=1d
JWT_REFRESH_EXPIRES_IN=365d
# Bcrypt
BCRYPT_SALT_ROUNDS=12
```
### **4. Run the Application**
- **Development:** `npm run start:dev`
- **Production:** `npm run start`
---
## **🛠️ Technologies Used**
- **Backend:** Node.js, Express.js
- **Database:** MongoDB (Mongoose ODM)
- **Authentication:** JWT, bcrypt.js
- **Language:** TypeScript
- **Middleware:** CORS, express-validator
---
## **🚀 Deployment**
Deploy on:
- **Vercel**
- **Render**
- **AWS / Heroku**
---
## **📄 API Endpoints (Sample)**
| Method | Endpoint | Description |
|--------|----------------------|----------------------------|
| POST | `/api/auth/signup` | User registration |
| POST | `/api/auth/login` | User login |
| GET | `/api/books` | Fetch all books |
| POST | `/api/orders` | Place a new order |
| GET | `/api/users` (Admin) | Get all users (Admin-only)|
*(See full API docs in Swagger/Postman if available.)*
---
## **📞 Contact**
For questions or feedback:
✉️ **Email:** [mailto:zn.rabby@gmail.com](mailto:zn.rabby@gmail.com)
---
## **🔑 Development Steps**
1. **Project Setup:** `npm init -y` + TypeScript config.
2. **Database:** MongoDB schema design with Mongoose.
3. **Auth:** JWT implementation with refresh tokens.
4. **API Routes:** Books, Users, Orders.
5. **Error Handling:** Global middleware for errors.
6. **Deployment:** Configure for cloud hosting.
---
**Happy Coding!** 🚀📖
---