Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Lab Assignment 1 – Smart Utility Toolkit

Node.js Version Build Status Dependencies

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.


📐 Repository Structure

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

⚡ Core Features & Modules

1. CLI Calculator (calculator.js)

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 8

2. Custom Modules & Reusability (app.js & modules/)

Demonstrates 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"

3. Native HTTP Server (server.js)

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.js

4. File Manager & Execution Flow (fileManager.js)

Performs 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 demo

5. Cryptographic Dice Generator (dice.js)

Generates 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 Compliance

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages