A production-structured RESTful Bookstore API built using Node.js and Express. This project demonstrates correct REST design principles, OpenAPI documentation, automated API testing, CI/CD automation, structured logging, and basic monitoring.
This project was developed incrementally to simulate a real backend modernization process. The objective was to transform a minimal API into a structured, testable, and deployable backend service.
Core goals achieved:
- REST-compliant resource design
- Consistent HTTP status code usage
- OpenAPI 3.0 documentation
- Automated Postman testing
- Continuous Integration (CI)
- Continuous Delivery (CD)
- Structured logging
- Basic monitoring endpoints
- Runtime: Node.js
- Framework: Express.js
- Data Store: In-memory (array-based)
- Documentation: OpenAPI + Swagger UI
- Testing: Postman + Newman
- CI/CD: GitHub Actions
- Deployment: Render
- Logging: Winston (structured JSON)
- Monitoring: Health + Metrics endpoints
Implemented a minimal Express server with in-memory storage.
Endpoints:
- GET /books → List all books
- POST /books → Create a book
- GET /books/:id → Retrieve a book
- PUT /books/:id → Update a book
- DELETE /books/:id → Delete a book
- GET /authors → List unique authors
Books are stored in memory using a simple array. Authors are dynamically derived from books to avoid maintaining a separate author store.
Integrated OpenAPI 3.0 specification via openapi.yaml.
Interactive documentation available at:
http://localhost:3000/docs
Documentation includes:
- Endpoint definitions
- Request/response schemas
- Required fields
- HTTP status codes
- Error responses
Created a Postman collection covering:
- Full CRUD lifecycle (Create → Retrieve → Update → Delete)
- Validation error handling
- Status code verification
Collection exported as:
postman_collection.json
Newman CLI added for automation:
npm install --save-dev newman
Package.json scripts:
"scripts": {
"start": "node server.js",
"test": "newman run postman_collection.json"
}Run tests locally:
npm test
GitHub Actions workflow:
.github/workflows/ci.yml
Pipeline stages:
- Checkout repository
- Install dependencies
- Start server
- Execute Postman tests using Newman
- Fail build if any test fails
Triggers:
- Push to
main - Pull requests targeting
main
Deployment automated using Render deploy hook.
Deployment runs only if:
- All CI tests pass
- Commit is pushed to
main
Secure deployment configured via GitHub Secrets.
Integrated Winston for structured JSON logging.
Features:
- Timestamped log entries
- Request lifecycle logging
- Error logging
- Console and file output (
app.log)
Each request logs:
- HTTP method
- Request URL
- Status code
- Response time
Added internal monitoring endpoints.
GET /health
Returns:
- Service status
- Uptime
- Timestamp
GET /metrics
Returns:
- Total request count
- Uptime (seconds)
- Memory usage
- CPU usage
Provides lightweight observability without external monitoring tools.
Base URL:
https://readify-bookstore-deh9.onrender.com
Swagger Documentation:
https://readify-bookstore-deh9.onrender.com/docs
Health Check:
https://readify-bookstore-deh9.onrender.com/health
Metrics Endpoint:
https://readify-bookstore-deh9.onrender.com/metrics
Clone repository:
git clone <repository-url>
cd readify-bookstore
Install dependencies:
npm install
Start server:
npm start
Server runs at:
http://localhost:3000
curl -X POST http://localhost:3000/books \
-H "Content-Type: application/json" \
-d '{"title":"Clean Code","author":"Robert Martin"}'
curl http://localhost:3000/books
curl http://localhost:3000/books/1
curl -X PUT http://localhost:3000/books/1 \
-H "Content-Type: application/json" \
-d '{"title":"Updated Title","author":"Updated Author"}'
curl -X DELETE http://localhost:3000/books/1
curl http://localhost:3000/authors
curl http://localhost:3000/health
curl http://localhost:3000/metrics
The GitHub Actions pipeline performs:
- Dependency installation
- Server startup
- Automated Postman test execution
- Conditional deployment to Render
This ensures:
- Regression prevention
- Build reliability
- Automated delivery
Structured logging implemented using Winston.
Log outputs:
- Console
app.logfile
Logs are formatted as JSON for compatibility with log aggregation systems.
- RESTful design with consistent URI structure
- Automated API validation
- Documented contract via OpenAPI
- Continuous integration and deployment
- Structured request logging
- Basic operational monitoring