A hands-on Node.js backend toolkit developed for Web Dev III (Node.js & Express Backend) Lab Assignment 1. This project demonstrates fundamental backend development concepts using Node.js Core Modules exclusively (process, http, fs, crypto, path), featuring command-line interaction, custom module export/import reusability, basic HTTP server routing, CRUD file operations, secure random generation, and execution flow analysis.
Note
A detailed technical explanation document detailing the architecture, execution flow analysis (sync vs async), core module mechanics, and command verification is available at assets/EXPLANATION.md.
smart-utility-toolkit/
├── calculator.js # CLI Calculator parsing process.argv inputs
├── app.js # Main entry point reusing custom modules (isEven & logger)
├── server.js # Native HTTP Web Server handling custom routes & 404s
├── fileManager.js # File CRUD operations (fs) & sync vs async execution demo
├── dice.js # Crypto-random dice roll generator with history logging
├── test.txt # Sample text file for file system testing
├── modules/
│ ├── isEven.js # Custom parity module exporting isEven
│ └── logger.js # Custom colorized ANSI logger with ISO timestamps
├── assets/
│ ├── Lab Assignment 1.pdf # Original assignment prompt document
│ └── EXPLANATION.md # Technical explanation & execution guide
└── README.md # Project documentation & quick-start guide
Calculates arithmetic operations directly from command-line arguments using process.argv.
- Supported Operations:
add,subtract,multiply,divide,modulo,power
# Example Commands
node calculator.js add 10 5
node calculator.js divide 100 4
node calculator.js power 2 8Demonstrates importing and reusing custom modules (isEven & logger) via require().
# Example Commands
node app.js 4 # Output: [SUCCESS] Number 4 is EVEN
node app.js 7 # Output: [SUCCESS] Number 7 is ODD
node app.js Hello # Output: [INFO] Input message: "Hello"Built using Node.js core http module listening on port 3000 (or configured PORT).
| Route | Response Description | HTTP Status |
|---|---|---|
GET / |
Welcome Home Page | 200 OK |
GET /about |
About Toolkit & Core Modules | 200 OK |
GET /contact |
Course Contact Details | 200 OK |
GET /* |
Custom 404 Error Page | 404 Not Found |
# Start Server
node server.jsPerforms file CRUD operations using Node.js fs (writeFile, readFile, appendFile, unlink). Includes an execution flow demonstration comparing synchronous vs. asynchronous event loop behavior.
# Interactive Commands
node fileManager.js create test.txt "Initial Content"
node fileManager.js read test.txt
node fileManager.js update test.txt "\nAppended Line"
node fileManager.js delete test.txt
# Run Execution Flow & Console Analysis Demo
node fileManager.js demoGenerates cryptographically secure dice rolls (numbers 1–6) using crypto.randomInt(). Automatically persists history logs to dice_history.txt.
# Roll single dice
node dice.js
# Roll dice 5 times in a loop
node dice.js 5| Rubric Criteria | Allocated Marks | Implementation Summary |
|---|---|---|
| Functionality | 1.5 Marks | Implemented CLI Calculator, Custom isEven module, Native HTTP server routing, fs CRUD File Manager, and crypto Random Dice Generator. |
| Code Structure & Modules | 0.5 Marks | Clean CommonJS modular architecture using module.exports and require() matching exact specified directory layout. |
| Clean Code & Output | 0.5 Marks | Colorized ANSI console logging, ISO timestamps, graceful error handling, and complete technical documentation. |
| Total | 2.5 Marks | Fully Satisfied |