Module5-HomePage-New
Module 5 builds upon the JavaScript skills you learned in Module 4 and introduces server-side JavaScript using Node.js, along with real-time communication using Socket.IO.
Contents
Reading
The following articles on the class wiki contain information that will help you complete the assignments:
---
Individual Assignments
Install Node.js
Install Node.js using the instructions in the Node.JS guide (use the current LTS version via nvm).
Verify installation:
node -v
npm -v
---
Static File Server in Node.js
The individual portion is intentionally short so you have sufficient time for the group project.
Follow these steps carefully.
- Copy the static file server example from the Node.JS page into a file named
app.js. Save it on your EC2 instance in a directory that is NOT served by Apache. - Ensure that you understand what the static file server script is doing.
- Create a directory parallel to
app.jsnamedpublic. - Confirm that your server’s
STATIC_DIRvariable matches this directory name. - Create the following files inside the
publicdirectory:hello.txt— a text file containing: Hello Worldbrookings.jpg— download from: http://classes.engineering.wustl.edu/cse330/content/brookings.jpgcollege.html— an HTML page based on the Quick and Easy HTML Layout that includes an<img>referencingbrookings.jpgphpinfo.php— a PHP file containing:
<?php phpinfo(); ?>
- Start your Node.js server and load all four files in your browser.
Questions to consider:
- Which files work and which do not?
- Why does
phpinfo.phpbehave differently when served by Node instead of Apache?
---
Group Project: Multi-Room Chat Server
In the group portion of Module 5, you will build a multi-room chat system using Node.js and Socket.IO.
The system must include:
- A main lobby where users select a nickname
- Ability to create chat rooms
- Ability to join chat rooms
- A list of available rooms
- A list of users currently in the room
- The entire application displayed on a single webpage
The single-room example is provided here:
---
AI Agent Extension
You will enhance your chat server with an AI assistant.
Users can message the AI by typing:
\agent What is the capital of France?
The server detects messages that begin with \agent, sends the prompt to an AI model, and broadcasts the response as Agent in the same room.
You may use:
- Ollama (recommended — runs locally and free)
- OpenAI
- Gemini
- HuggingFace
- Any approved model
If using an API, store your key in a file named .env at the root of your project:
OPENAI_API_KEY=your_key_here
Load it securely in your server:
import 'dotenv/config';
Refer to your chosen model’s documentation for setup details.
---
Grading
Assignments must be committed to GitHub by the end of class on the due date.
The TA must be able to clone your repository and run your server without creating directories or copying files.
---
Individual Portion (30 Points)
- Node.js installed and working (5 pts)
Screenshot: EC2 serving college.html on port 3456 (URL visible)
hello.txt,brookings.jpg,college.htmlload successfully (4 pts each)- Visiting a nonexistent file returns 404 (4 pts)
- Explain in README why
phpinfo.phpbehaves differently under Node (4 pts) - All files pushed to GitHub
- Completion of AI Reflection (5 pts)
---
Multi-room Chat Server (55 Points)
Room Administration (25 pts)
- Create chat rooms (5)
- Join rooms (5)
- Display users in room (5)
- Private/password room (5)
- Kick users (3)
- Ban users (2)
Messaging (5 pts)
- Messages show username and broadcast to room (1)
- Private messaging (4)
AI Agent (15 pts)
\agentcommand works (10)- Handles errors gracefully without crashing (5)
Best Practices (5 pts)
- Clean, readable code (2)
- Valid HTML (2)
node_modulesignored by version control (1)
Usability (5 pts)
- Easy and intuitive interaction (4)
- Visually appealing (1)
AI Reflection (5 pts)
---
Creative Portion (10 Points)
Add a meaningful feature beyond requirements.