Difference between revisions of "Module 5"

From CSE330 Wiki
Jump to navigationJump to search
 
(95 intermediate revisions by 12 users not shown)
Line 1: Line 1:
−
In Module 6, you will learn about python, a programming language, and Django, a web framework.
+
__NOTOC__
  
−
This article contains your assignments for Module 6.
+
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:
 +
 
 +
* [[Node.JS]]
 +
* [[Socket.IO]]
 +
* [[FAQ - Mod 5]]
  
 
== Individual 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.
 +
 +
# 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.
 +
 +
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:
 +
 +
* [[Socket.IO]]
 +
 +
== AI Agent Extension ==
 +
 +
You will enhance your chat server with an AI assistant.
 +
 +
Users can message the AI by typing:
 +
 +
<pre>/agent What is the capital of France?</pre>
  
−
=== Python Tutorial ===
+
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.
  
−
====Install Python Tools====
+
You may use:
−
*<code>sudo yum install python-setuptools</code><br>
 
−
*<code>sudo yum install python-devel</code>
 
−
====Python Assignment====
 
−
*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.
 
−
*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 first line of the file is of the form: NUM_LABS,NUM_EXAMS,LAB_WEIGHT
 
−
*All of the other lines in the file are of the form: FIRSTNAME LASTNAME|GRADE|TYPE
 
−
*The FIRSTNAME and LASTNAME fields are the student's full name (always only a first and last name), the GRADE is one grade for the student, and the TYPE describes what kind of assignment the grade was for, in this case either a 'lab' or an 'exam'.
 
−
*Your script should read in a grades file with the above format and perform the following:
 
−
*# Compute the final grade for every student, given that there were a total of NUM_LABS labs, NUM_EXAMS exams, and that the labs account for a total of LAB_WEIGHT percent of the grade.
 
−
*# Compute the final letter grade based on the final numeric grade (A = 90 or above, B = 80 - 90, C = 70 - 80, D = 60 - 70, F = below 60). 
 
−
*# Ignore any blank lines.
 
−
*# Sort the students by last name, and print out final grades in that sorted order.
 
−
*# No names should be hard coded into the script (you will run your script on another file with different student names when we grade your assignment).
 
−
*# Finally, the script should take one optional command line argument, which is a string to match against student names.  Only names that match the string in full or in part, should be printed out with their final grades.
 
−
*#*For example, with the argument 'John' grades for both John Smith and John Locke should be printed (if those are the only two Johns in the grades.txt file)
 
  
−
=== Django Tutorial===
+
* Ollama (recommended — runs locally and free)
−
====Install Djgano====
+
* OpenAI
−
<p> This procedure assumes you are using and Amazon AMI Linux on an ec2 instance. An in-depth install guide can be found on the [https://docs.djangoproject.com/en/dev/topics/install/# Django website], but a quick version is below. </p>
+
* Gemini
−
<ul>
+
* HuggingFace
−
<li>Install Distribute (prerequisite for pip):</li>
+
* Any approved model
−
<code>wget http://python-distribute.org/distribute_setup.py</code><br><code>sudo python distribute_setup.py </code>
 
−
<li>Install pip:</li>
 
−
<code>wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py </code><br><code>sudo python get-pip.py</code>
 
−
<li><p>Install Django using pip:</p></li>
 
−
<code>sudo pip install Django</code>
 
−
</ul>
 
−
<p> That's it. </p>
 
  
−
====Django Assignment====
+
If using an API, store your key in a file named <code>.env</code> at the root of your project:
−
<p>Complete the [https://docs.djangoproject.com/en/1.4/intro/tutorial01/ tutorial] on the django website. You will create a Polls app. There are four parts to this tutorial.</p>
 
−
<p>It is important you do all the steps in the tutorial to get comfortable defining models, views, templates, and using the interactive shell and the admin app. Understanding the concepts will make the project go much quicker.</p>
 
−
<ul>
 
−
<li><h5>[https://docs.djangoproject.com/en/1.4/intro/tutorial01/ Part 1]</h5>
 
−
<ul>
 
−
<li>Create a project</li>
 
−
<li>Start the development server</li>
 
−
<li>Setup an SQLite database</li>
 
−
<li>Create the Polls app and define the models</li>
 
−
<li>Interact with the database using the interactive python shell</li>
 
−
</ul>
 
−
</li>
 
−
<li>
 
−
<h5>[https://docs.djangoproject.com/en/1.4/intro/tutorial02/ Part 2]</h5>
 
−
<ul>
 
−
<li>Activate the admin site</li>
 
−
<li>Add the poll app to the admin site</li>
 
−
<li>Modify the database using the admin site</li>
 
−
</ul>
 
−
</li>
 
−
<li>
 
−
<h5>[https://docs.djangoproject.com/en/1.4/intro/tutorial03/ Part 3]</h5>
 
−
<ul>
 
−
<li>Configure URL handling</li>
 
−
<li>Create some views</li>
 
−
</ul>
 
−
</li>
 
−
<li>
 
−
<h5>[https://docs.djangoproject.com/en/1.4/intro/tutorial04/ Part 4]</h5>
 
−
<ul>
 
−
<li>Write a form that modifies the database</li>
 
−
<li>Refactor to use generic views</li>
 
−
</ul>
 
  
−
<h5>Switch to Apache Webserver</h5>
+
<source lang="bash">
−
<ul>
+
OPENAI_API_KEY=your_key_here
−
<li>run <code> sudo yum install mod_wsgi</code> to install the apache and the module necessary for serving your django app.</li>
 
−
<li> Add these lines to /etc/httpd/conf/httpd.conf
 
−
<source lang="apache">
 
−
Alias /static /var/www/mysite/static
 
−
<Directory /var/www/mysite/static>
 
−
  Order deny,allow
 
−
  Allow from all
 
−
</Directory>
 
−
WSGIScriptAlias / /var/www/mysite/apache/django.wsgi
 
 
</source>
 
</source>
−
</li>
 
−
<li>Move your "mysite" project (the top level mysite directory) to /var/www and make the directory /var/www/mysite/apache. In that directory create the file django.wsgi and inside that file put:
 
−
<source lang="python">
 
−
import os
 
−
import sys
 
−
sys.path.append('/var/www/mysite')
 
−
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
 
−
import django.core.handlers.wsgi
 
−
application = django.core.handlers.wsgi.WSGIHandler()
 
−
</source></li>
 
−
</ul>
 
−
</li>
 
−
<li>Be sure to change any references to old paths in the django "mysite" settings.py file</li>
 
−
</ul>
 
  
−
== Group Project ==
+
Load it securely in your server:
 +
 
 +
<source lang="javascript">
 +
import 'dotenv/config';
 +
</source>
  
−
You may work in pairs on this project. Your group will create an image tagging and browsing site using Django as described below.
+
Refer to your chosen model’s documentation for setup details.
  
−
=== Image Tagging/Browsing Site ===
+
== Grading ==
  
−
A site that lets users upload images, apply multiple tags to them, and browse through images of a certain tag.
+
We will be grading the following aspects of your work. There are 100 points total.
−
When looking at an image, it lists all associated tags so you can switch albums.
 
  
−
==== Requirements ====
+
'''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'''
  
 +
_________
  
−
<ul>
+
# '''Individual Portion (30 Points):'''
−
<li>Make a database that stores images and tags. An image can have multiple tags, and each tag can have multiple images.</li>
+
#* Node.JS is installed on your EC2 instance (5 points)
−
<li>The home page should allow users to find tags that they want to view. (e.g. lolcat).</li>
+
#*: ''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.''
−
<li>After clicking a link to a tag, it should take you to a page with the newest image for that tag.</li>
+
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)
−
<li>Clicking on the current image should take to to the next image according to date added. When at the last image, link to the first.</li>
+
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)
−
<li>Make it clear which tag you are currently browsing. Beside or below the current image, also display the full list of tags that belong to the current image (e.g. lolcat, meme, internet, funny). You should be able to click on any of the tags to begin looking through that collection of images.</li>
+
#* Discuss in the README.md why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)
−
<li>Provide a way for users who are logged in to add new images and new tags.</li>
+
#* 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)
−
<li>Validate user input</li>
+
#* Completion of the AI Reflections for the individual portion of the assignment following the [[AI Best Practices]] (5 points)
−
<li>Provide a way for users to register, login, and change their password.</li>
+
# '''Multi-room Chat Server (70 Points):'''
−
<li>Have a link that sends an email to a user with a link for resetting their password in case they forget it.</li>
+
#* '''''Administration of user created chat rooms (25 Points):'''''
−
<li>Style the site with statically-served CSS (i.e. link to static .css files and don't write CSS inside the html templates) </li>
+
#** Users can create chat rooms with an arbitrary room name(5 points)
−
</ul>
+
#** 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 -->
  
−
==== Notes ====
+
== Submission Instructions ==
−
<ul>
 
−
<li>You may store images as external web links. </li>
 
−
<li>Try to find and figure out as many Django shortcuts as you can. You do not need to write your own url parsing, validation, login/registration/reset forms etc. For these common tasks, there is almost always built-in functionality that will do what you want in very few lines.</li>
 
−
<li>The admin interface and the interactive python shell will be very helpful when getting started with the database.</li>
 
  
−
</ul>
+
To ensure your project can be graded quickly and reliably, follow these submission requirements carefully.
  
−
== Grading ==
+
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 <code>package.json</code> file
 +
* 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>
 +
 
 +
'''Do NOT commit your API keys.'''
 +
 
 +
If your project uses environment variables, include a file named:
 +
 
 +
<source lang="bash">
 +
.env.example
 +
</source>
 +
 
 +
Example:
 +
 
 +
<source lang="bash">
 +
OPENAI_API_KEY=
 +
</source>
 +
 
 +
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 [[#Running Tmux|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 <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 ===
  
−
<span style="font-size:2em; line-height:2em;">'''Due Date: Wednesday December 5th by 1pm (both individual and group)'''</span>
+
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:
−
!Python Assignment (Individual)
+
sudo yum install tmux
−
!Points
 
−
|-
 
−
|Compute Final Grades
 
−
|0.25
 
−
|-
 
−
|Compute Letter Grade
 
−
|0.25
 
−
|-
 
−
|Sort by Last Name
 
−
|0.25
 
−
|-
 
−
|Accept Command Line Argument
 
−
|0.25
 
−
|-
 
−
!colspan="2"|Django Assignment (Individual)
 
−
|-
 
−
|Models defined, database set up     
 
−
|0.25
 
−
|-
 
−
|Admin app enabled and working
 
−
|0.25
 
−
|-
 
−
|URLs matched to correct views
 
−
|0.25
 
−
|-
 
−
|Templates for viewing and voting using generic views
 
−
|0.25
 
−
|-
 
−
|Apache serving the site
 
−
|0.5
 
−
|-
 
−
!colspan="2"|Group Portion:
 
−
|-
 
−
|Models defined and database set up
 
−
|1
 
−
|-
 
−
|View of single image with current tag and list of all tags
 
−
|1
 
−
|-
 
−
|Navigation between images and tags
 
−
|0.5
 
−
|-
 
−
|Main page displays all tags sorted by number of images
 
−
|0.5
 
−
|-
 
−
|User registration, login/logout and change password
 
−
|0.5
 
−
|-
 
−
|Forgot password sends email with working reset link
 
−
|0.5
 
−
|-
 
−
|Validation of all user input
 
−
|0.5
 
−
|-
 
−
|Add new images and tags, only if logged in
 
−
|0.5
 
−
|-
 
−
|Static CSS applied to some templates
 
−
|0.5
 
−
|-
 
−
|Creative Portion
 
−
|2
 
−
|-
 
−
|}
 
  
 +
To start using tmux, create a session by typing:
 +
tmux
  
−
Total Points = 10
+
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).
  
−
Turn in after 1pm on the 5th = 1 point off
+
If you want to disconnect from the server but keep your program running, detach from tmux by pressing:
 +
Control + b, then press d
  
−
Turn in on the 6th = 2 points off
+
Your Node.js app will continue running even after you disconnect from SSH.
  
−
Turn in on the 7th = 3 points off
+
Later, when you SSH back into your EC2 instance, you can return to the same tmux session by running:
 +
tmux attach
  
−
All projects should be completed by the last day of class, Friday the 7th.  Any modules that have not been demo'd at that time will be given a grade of zero.  You are responsible for making sure you can attend TA hours to demo if you are late (or for contacting a TA to try and arrange a session).  You cannot demo by e-mail. 
 
  
−
[[Category:Module 6]]
+
[[Category:Module 5]]
 
[[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