Professional Node.js REST API for managing notes with comprehensive testing and interview-ready architecture
A production-quality CRUD API built with Express.js, featuring comprehensive input validation, error handling, and a robust test suite. Designed to demonstrate senior-level backend engineering skills.
- Complete CRUD Operations - Create, read, update, and delete notes
- Professional Architecture - Clean separation of concerns with layered design
- Comprehensive Validation - Input sanitization and detailed error messages
- Robust Error Handling - Proper HTTP status codes and structured responses
- High Test Coverage - 95%+ coverage with 46 comprehensive test cases
- Code Quality - ESLint integration with consistent coding standards
- In-Memory Storage - No external dependencies, perfect for demos
- CORS Support - Ready for frontend integration
- Health Monitoring - Built-in health check endpoint
- Node.js β₯18.0.0
- npm β₯8.0.0
# Clone the repository
git clone <repository-url>
cd notes-crud-api
# Install dependencies
npm install
# Start the server
npm startThe API will be available at http://localhost:3000
# Start with auto-reload
npm run dev| Command | Description |
|---|---|
npm start |
Start the production server |
npm run dev |
Start development server with auto-reload |
npm test |
Run the complete test suite |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Run tests with coverage report |
npm run lint |
Check code quality with ESLint |
npm run lint:fix |
Fix ESLint issues automatically |
http://localhost:3000
| Method | Endpoint | Description | Status Codes |
|---|---|---|---|
POST |
/notes |
Create a new note | 201, 400 |
GET |
/notes |
Retrieve all notes | 200 |
GET |
/notes/:id |
Retrieve a specific note | 200, 404 |
PUT |
/notes/:id |
Update a note | 200, 400, 404 |
DELETE |
/notes/:id |
Delete a note | 200, 404 |
GET |
/health |
Health check | 200 |
curl -X POST http://localhost:3000/notes \
-H "Content-Type: application/json" \
-d '{
"title": "Meeting Notes",
"content": "Discuss project timeline and deliverables"
}'Response (201 Created):
{
"success": true,
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Meeting Notes",
"content": "Discuss project timeline and deliverables",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"message": "Note created successfully"
}curl http://localhost:3000/notesResponse (200 OK):
{
"success": true,
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Meeting Notes",
"content": "Discuss project timeline and deliverables",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
],
"count": 1,
"message": "Notes retrieved successfully"
}curl http://localhost:3000/notes/123e4567-e89b-12d3-a456-426614174000curl -X PUT http://localhost:3000/notes/123e4567-e89b-12d3-a456-426614174000 \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Meeting Notes",
"content": "Discuss project timeline, deliverables, and budget"
}'curl -X DELETE http://localhost:3000/notes/123e4567-e89b-12d3-a456-426614174000{
"success": false,
"error": "Validation Error",
"message": "Title is required and must be a non-empty string"
}{
"success": false,
"error": "Not Found",
"message": "Note not found"
}The project maintains 95%+ code coverage with comprehensive test scenarios:
- 46 test cases covering all CRUD operations
- Validation testing for all input scenarios
- Error handling for edge cases and failures
- Integration testing for middleware and server functionality
- Boundary testing for limits and constraints
# Run all tests
npm test
# Run with coverage report
npm run test:coverage
# Run tests in watch mode
npm run test:watch# Check code quality
npm run lint
# Auto-fix issues
npm run lint:fixSee TESTING.md for detailed testing documentation and philosophy.
A complete demo script is provided to showcase all API functionality:
# Make the script executable
chmod +x demo.sh
# Run the complete demo (requires server to be running)
./demo.shThe demo script demonstrates:
- Health check
- Creating multiple notes
- Retrieving all notes
- Getting a specific note
- Updating a note
- Deleting a note
- Error handling scenarios
notes-crud-api/
βββ src/
β βββ app.js # Express application setup
β βββ server.js # Server startup and configuration
β βββ middleware/ # Custom middleware
β β βββ errorHandler.js # Global error handling
β β βββ validateNote.js # Input validation
β βββ models/ # Data models
β β βββ Note.js # Note entity
β βββ routes/ # API route definitions
β β βββ notes.js # Notes CRUD endpoints
β βββ services/ # Business logic
β βββ notesService.js # Notes service layer
βββ tests/ # Test suites
β βββ notes.test.js # API endpoint tests
β βββ server.test.js # Server integration tests
β βββ setup.js # Test configuration
βββ demo.sh # Complete API demo script
βββ TESTING.md # Testing documentation
βββ README.md # This file
- Layered Architecture - Clear separation between routes, services, and models
- Error-First Design - Comprehensive error handling at every layer
- Validation-First - Input validation before processing
- Test-Driven Quality - High test coverage with meaningful assertions
- Professional Standards - ESLint, consistent naming, proper HTTP codes
This project demonstrates:
- β RESTful API design with proper HTTP methods and status codes
- β Comprehensive input validation and error handling
- β Professional project structure and code organization
- β High test coverage (95%+) with meaningful test cases
- β Code quality enforcement with ESLint
- β Modern Node.js and Express.js best practices
- β Layered architecture with separation of concerns
- β Middleware pattern for cross-cutting concerns
- β Service layer abstraction for business logic
- β Comprehensive error handling strategy
- β Professional testing methodology
- β Clean, maintainable, and scalable code
- β Environment-based configuration
- β Proper logging and monitoring (health check)
- β CORS support for frontend integration
- β Input sanitization and validation
- β Graceful error responses
- β Documentation and demo scripts
- Runtime: Node.js 18+
- Framework: Express.js 4.18+
- Testing: Jest 29+ with Supertest
- Code Quality: ESLint 8+
- UUID Generation: uuid 9+
- CORS: cors 2.8+
This project is licensed under the MIT License - see the LICENSE file for details.
This is a portfolio/interview demonstration project. For suggestions or improvements, please open an issue or submit a pull request.
Built with β€οΈ for demonstrating senior backend engineering skills