Difference between revisions of "Module 5"

From CSE330 Wiki
Jump to navigationJump to search
 
(148 intermediate revisions by 14 users not shown)
Line 1: Line 1:
−
THIS PAGE UNDER CONSTRUCTION
+
__NOTOC__
  
 +
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.
  
−
In Module 6, you will learn about python, a scripting language, and Django, a web framework.
+
== Reading ==
  
−
This article contains your assignments for Module 6.
+
The following articles on the class wiki contain information that will help you complete the assignments:
 +
 
 +
* [[Node.JS]]
 +
* [[Socket.IO]]
 +
* [[FAQ - Mod 5]]
  
 
== Individual Assignments ==
 
== Individual Assignments ==
  
−
Python tutorial
+
=== Install Node.js ===
−
Django tutorial
+
 
 +
Install Node.js using the instructions in the [[Node.JS]] guide (use the current LTS version via nvm).
 +
 
 +
=== 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 <code>app.js</code>. 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 <code>app.js</code> named <code>static</code>.
 +
# Confirm that your server’s <code>STATIC_DIR</code> variable matches this directory name.
 +
# Create the following files inside the <code>static</code> directory:
 +
#* <code>hello.txt</code> — a text file containing: <b>Hello World</b>
 +
#* <code>brookings.jpg</code> — download from: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg
 +
#* <code>college.html</code> — an HTML page based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] that includes an <code>&lt;img&gt;</code> referencing <code>brookings.jpg</code>
 +
#* <code>phpinfo.php</code> — a PHP file containing:
 +
#: <source lang="php"><?php phpinfo(); ?></source>
 +
# 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 <code>phpinfo.php</code> behave 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.
  
−
=== Python Tutorial ===
+
The system must include:
  
−
====Install Python Tools====
+
* A main lobby where users select a nickname
−
#<code>sudo yum install python-setuptools</code><br>
+
* Ability to create chat rooms
−
#<code>sudo yum install python-devel</code>
+
* Ability to join chat rooms
−
====Assignment====
+
* A list of available rooms
−
#You will write a python script that reads a set of student grades in from a file and does some basic parsing and processing. [http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files here] is the section of the python tutorial on reading and writing files.
+
* A list of users currently in the room
−
#An example grades file is [http://research.engineering.wustl.edu/~todd/cse330/grades.txt here]. For the sake of simplicity you can assume that the file name is always going to be grades.txt.
+
* The entire application displayed on a single webpage
  
−
=== Set Up a Database ===
+
The single-room example is provided here:
  
−
You may find the following article to be very helpful: [[Introduction to MySQL]]
+
* [[Socket.IO]]
  
−
# Create a database named '''wustl'''
+
== AI Agent Extension ==
−
# Create a user named '''wustl_inst''' and give them the password '''wustl_pass'''
 
  
−
=== Create Tables ===
+
You will enhance your chat server with an AI assistant.
  
−
You may find the following article to be very helpful: [[MySQL Schema and State]]
+
Users can message the AI by typing:
  
−
When creating tables, keep the following items in mind:
+
<pre>/agent What is the capital of France?</pre>
  
−
* You should create all tables such that they use the InnoDB storage engine, since we wish to make use of its support of foreign keys. In other database engines, foreign key constraints are not enforced.  (If you mess up, you can use ALTER TABLE to change the storage engine.)
+
The server detects messages that begin with <code>/agent</code>, sends the prompt to an AI model, and broadcasts the response as <b>Agent</b> in the same room.
−
* Where it is appropriate, you should take advantage of the ability to define fields NOT NULL so that you do not inadvertently insert incomplete data for a row.
 
  
−
Create the following tables:
+
You may use:
  
−
# Create a table named '''students''' with the following fields:
+
* Ollama (recommended — runs locally and free)
−
#* '''id''' of an appropriately-sized unsigned integer type (we will never need to process more than a million students)
+
* OpenAI
−
#* '''first_name''' of type '''VARCHAR(50)'''
+
* Gemini
−
#* '''last_name''' of type '''VARCHAR(50)'''
+
* HuggingFace
−
#* '''email_address''' of type '''VARCHAR(50)'''
+
* Any approved model
−
#: The primary key should be on the '''id''' field.
 
−
# Create a table named '''departments''' with the following fields:
 
−
#* '''school_code''' of type '''ENUM''' (e.g. "L" for ArtSci and "E" for Engineering).  The options are as follows:
 
−
#*: 'L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M'
 
−
#* '''dept_id''' of an appropriately-sized unsigned integer type (in the foreseeable future there will never be more than 200 departments in a school)
 
−
#* '''abbreviation''' of type '''VARCHAR(9)''' (e.g. CSE, ChemE, etc)
 
−
#* '''dept_name''' of type '''VARCHAR(200)''' (e.g. Computer Science and Engineering)
 
−
#: The primary key should be on two fields: '''school_code''' and '''dept_id'''
 
−
#: '''Note:''' Why not just use the department ID? The ID numbers are sometimes reused across schools. For instance, department 33 in The School of Arts and Sciences is Psychology while department 33 in The School of Engineering and Applied Sciences is Energy, Environmental and Chemical Engineering. Thus we must also include the school code to differentiate them  such that the record for  E33 is distinct from that of L33.
 
−
# Create a table named '''courses''' with the following fields:
 
−
#* '''school_code''' of type '''ENUM'''
 
−
#*: This should have the same letters in the same order as the '''school_code''' '''ENUM''' field in the '''departments''' table.
 
−
#* '''dept_id''' of the same size of integer as in the '''departments''' table
 
−
#* '''course_code''' of type '''CHAR(5)''' (this will hold course codes; e.g., '330S', '131', '2960')
 
−
#* '''name''' of type '''VARCHAR(150)'''
 
−
#: The appropriate fields in this table should make a foreign key reference to the corresponding fields in '''department'''.
 
−
#: In addition, it is up to you to determine the field(s) for the primary key.
 
−
#: '''Note:''' If you are unsure which fields to make the foreign keys and feel the need to beg your friends or the TAs to give you the answer, bang your head on your desk whilst repeating "I WILL EXERCISE REASON AND COMMON SENSE AND I WILL CURTAIL MY DESIRE TO BLINDLY FOLLOW DIRECTIONS"
 
−
#: ''Disclaimer: don't actually bang your head on your desk, the resulting head trauma may in fact make it harder for you to determine which fields should have associated foreign keys.''
 
−
# Create a table named '''grades''' with the following fields:
 
−
#* '''pk_grade_ID''' of an appropriately-sized unsigned integer type (should be larger than the one you chose for the '''students''' table)
 
−
#*: You should declare this field to be '''auto_increment''' and make it the primary key.
 
−
#*: This is called a ''surrogate key'' as opposed to a ''natural key'' because it doesn't arise "naturally" from the data; that is to say that it is not derived from application data. The use of surrogate keys vs. natural keys is a polemic issue amongst database designers.  For a decently unbiased take on the issue, see this page: http://www.agiledata.org/essays/keys.html#Comparison
 
−
#*: '''Food for thought:''' Aside from simply exposing you to the concept, can you think of any reasons why a surrogate key might be preferable for this table?  Alternatively, what attributes, if any, could you use as a natural key, and what might be the drawbacks of doing so?
 
−
#* '''student_id''' of the same integer (unsigned) type that you chose in the '''students''' table
 
−
#* '''grade''' of type '''decimal'''
 
−
#* '''school_code''' of type '''ENUM'''
 
−
#*: Can you guess what entries to use for the enum?
 
−
#* '''dept_id''' of the same integer type that you've used for this field in other tables
 
−
#* '''course_code''' of the same type you chose for the course code in the '''courses''' table
 
−
#: The '''grades''' table should have foreign keys to both the '''students''' table and the '''courses''' table.
 
  
−
=== Populate Tables ===
+
If using an API, store your key in a file named <code>.env</code> at the root of your project:
  
−
Now, populate the tables by downloading the text files given below and loading them into the appropriate tables.
+
<source lang="bash">
 +
OPENAI_API_KEY=your_key_here
 +
</source>
  
−
'''Note:''' Do not insert all the values manually; instead, use the MySQL's ability to load in data from text files.
+
Load it securely in your server:
  
−
You may find the following article to be very helpful: [[MySQL Schema and State]]
+
<source lang="javascript">
 +
import 'dotenv/config';
 +
</source>
  
−
The files containing the data are:
+
Refer to your chosen model’s documentation for setup details.
−
* students: http://research.engineering.wustl.edu/~todd/cse330/students_data.txt
 
−
* courses: http://research.engineering.wustl.edu/~todd/cse330/course_data.txt
 
−
* departments: http://research.engineering.wustl.edu/~todd/cse330/departments_data.txt
 
−
* grades: http://research.engineering.wustl.edu/~todd/cse330/grade_data.txt
 
  
−
=== Insert More Data ===
+
== Grading ==
  
−
Insert the following data into the tables that you have created and populated:
+
We will be grading the following aspects of your work.  There are 100 points total.
  
−
# Insert an entry for CSE 330
+
'''Assignments (including code) must be committed to Github by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. '''
−
#: ''If you don't know CSE's department code, how can you find out using the tables in the database?''
 
−
# Insert the grades given for the students named below. You may choose to make the entries for whichever classes you like, with the one condition that all of the students must have a grade for CSE 330 (who wouldn't want to take that class: I hear the professor and TAs are amazing!)
 
−
#* '''Ben Harper'''
 
−
#** E-mail: '''bharper@ffym.com'''
 
−
#** Student ID: '''88'''
 
−
#** Grades:
 
−
#*** 5.5
 
−
#*** 0
 
−
#*** 20
 
−
#* '''Matt Freeman'''
 
−
#** E-mail: '''mfreeman@kickinbassist.net'''
 
−
#** Student ID: '''202'''
 
−
#** Grades:
 
−
#*** 100
 
−
#*** 90.5
 
−
#*** 94.8
 
−
#* '''Marc Roberge'''
 
−
#** E-mail: '''mroberge@ofarevolution.us'''
 
−
#** Student ID: '''115'''
 
−
#** Grades:
 
−
#*** 15
 
−
#*** 37
 
−
#*** 45.5
 
−
#: You may choose any 3 classes you'd like for them to be enrolled in, with at least one class, "CSE 330S", in which they are all enrolled.
 
  
−
=== Querying Your Database ===
+
'''Additionally, for this module, the TA should be able to simply download your repo and start up your file server, without having to copy files or create additional subdirectories.  This applies to both the individual and the creative portion'''
  
−
Now that you have a fully-functional, populated database, let's do some queries on it!
+
_________
  
−
Please take a screenshot of running the following '''select''' queries and show them to a TA (be sure to include your query command and the response:
+
# '''Individual Portion (30 Points):'''
 +
#* Node.JS is installed on your EC2 instance (5 points)
 +
#*: ''Take a screenshot of your browser visiting your EC2 instance serving up the college.html web page on port 3456, make sure the URL is visible in the screenshot.''
 +
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)
 +
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)
 +
#* Discuss in the README.md why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)
 +
#* Make sure all of your individual portion files are pushed to Github (include your node.js files, hello.txt, brookings.jpg, college.html, and phpinfo.php)
 +
#* Completion of the AI Reflections for the individual portion of the assignment following the [[AI Best Practices]] (5 points)
 +
# '''Multi-room Chat Server (70 Points):'''
 +
#* '''''Administration of user created chat rooms (25 Points):'''''
 +
#** Users can create chat rooms with an arbitrary room name(5 points)
 +
#** Users can join an arbitrary chat room (5 points)
 +
#** The chat room displays all users currently in the room (5 points)
 +
#** A private room can be created that is password protected (5 points)
 +
#** Creators of chat rooms can temporarily kick others out of the room (3 points)
 +
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)
 +
#* '''''Messaging (5 Points):'''''
 +
#** A user's message shows their username and is sent to everyone in the room (1 point)
 +
#** Users can send private messages to another user in the same room (4 points)
 +
#* '''''Best Practices (5 Points):'''''
 +
#** Code is well formatted and easy to read, with proper commenting (2 points)
 +
#** Code passes HTML validation (2 points)
 +
#** node_modules folder is ignored by version control (1 points)
 +
#* '''''Usability (5 Points):'''''
 +
#** Communicating with others and joining rooms is easy and intuitive (4 points)
 +
#** Site is visually appealing (1 point)
 +
#* '''AI Agent and Reflection (20 Points)'''
 +
#** Implement an AI assistant accessible via the command \agent ... that replies in the current room (10 points)
 +
#** Handles basic errors gracefully and does not crash the server (5 point)
 +
#** Completion of the AI Reflections for the group portion of the assignment following the [[AI Best Practices]] (5 points)
 +
#* '''Creative Portion (10 Points)'''
 +
<!-- #** Make sure to create a README.md file pointing to your server -->
  
−
# Select the entire grades table.
+
== Submission Instructions ==
−
# Select all fields describing the courses offered in the school of arts and sciences (school code L).
 
−
# The names, student IDs, and grades of the students who are in CSE330.
 
−
# The names and e-mails of any student with an average below 50 so that the dean can send them an email notification that they are now on academic probation.
 
−
#: ''You should be able to do this in only one query, without making any temporary tables.  You will need to use aggregation functions and the '''having''' keyword.''
 
−
# An individual report card for Jack Johnson, consisting of two tables (these can be done using separate queries):
 
−
## His student ID, e-mail address, and average grade.
 
−
##: ''Again, you should be able to do this in just one query, using the correct combination of aggregation functions and joins.''
 
−
## The classes he is in and his grades for those classes. To give you an idea, one row in the table should look like this:
 
−
##: <code>E 81 400 Independent Study 98.5</code>
 
  
−
== Group Project ==
+
To ensure your project can be graded quickly and reliably, follow these submission requirements carefully.
  
−
You will work in pairs on this project.  You may work with the same partner from Module 2, or change to someone else.
+
All students must submit a working GitHub repository. In addition, your project must be verifiable by the TA using one of the two methods below.
  
−
'''Important Reminder:''' frequently commit your work to your subversion repository as a backup!
+
=== Required for ALL Submissions ===
  
−
=== Simple News Web Site ===
+
Your GitHub repository must include:
  
−
'''Examples:'''
+
* All source code for both the individual and group portions
−
* http://digg.com/
+
* A complete <code>package.json</code> file
−
* http://slashdot.org/
+
* A <code>README.md</code> containing:
 +
** How to run your server
 +
** Which AI model you used (Ollama, OpenAI, Gemini, etc.)
 +
** Any special setup instructions
 +
* A <code>.gitignore</code> file that excludes:
 +
** <code>node_modules/</code>
 +
** <code>.env</code>
  
−
You should use '''PHP''' unless you get permission to use another web technology from the instructor.  You may also use phpMyAdmin to help set up databases.
+
'''Do NOT commit your API keys.'''
  
−
You may find this wiki article helpful: [[PHP and MySQL]]
+
If your project uses environment variables, include a file named:
  
−
==== Requirements ====
+
<source lang="bash">
 +
.env.example
 +
</source>
  
−
* Users can register for accounts and then log in to the website.
+
Example:
−
* Accounts should have both a username and a ''secure'' password.  '''NEVER store plaintext passwords in a database!'''
 
−
*: For more information on password security, refer to [[Web Application Security, Part 2#Password Security|the Web Application Security guide]].
 
−
* Registered users can submit stories: either a link with summary or news text.
 
−
*: You do not have to make a distinction between the two types of stories, although if you want to, you could do something with this for the creative portion of your project.
 
−
* Registered users can comment on any story.
 
−
* Administrator users can delete stories and comments.
 
−
* Unregistered users can only view stories and comments.
 
−
* Registered users can edit their stories and can delete their comments.
 
−
* All data must be kept in a MySQL database (user information, stories, comments, and categories).
 
−
* As before, please check with a TA to see if your creative portion is okay or not before you proceed.
 
  
−
=== Web Security and Validation ===
+
<source lang="bash">
 +
OPENAI_API_KEY=
 +
</source>
  
−
Your project needs to demonstrate that thought was put into web security and best practice. For more information, see this week's Web Application Security guide: [[Web Application Security, Part 2]]
+
Your server must not crash if the API key is missing. It should fail gracefully.
  
−
In particular:
+
=== Option A - Running on EC2 ===
  
−
* '''Your application needs to be secure from SQL injection attacks'''. If you are using prepared queries, you should already be safe on this front.
+
Deploy your chat server on your EC2 instance and keep it running using [[#Running Tmux|tmux]].
−
* '''All of your output needs to be sanitized using htmlentities()'''.
 
  
−
You shouldn't forget the practices you learned last week:
+
Your README must include:
  
−
* '''You should pass tokens in forms''' to prevent CSRF attacks.
+
* Public EC2 URL
−
* '''Your page should validate''' with no errors through the W3C validator.
+
* Port number (e.g., 3456)
 +
* Any login instructions (if applicable)
  
−
== Grading ==
+
The TA will:
 +
 
 +
* Visit your running server
 +
* Test chat functionality
 +
* Test multi-room behavior
 +
* Test the <code>/agent</code> AI command
 +
 
 +
This is the fastest and preferred grading method.
 +
 
 +
=== Option B — Local Execution + Demo Video ===
 +
 
 +
If your server is NOT running on EC2, you must provide a short demonstration video.
 +
 
 +
The video must show:
 +
 
 +
* Starting the server
 +
* Two browser windows connected
 +
* Chat working between users
 +
* The <code>/agent</code> command working
 +
 
 +
Video length: approximately 1–2 minutes.
 +
 
 +
The TA may still run your code locally if needed.
 +
 
 +
=== Server Requirements ===
 +
 
 +
Your submission must:
 +
 
 +
* Start successfully with:
 +
 
 +
<source lang="bash">
 +
npm install
 +
node chat-server.js
 +
</source>
 +
 
 +
(or equivalent script)
 +
 
 +
* Not require manual file copying or directory creation
 +
* Not require editing source code to run
 +
* Handle missing AI keys gracefully
 +
* Not crash during normal use
 +
 
 +
=== Common Causes of Lost Points ===
 +
 
 +
* Missing README instructions
 +
* API key committed to GitHub
 +
* Server crashes when AI key missing
 +
* Broken EC2 deployment (port closed)
 +
* Cannot run after <code>npm install</code>
 +
* <code>node_modules</code> committed to repo
 +
* Hardcoded absolute file paths
 +
* Missing AI demonstration
 +
 
 +
Following these instructions ensures your project can be graded quickly and fairly.
 +
 
 +
=== Running Tmux ===
 +
 
 +
To keep your Node.js apps running after you disconnect from your EC2 instance, you can use a tool called tmux. Normally, when you SSH into a server and start a program, it stops running as soon as you close the terminal. tmux lets your programs continue running in the background even after you disconnect.
 +
 
 +
First, install tmux on your EC2 instance by running:
 +
sudo yum install tmux
 +
 
 +
To start using tmux, create a session by typing:
 +
tmux
 +
 
 +
This opens a new terminal session managed by tmux. You can now start your Node.js server inside this session (for example, node server.js).
 +
 
 +
If you want to disconnect from the server but keep your program running, detach from tmux by pressing:
 +
Control + b, then press d
  
−
<span style="font-size:2em; line-height:2em;">'''Due Date: Wednesday October 10th, by 1pm (both individual and group)'''</span>
+
Your Node.js app will continue running even after you disconnect from SSH.
  
−
{|
+
Later, when you SSH back into your EC2 instance, you can return to the same tmux session by running:
−
!Assignment
+
tmux attach
−
!Points
 
−
|-
 
−
|Tables Correct
 
−
|2
 
−
|-
 
−
|Data Queries Correct
 
−
|2
 
−
|-
 
−
!colspan="2"|Group Portion:
 
−
|-
 
−
|User Authentication
 
−
|1
 
−
|-
 
−
|User Registration
 
−
|1
 
−
|-
 
−
|Salted One-Way Encryption
 
−
|1
 
−
|-
 
−
|Main page displays all stories (or most recent stories)
 
−
|1
 
−
|-
 
−
|Page with individual story and comments
 
−
|1
 
−
|-
 
−
|Story Submission
 
−
|1
 
−
|-
 
−
|Comment System
 
−
|1
 
−
|-
 
−
|Administrator Deletion of Stories/Comments
 
−
|1
 
−
|-
 
−
|User Edit/Delete of Story (1 pt) and Delete of Comment (1 pt)
 
−
|2
 
−
|-
 
−
|Protect Against SQL Injection Attack
 
−
|1
 
−
|-
 
−
|Sanitize Output
 
−
|1
 
−
|-
 
−
|CSRF Safe and Validation
 
−
|1
 
−
|-
 
−
|Creative Portion
 
−
|2
 
−
|-
 
−
|}
 
  
  
−
Total Points = 19
+
[[Category:Module 5]]
−
[[Category:Module 3]]
 
 
[[Category:Modules]]
 
[[Category:Modules]]

Latest revision as of 13:31, 7 July 2026


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.

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

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.

  1. 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.
  2. Ensure that you understand what the static file server script is doing.
  3. Create a directory parallel to app.js named static.
  4. Confirm that your server’s STATIC_DIR variable matches this directory name.
  5. Create the following files inside the static directory:
    <?php phpinfo(); ?>
    
  6. 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.php behave 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

We will be grading the following aspects of your work. There are 100 points total.

Assignments (including code) must be committed to Github by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.

Additionally, for this module, the TA should be able to simply download your repo and start up your file server, without having to copy files or create additional subdirectories. This applies to both the individual and the creative portion

_________

  1. Individual Portion (30 Points):
    • Node.JS is installed on your EC2 instance (5 points)
      Take a screenshot of your browser visiting your EC2 instance serving up the college.html web page on port 3456, make sure the URL is visible in the screenshot.
    • The hello.txt, brookings.jpg, and college.html files all load successfully (4 points each)
    • Visiting a file that does not exist inside the static directory results in a 404 (4 points)
    • Discuss in the README.md why phpinfo.php behaves the way it does when loaded through Node.JS (4 points)
    • Make sure all of your individual portion files are pushed to Github (include your node.js files, hello.txt, brookings.jpg, college.html, and phpinfo.php)
    • Completion of the AI Reflections for the individual portion of the assignment following the AI Best Practices (5 points)
  2. Multi-room Chat Server (70 Points):
    • Administration of user created chat rooms (25 Points):
      • Users can create chat rooms with an arbitrary room name(5 points)
      • Users can join an arbitrary chat room (5 points)
      • The chat room displays all users currently in the room (5 points)
      • A private room can be created that is password protected (5 points)
      • Creators of chat rooms can temporarily kick others out of the room (3 points)
      • Creators of chat rooms can permanently ban users from joining that particular room (2 points)
    • Messaging (5 Points):
      • A user's message shows their username and is sent to everyone in the room (1 point)
      • Users can send private messages to another user in the same room (4 points)
    • Best Practices (5 Points):
      • Code is well formatted and easy to read, with proper commenting (2 points)
      • Code passes HTML validation (2 points)
      • node_modules folder is ignored by version control (1 points)
    • Usability (5 Points):
      • Communicating with others and joining rooms is easy and intuitive (4 points)
      • Site is visually appealing (1 point)
    • AI Agent and Reflection (20 Points)
      • Implement an AI assistant accessible via the command \agent ... that replies in the current room (10 points)
      • Handles basic errors gracefully and does not crash the server (5 point)
      • Completion of the AI Reflections for the group portion of the assignment following the AI Best Practices (5 points)
    • Creative Portion (10 Points)

Submission Instructions

To ensure your project can be graded quickly and reliably, follow these submission requirements carefully.

All students must submit a working GitHub repository. In addition, your project must be verifiable by the TA using one of the two methods below.

Required for ALL Submissions

Your GitHub repository must include:

  • All source code for both the individual and group portions
  • A complete package.json file
  • A README.md containing:
    • How to run your server
    • Which AI model you used (Ollama, OpenAI, Gemini, etc.)
    • Any special setup instructions
  • A .gitignore file that excludes:
    • node_modules/
    • .env

Do NOT commit your API keys.

If your project uses environment variables, include a file named:

.env.example

Example:

OPENAI_API_KEY=

Your server must not crash if the API key is missing. It should fail gracefully.

Option A - Running on EC2

Deploy your chat server on your EC2 instance and keep it running using tmux.

Your README must include:

  • Public EC2 URL
  • Port number (e.g., 3456)
  • Any login instructions (if applicable)

The TA will:

  • Visit your running server
  • Test chat functionality
  • Test multi-room behavior
  • Test the /agent AI command

This is the fastest and preferred grading method.

Option B — Local Execution + Demo Video

If your server is NOT running on EC2, you must provide a short demonstration video.

The video must show:

  • Starting the server
  • Two browser windows connected
  • Chat working between users
  • The /agent command working

Video length: approximately 1–2 minutes.

The TA may still run your code locally if needed.

Server Requirements

Your submission must:

  • Start successfully with:
npm install
node chat-server.js

(or equivalent script)

  • Not require manual file copying or directory creation
  • Not require editing source code to run
  • Handle missing AI keys gracefully
  • Not crash during normal use

Common Causes of Lost Points

  • Missing README instructions
  • API key committed to GitHub
  • Server crashes when AI key missing
  • Broken EC2 deployment (port closed)
  • Cannot run after npm install
  • node_modules committed to repo
  • Hardcoded absolute file paths
  • Missing AI demonstration

Following these instructions ensures your project can be graded quickly and fairly.

Running Tmux

To keep your Node.js apps running after you disconnect from your EC2 instance, you can use a tool called tmux. Normally, when you SSH into a server and start a program, it stops running as soon as you close the terminal. tmux lets your programs continue running in the background even after you disconnect.

First, install tmux on your EC2 instance by running: sudo yum install tmux

To start using tmux, create a session by typing: tmux

This opens a new terminal session managed by tmux. You can now start your Node.js server inside this session (for example, node server.js).

If you want to disconnect from the server but keep your program running, detach from tmux by pressing: Control + b, then press d

Your Node.js app will continue running even after you disconnect from SSH.

Later, when you SSH back into your EC2 instance, you can return to the same tmux session by running: tmux attach