Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules/
package-lock.json

.env
.DS_Store
*.log
.vscode/
.idea/
154 changes: 31 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,138 +1,46 @@
Assignment 2 - Short Stack: Basic Two-tier Web Application using HTML/CSS/JS and Node.js
===
# Movie Rating Tracker - Aanan Goyal

Due: Monday, September 8, 2025, by 11:59 PM.
https://a3-aanangoyal.onrender.com

This assignment aims to introduce you to creating a prototype two-tiered web application.
Your application will include the use of HTML, CSS, JavaScript, and Node.js functionality, with active communication between the client and the server over the life of a user session.
A web application for tracking movie ratings with user authentication and persistent storage. Built with Express, MongoDB, and Bootstrap.

Baseline Requirements
---
## Features

There is a large range of application areas and possibilities that meet these baseline requirements.
Try to make your application do something useful! A todo list, storing / retrieving high scores for a very simple game... have a little fun with it.
- **User Authentication**: Simple login system that creates accounts on first login
- **Personal Movie Collections**: Each user has their own private movie list
- **Full CRUD Operations**: Add, view, update ratings, and delete movies
- **Automatic Recommendations**: Movies categorized as Must Watch, Highly Recommended, Worth Watching, or Skip
- **Responsive Design**: Clean Bootstrap-based UI that works on all devices

Your application is required to implement the following functionalities (4 pts each, total 20 pts):
## Authentication Strategy

- a `Server` which not only serves files, but also maintains a tabular dataset with 3 or more fields related to your application
- a `Results` functionality which shows the entire dataset residing in the server's memory
- a `Form/Entry` functionality which allows a user to add or delete data items residing in the server's memory
- a `Server Logic` which, upon receiving new or modified "incoming" data, includes and uses a function that adds at least one additional derived field to this incoming data before integrating it with the existing dataset
- the `Derived field` for a new row of data must be computed based on fields already existing in the row.
For example, a `todo` dataset with `task`, `priority`, and `creation_date` may generate a new field `deadline` by looking at `creation_date` and `priority`
I chose simple username/password authentication because it was straightforward to implement and meets the assignment requirements. New accounts are automatically created on first login, which is clearly communicated to users on the login page.

Your application is required to demonstrate the use of the following concepts:
## CSS Framework

HTML (4 pts each, total 16 pts):
- One or more [HTML Forms](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms), with any combination of form tags appropriate for the user input portion of the application
- A results page displaying all data currently available on the server. You will most likely use a `<table>` tag for this, but `<ul>` or `<ol>` could also work and might be simpler to work with. Alternatively, you can create a single-page app (see Technical Acheivements) but this is not a requirement.
- All pages should [validate](https://validator.w3.org)
- If your app contains multple pages, they should all be accessible from the homepage (index.html)
I used **Bootstrap 5.3** because:
- Provides professional-looking components out of the box
- Excellent documentation and widespread adoption
- Built-in responsive design
- Minimal custom CSS needed

CSS (4 pts each, total 16 pts):
- CSS styling of the primary visual elements in the application
- Various CSS Selector functionality must be demonstrated:
- Element selectors
- ID selectors
- Class selectors
- CSS positioning and styling of the primary visual elements in the application:
- Use of either a CSS grid or flexbox for layout
- Rules defining fonts for all text used; no default fonts! Be sure to use a web safe font or a font from a web service like [Google Fonts](http://fonts.google.com/)
- CSS defined in a maintainable, readable form, in external stylesheets
**Custom CSS modifications**: Added gradient background for login page and some custom styling for alert positioning.

JavaScript (4 pts):
- At minimum, a small amount of front-end JavaScript to get / fetch data from the server; a sample is provided in this repository.
## Express Middleware Packages

Node.js (4 pts):
- An HTTP Server that delivers all necessary files and data for the application, and also creates the required `Derived Fields` in your data.
A starting point is provided in this repository.
- **express-session**: Manages user sessions and login state
- **bcryptjs**: Hashes passwords securely before storing in database
- **dotenv**: Loads environment variables from .env file for MongoDB connection
- **mongodb**: Official MongoDB Node.js driver for database operations

Deliverables
---
## Database Design

1. (5 pts) Fork the starting project code repo. The starter code in the repo may be used or discarded as needed.
2. (60 pts, detailed above) Implement your project with the above requirements.
3. Test your project to make sure that when someone goes to your main page, it displays correctly.
4. (5 pts) Deploy your project to Render (or your hosting service of choice), and fill in the appropriate fields in your package.json file.
5. (5 pts) Ensure that your project at least starts with the proper naming scheme `a2-FirstnameLastname` so we can find it.
6. (5 pts) Modify the README to the specifications below, and delete all of the instructions originally found in this README.
7. (5 pts) Create and submit a Pull Request to the original repo. Be sure to include your name in the pull request.
Uses MongoDB with a simple schema:
- **users collection**: `{ username, password, movies: [], createdAt }`
- Movies are stored as embedded documents in user records for simplicity

Acheivements
---
## Login Instructions

Below are suggested technical and design achievements. You can use these to help customize the assignment to your personal interests. These are recommended acheivements, but feel free to create/implement your own... just make sure you thoroughly describe what you did in your README and why it was challenging. ALL ACHIEVEMENTS MUST BE DESCRIBED IN YOUR README IN ORDER TO GET CREDIT FOR THEM. Remember, the highest grade you can get on any individual assignment is a 100%.

*Technical*
- (5 points) Create a single-page app that both provides a form for users to submit data and always shows the current state of the server-side data. To put it another way, when the user submits data, the server should respond sending back the updated data (including the derived field calculated on the server) and the client should then update its data display.

- (5 points) In addition to a form enabling adding and deleting data on the server, also add the ability to modify existing data.

*Design/UX*
- (5 points per person, with a max of 10 points) Test your user interface with others. Define a specific task for them to complete (ideally something short that takes <10 minutes), and then use the [think-aloud protocol](https://en.wikipedia.org/wiki/Think_aloud_protocol) to obtain feedback on your design (talk-aloud is also fine). Important considerations when designing your study:

1. Make sure you start the study by clearly stating the task that you expect your user to accomplish.
2. You shouldn't provide any verbal instructions on how to use your interface / accomplish the task you give them. Make sure that your interface is clear enough that users can figure it out without any instruction, or provide text instructions from within the interface itself.
3. If users get stuck to the point where they give up, you can then provde instruction so that the study can continue, but make sure to discuss this in your README. You won't lose any points for this... all feedback is good feedback!

You'll need to use sometype of collaborative software that will enable you both to see the test subject's screen and listen to their voice as they describe their thoughts, or conduct the studies in person. After completing each study, briefly (one to two sentences for each question) address the following in your README:

1. Provide the last name of each student you conduct the evaluation with.
2. What problems did the user have with your design?
3. What comments did they make that surprised you?
4. What would you change about the interface based on their feedback?

*You do not need to actually make changes based on their feedback*. This acheivement is designed to help gain experience testing user interfaces. If you run two user studies, you should answer two sets of questions.

Important Notes
---
* For this and future assignments, you should choose **Web Service** instead of "Static Page" when uploading to Render. On the New Project page, you should leave all fields as their default values except under **Instance Type**, where you should select the free tier.
* You are **strongly encouraged** to create a [.gitignore file](https://git-scm.com/docs/gitignore) that will keep your node_modules folder and any other stray files (such as package-lock.json) out of your online repo.


FAQ
---
**Q: I'm getting a 404 error on render. Why?**

A: Make sure that you've uploaded your project as a Web Service, not a Static Page. Also verify that any stray files (such as package-lock.json) are not in your online repository.

**Q: What fields should I fill out in the package.json file?**

A: Give the name field your project name and the version field 1.0.0. You can leave the others blank.

**Q: On Windows, I'm getting an Execution Policy exception when starting npm.**

A: You may need to make a policy change on your machine. Check out the following links for more information on how to fix it.

* [npm Not Working (Reddit)](https://www.reddit.com/r/node/comments/1h6wer2/npm_not_working_on_windows_after_install_and/)
* [Set-Execution Policy](https://www.pdq.com/powershell/set-executionpolicy/)
* [Successfully Changing Execution Policy (StackOverflow)](https://stackoverflow.com/questions/27753917/how-do-you-successfully-change-execution-policy-and-enable-execution-of-powershe)

**Q: Can I use frameworks for this assignment?**

A: No. We'll discuss them later this term, but for right now, we want to see that you can implement these features yourself instead of outsourcing them to an existing framework or library.

**Q: After I delete some data server-side, the data persists on the client side until I refresh the page.**

A: Make sure the client-side copy of the data also reflects the deletion. The server-side and client-side copies of the data should remain in sync at all times.

**Q: Do I have to implement the specific achievements above?**

A: No. As discussed in the instructions, you are free to implement your own. If you're not sure if they'll qualify, check with the instructor.

**Q: If I do a single page for the technical achievement, will I still get credit for the last two criteria in the base requirements?**

Yes.


Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title
Include a very brief summary of your project here. Be sure to include the CSS positioning technique you used, and any required instructions to use your application.

## Technical Achievements
- **Tech Achievement 1**: Using a combination of...

### Design/Evaluation Achievements
- **Design Achievement 1**:
Use any username/password combination. If the account doesn't exist, it will be created automatically. For testing, you can use:
- Username: `test`
- Password: `password`
25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
"name": "",
"version": "",
"description": "",
"author": "",
"name": "a3-movie-rating-tracker",
"version": "1.0.0",
"description": "A movie rating tracker with user authentication and MongoDB",
"main": "server.js",
"scripts": {
"start": "node server.improved.js"
"start": "node server.js",
"dev": "node server.js"
},
"keywords": ["movie", "rating", "tracker", "nodejs", "express", "mongodb"],
"author": "Aanan Goyal",
"license": "MIT",
"dependencies": {
"mime": "^2.6.0"
"express": "^4.18.2",
"mongodb": "^6.0.0",
"dotenv": "^16.3.1",
"express-session": "^1.17.3",
"bcryptjs": "^2.4.3"
},
"engines": {
"node": ">=14.0.0"
}
}
}
4 changes: 0 additions & 4 deletions public/css/main.css

This file was deleted.

110 changes: 93 additions & 17 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,94 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>CS4241 Assignment 2</title>
<meta charset="utf-8">
<script src="js/main.js"></script>
<link rel="stylesheet" href="css/main.css">

<!-- get rid of favicon error -->
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
</head>
<body>
<form>
<input type="text" id="yourname" value="your name here">
<button>submit</button>
</form>
</body>
</html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Movie Rating Tracker</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="/">🎬 Movie Tracker</a>
<div class="navbar-nav ms-auto">
<a class="nav-link active" href="/">Add Movie</a>
<a class="nav-link" href="/results">View Movies</a>
<button class="btn btn-outline-light btn-sm" onclick="logout()">Logout</button>
</div>
</div>
</nav>

<div class="container mt-4">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5>Add New Movie</h5>
</div>
<div class="card-body">
<form id="movieForm">
<div class="mb-3">
<label class="form-label">Movie Title</label>
<input type="text" class="form-control" id="title" required>
</div>

<div class="mb-3">
<label class="form-label">Genre</label>
<select class="form-select" id="genre" required>
<option value="">Select genre</option>
<option value="Action">Action</option>
<option value="Comedy">Comedy</option>
<option value="Drama">Drama</option>
<option value="Horror">Horror</option>
<option value="Romance">Romance</option>
<option value="Sci-Fi">Sci-Fi</option>
<option value="Thriller">Thriller</option>
</select>
</div>

<div class="mb-3">
<label class="form-label">Rating (0-10)</label>
<input type="number" class="form-control" id="rating" min="0" max="10" step="0.1" required>
<div class="form-text">
<input type="radio" name="ratingType" value="love" id="love" class="me-1">
<label for="love" class="me-3">Love it</label>
<input type="radio" name="ratingType" value="like" id="like" class="me-1">
<label for="like" class="me-3">Like it</label>
<input type="radio" name="ratingType" value="meh" id="meh" class="me-1">
<label for="meh">Meh</label>
</div>
</div>

<button type="submit" class="btn btn-primary">Add Movie</button>
</form>
</div>
</div>
</div>

<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5>Recent Movies</h5>
</div>
<div class="card-body">
<div id="recentMovies">Loading...</div>
<a href="/results" class="btn btn-outline-primary btn-sm mt-3">View All Movies</a>
</div>
</div>
</div>
</div>
</div>

<script src="script.js"></script>
<script>
async function logout() {
try {
await fetch('/api/logout', { method: 'POST' });
window.location.href = '/login';
} catch (error) {
console.error('Logout error:', error);
}
}
</script>
</body>
</html>
27 changes: 0 additions & 27 deletions public/js/main.js

This file was deleted.

Loading