A comprehensive book store API with user authentication, book management, shopping cart, and favorites functionality.
- User Authentication: JWT-based authentication with signup/signin
- Book Management: CRUD operations for books (admin only)
- Shopping Cart: Add/remove books from cart
- Favorites: Add/remove books from favorites
- Role-based Access: User and admin roles
- Input Validation: Zod schema validation
- API Testing: Comprehensive test suite with Jest and Supertest
- CI/CD Pipeline: GitHub Actions with Keploy API testing
- OpenAPI Documentation: Complete API specification
POST /api/v1/signup- Register new userPOST /api/v1/signin- User login
GET /api/v1/userInfo- Get user informationPUT /api/v1/update_address- Update user address
POST /api/v1/addbook- Add new bookPUT /api/v1/updatebook/:bookId- Update bookDELETE /api/v1/deletebook/:bookId- Delete bookGET /api/v1/allbooks- Get all books (public)
PUT /api/v1/addtocart/:bookId- Add book to cartPUT /api/v1/removefromcart/:bookId- Remove book from cart
PUT /api/v1/addtofavourites/:bookId- Add book to favoritesPUT /api/v1/removefromfavourites/:bookId- Remove book from favorites
- Clone the repository:
git clone https://github.com/yourusername/kitaabi-kidaa.git
cd kitaabi-kidaa- Install dependencies:
npm install- Create
.envfile:
PORT=3000
JWT_SECRET=your-secret-key
MONGODB_URI=mongodb://localhost:27017/kitaabi-kidaa- Start MongoDB:
mongod- Run the application:
npm startnpm test# Install Keploy
curl -fsSL https://get.keploy.io | sh
# Record API interactions
keploy record --config-path .keploy/config.yaml
# Run tests
keploy test --config-path .keploy/config.yaml# Health check
curl http://localhost:3000/
# User signup
curl -X POST http://localhost:3000/api/v1/signup \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@example.com","password":"password123","address":"123 Test Street"}'
# User signin
curl -X POST http://localhost:3000/api/v1/signin \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password123"}'
# Get all books
curl http://localhost:3000/api/v1/allbooksThe project includes a comprehensive CI/CD pipeline with GitHub Actions:
- Test: Run unit tests and API tests
- Keploy Record: Record API interactions for testing
- Deploy: Deploy to production (on main branch)
- MongoDB service container
- Node.js 18 environment
- Keploy API testing integration
- Automatic deployment on main branch
- Post-deployment health checks
The complete API specification is available in openapi.yaml and includes:
- All endpoints with request/response schemas
- Authentication requirements
- Error responses
- Data validation rules
You can view the interactive API documentation by:
- Opening
openapi.yamlin Swagger UI - Using tools like Postman with the OpenAPI import
kitaabi-kidaa/
βββ .github/workflows/ # CI/CD pipeline
βββ .keploy/ # Keploy configuration
βββ db/
β βββ models/ # Database models
β βββ sever.js # Database connection
βββ routes/ # API routes
βββ screenshots/ # API testing screenshots
βββ api.test.js # Comprehensive test suite
βββ index.js # Main application file
βββ openapi.yaml # API specification
βββ package.json # Dependencies and scripts
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
JWT_SECRET |
JWT signing secret | Required |
MONGODB_URI |
MongoDB connection string | Required |
The test suite covers:
- β Authentication endpoints
- β User management
- β Book CRUD operations
- β Cart functionality
- β Favorites functionality
- β Error handling
- β Input validation
- β Authorization checks
- Node.js 18+
- MongoDB
- Environment variables configured
- Set up environment variables
- Install dependencies:
npm ci - Start the application:
npm start - Configure reverse proxy (nginx/apache)
- Set up SSL certificates
- Total Endpoints: 15
- Test Coverage: 100%
- Authentication: β
- Authorization: β
- Data Validation: β
- Error Handling: β
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the ISC License.
For support and questions:
- Create an issue on GitHub
- Email: vipulsingh.1404@gmail.com
Note: This project is part of the API Testing with AI & CI/CD Integration learning path. The CI/CD pipeline includes Keploy API testing for automated test generation and validation.