A RESTful API for managing a Bookstore, built using Node.js and Express.js with MongoDB as the database. This API handles user authentication and CRUD operations for books with filtering and search capabilities.
- Register: Create a new user account
- Login: Authenticate and receive a JWT token
- Logout: Invalidate user session (handled on frontend/client)
- All book routes are protected and require a valid token
- Create a new book
- Get all books
- Get a book by ID
- Update a book by ID
- Delete a book by ID
- Filter books by author, category, rating
- Search books by title
- Returns proper HTTP status codes for errors
- Validates input data using middleware
- Backend: Node.js + Express.js
- Database: MongoDB (Mongoose ODM)
- Authentication: JWT
- Environment Variables:
dotenv
Zynetic-Backend/
│
├── controllers/ # Request handlers
├── models/ # Mongoose schemas
├── routes/ # Auth and Book routes
├── middleware/ # Auth middleware
├── db/ # MongoDB connection
├── .env # Environment variables
├── server.js # Entry point
└── frontend/ # Vite + React frontend (in subfolder)
Base URL:
http://localhost:4000/api
POST /api/auth/register - Register user
POST /api/auth/login - Login and get token
POST /api/auth/logout - Logout user
POST /api/books/createbook - Add new book
GET /api/books/getbooks - Get all books
GET /api/books/getbook/:id - Get single book
PATCH /api/books/updatebook/:id - Update book
DELETE /api/books/deletebook/:id - Delete book
GET /api/books/filterbooks?author=xyz&rating=4 - Filter
GET /api/books/searchbooks?title=java - Search
-
Clone the Repo
git clone https://github.com/AnuragRaj11/Zynetic_-Backend.git cd Zynetic_-Backend -
Backend Setup
cd backend npm install -
Create
.envFilePORT=4000 MONGO=mongodb://localhost:27017/bookapi SECRET=your_jwt_secret_key_here
-
Run Backend
npm run dev
-
Frontend Setup
cd frontend npm install npm run dev
- Backend: Deployed to Render as web service (Node.js)
- Frontend: Deployed as static site using Vite + Render
- ✅ Modular folder structure
- ✅ JWT token authentication
- 🚧 Pagination & sorting (to be added)
- 🚧 Swagger/OpenAPI docs (optional)
- 🚧 Docker setup (optional)
- JWT token is stored in headers (
Authorization: Bearer <token>) - Logout is handled client-side by removing token
- Minimal frontend (React + Vite) for demonstration
Anurag Raj
GitHub: @AnuragRaj11