This project is a backend system for managing an online bookstore. It allows customers to browse, search, and purchase books while providing functionality for inventory and customers management for admins.
- Testing: Unit and integration tests are run on GitHub Actions every time a commit is pushed.
- Continuous Deployment: Every successful push to the main branch triggers a deployment to fly.io.
- Roles: Two user roles are supported: customer and admin.
- Customer Authentication: Customers can register, log in, and update their profile information.
- Admin Management: Admins can manage customers' accounts.
- Add Books: Admins can add new books to the inventory via an API endpoint.
- Update Books: An endpoint is available for admins to update existing book details.
- Retrieve Books: Users can retrieve a list of books with filtering options; genre, author, and year.
- Add to Cart: Customers can add books to their shopping cart.
- Update Cart: Customers can update the quantity or remove items from their cart.
- Total Price Calculation: The total price of items in the cart is automatically calculated each time the cart is updated.
- Place Orders: Customers can place orders to checkout their carts.
- Inventory Deduction: The ordered quantity is deducted from the inventory upon order placement.
- Payment Gateway: Midtrans payment gateway is integrated to process order payments. Customers can pay using QRIS.
- Email Notification: Customers receive an email confirmation after placing an order.
- View and Manage Inventory: Admins can view and manage the current inventory.
- Validation and Error Handling: All API endpoints have proper validation and error handling.
- Sensitive Information: Sensitive information is securely encrypted.
- Logging: Important events and errors are logged with Morgan.
- Monitoring: Basic monitoring for API performance is implemented using Prometheus.
- Unit Tests: Important API endpoints (book and order) have unit tests.
- Integration Testing: Integration testing ensures components work together seamlessly.
The API documentation is available at Postman.
- Node.js and npm for server-side code.
- PostgreSQL for database.
- Midtrans for payment gateway.
- Postman for API documentation.
- fly.io for deployment.
- Clone the repository:
git clone https://github.com/mufidu/bookstore-api.git
cd bookstore-api
- Install dependencies:
npm install
- Set up the environment variables:
cp .env.example .env
- Set up the database:
NODE_ENV=development npx sequelize-cli db:migrate
- Start the server:
npm run dev
- The server will be running at
http://localhost:9000
.
The API is deployed on fly.io. The live version is available at https://bookstore-app.fly.dev.