Skip to Content
AssignmentsAssignment 3

Assignment 3: React Frontend

Release Date: February 15, 2026

Due Date: March 1, 2026, 11:59 PM EST

Weight: 12.5% of final grade

Overview

Building upon Assignment 2, which established the backend with a PostgreSQL database, this assignment expands the Paper Management System into a full-stack application by adding a React frontend.

You will develop a React + TypeScript user interface for managing papers and authors, allowing users to perform CRUD (Create, Read, Update, Delete) operations through an interactive web application. The frontend communicates with your Assignment 2 backend via REST APIs, fetching and displaying data dynamically.

Learning Objectives

After completing this assignment, you will be able to:

  • Build React components using function components and TSX
  • Use useState and useEffect for state and side effects
  • Integrate a frontend with a REST API
  • Implement client-side routing using React Router
  • Apply practical TypeScript typing to React applications
  • Implement controlled forms with validation
  • Handle loading and error states correctly
  • Style React components using CSS modules

Requirements

Before you start coding

After reading the assignment requirements below, pause and think about what you expect will be the hardest part of this assignment. This will help you answer Q1 in reasoning.md, which you will submit together with your code.

See the AI Usage Policy for details.

The detailed requirements can be found in the next Detailed Requirements section.

Starter Code

Download the starter code archive:

curl -o starter-code.tar.gz https://www.eecg.utoronto.ca/~cying/courses/ece1724-web/assignments/assignment-3/starter-code.tar.gz

Alternatively, download the archive here.

The archive includes:

  • Vite + React + TypeScript setup
  • Preconfigured proxy for backend API
  • Component skeletons with TODO comments
  • Sample Playwright tests
        • AuthorSelect.tsx
        • PaperForm.tsx
        • PaperList.tsx
        • EditPaper.tsx
        • Home.tsx
        • global.css
        • Home.module.css
        • PaperForm.module.css
        • PaperList.module.css
      • main.tsx
      • types.ts
      • sample.test.ts
    • eslint.config.js
    • index.html
    • package.json
    • tsconfig.app.json
    • tsconfig.json
    • tsconfig.node.json
    • vite.config.ts

You need to:

  • Set up React Router in main.tsx
  • Implement home page layout in routes/Home.tsx
  • Add paper editing functionality in routes/EditPaper.tsx
  • Implement paper list display in components/PaperList.tsx
  • Create paper creation form in components/PaperForm.tsx
  • Implement author selection in components/AuthorSelect.tsx
  • Add custom types in types.ts

Do not modify:

  • index.html
  • CSS files in src/styles/ directory
  • Vite/TypeScript configuration files (e.g., vite.config.ts, eslint.config.js, tsconfig*.json)

Paper Management

  • Implement a paper list view with loading states
  • Create a paper form to add a new paper, allowing selection of existing authors from a dropdown
  • Implement paper editing (title, venue, year) but do not allow editing authors for simplicity
  • Implement paper deletion with a confirmation prompt

React Implementation

  • Use function components and hooks (useState, useEffect)
  • Implement React Router for client-side navigation (Home, EditPaper pages)
  • Use fetch for data fetching
  • Handle loading and error states properly

Detailed Requirements

You only need to implement what is explicitly required.

Home Route ("/")

Page Layout

Page should display:

Home Page

  • Main heading: Paper Management System
  • Section heading: Create New Paper followed by the create paper form
  • Section heading: Papers followed by the paper list

Paper List Display

Sample Paper List

  • Display all papers in a list format showing:
    • Paper title
    • Publication venue
    • Publication year
    • List of author names (comma-separated)
  • Each paper should have:
    • Edit button to navigate to edit page
    • Delete button to trigger deletion confirmation
  • Loading state should show Loading papers... Loading State
  • Error state should show Error loading papers Error State
  • Empty state should show No papers found Empty State

Delete Functionality

  • Each paper in the list should have a Delete button

    Delete Button

  • Clicking the delete button should show the browser’s built-in confirmation dialog using confirm():

    Delete Confirmation

    • Dialog message: Are you sure you want to delete [paper title]?
    • The dialog will have default OK (to confirm deletion) and Cancel buttons
  • After user interaction:

    • If OK is clicked:

      • Send delete request to backend

      • Display Paper deleted successfully in DOM

      • Remove the deleted paper from the list

        Deletion Result

      • Note: If the last paper is deleted, you may display No papers found. The autograder checks Paper deleted successfully when deleting a paper that is not the only paper in the database.

    • If Cancel is clicked:

      • Close the dialog and make no changes
    • If deletion fails:

      • Display “Error deleting paper” in DOM

Create Paper Interface

  • Form fields:

    • Title (required, text input)
    • Published In (required, text input)
    • Year (required, number input)
    • Authors (multi-select dropdown for selecting paper authors)
      • Show Error loading authors above dropdown if fetch fails
      • Show No authors available in dropdown if author list is empty
      • Dropdown should be disabled during loading or error states Loading Authors Error
      • Note: Use Ctrl+click (Windows/Linux) or Cmd+click (Mac) to select multiple authors
  • Validation: On submit, validate in this order and display only the first error encountered:

    1. Title is required if empty string or string containing only whitespace
    2. Publication venue is required if empty string or string containing only whitespace
    3. Publication year is required if empty
    4. Valid year after 1900 is required if not an integer greater than 1900
    5. Please select at least one author if no authors selected

    Form Validation Sample

    Note about the Year field

    Because the Year field uses <input type="number">:

    1. When manually testing Publication year is required, the browser may immediately display 0 instead of leaving the field visually empty after you clear the input. This is expected browser behavior for number inputs.

      For this assignment, the “empty year” case refers to clearing the input and submitting the form. Your validation should treat this situation as empty input and display: Publication year is required.

      The provided sample test cases include "Create Form Validation: 'Publication year is required' if empty", and the autograder checks the same validation logic in Edit mode as well. If your implementation passes the sample test and your Edit page applies the same validation rule, then this message is implemented correctly.

    2. Non-numeric characters (e.g., letters) cannot be entered in a number input field.

      As a result, for the validation rule Valid year after 1900 is required, the autograder will only test numeric values, including:

      • positive integers (e.g., 1800)
      • fractional decimal values (e.g., 1901.5)

      Decimal values ending with .0 (e.g., 1901.0) are acceptable, since they represent an integer year. The autograder will not test decimal values ending with .0.

  • Submit behavior:

    • Submit button should be labeled Create Paper

    • On success:

      • Show Paper created successfully in DOM

        Paper Creation

      • Delay any page reload by 3 seconds

      • No need to refresh the paper list before the reload

    • On failure

      • Show Error creating paper in DOM

Edit Route ("/edit/:id")

Page Layout

Page should display:

Edit Page

  • Main heading: Edit Paper
  • Edit form below the heading

Paper Edit Interface

  • Form pre-populated with existing paper data with fields:

    • Title (required, text input)
    • Published In (required, text input)
    • Year (required, number input)
  • Authors are displayed but can not be edited (for simplicity)

    • The author dropdown is still rendered and selectable.
    • However, changing the selected authors will not modify the paper’s authors in the database.
    • When submitting an update request, you must preserve the original authors fetched from the backend and include them unchanged in the PUT /api/papers/:id request.
  • Validation: On submit, validate in this order and display only the first error encountered:

    1. Title is required if empty string or string containing only whitespace
    2. Publication venue is required if empty string or string containing only whitespace
    3. Publication year is required if empty
    4. Valid year after 1900 is required if not an integer greater than 1900

    Edit Validation Sample

  • State messages:

    • Loading state: Show Loading paper details...
    • Error state: Show Error loading paper
    • Not found state: Show Paper not found
  • After submission:

    • On success:
      • Render Paper updated successfully in DOM
      • Navigate to home page after 3 seconds
      • Any edits made during the 3-second delay should not be recorded
    • On failure:
      • Render Error updating paper in DOM
  • Include a Cancel button to return to home page

API Integration

Your backend runs at http://localhost:3000. Your frontend should call the following endpoints via the Vite proxy:

  • GET /api/papers
  • GET /api/authors
  • GET /api/papers/:id
  • POST /api/papers
  • PUT /api/papers/:id
  • DELETE /api/papers/:id

The autograder will not test more than 10 papers/authors. Therefore, you may call GET /api/papers and GET /api/authors without specifying a limit. Using the default value of 10 is sufficient.

Important Payload Note (Create / Update)

Assignment 2 backend expects each paper to include an authors array with author objects (not just IDs). Therefore:

  • When creating a paper: The dropdown displays author names, but each selection corresponds to an author id stored in your form state. You must map those selected IDs to full author objects before sending the request.
  • When updating a paper: Since authors are not editable, you must preserve the existing authors from the fetched paper and include them unchanged in the update request.

Starter code TODOs will guide you through this logic.

React Router

Use React Router for navigation between:

  • /Home: Displays paper list and create form
  • /edit/:idEditPaper: Displays edit form
    • Use useParams() to read id

Use useNavigate() to navigate after actions

Styling

All necessary CSS files are provided in src/styles/ directory:

  • global.css: Global styles (DO NOT MODIFY)
  • Home.module.css: Styles for the home page (DO NOT MODIFY)
  • PaperList.module.css: Styles for the paper list component (DO NOT MODIFY)
  • PaperForm.module.css: Styles for the paper form component (DO NOT MODIFY)

For this assignment, you do not need to write or modify any CSS. Your task is to apply the provided styles by using the appropriate className values in your TSX (as indicated in the starter code).

You may experiment with different styles during development. However, before submitting your work to Quercus, ensure that all of the above files remain exactly as provided in the starter code.

Implementation Notes

Component Organization

  • PaperList.tsx: displays paper list and delete functionality
  • PaperForm.tsx: handles both create and edit forms
  • AuthorSelect.tsx: dropdown for author selection

Form Handling

  • Implement validation before submission
  • Clear form after successful submission
  • Handle form submission with preventDefault()
  • For multi-select authors, manage an array of authorIds in the form state (see TODOs in stater code)

Getting Started

Get Starter Code

Download the starter code archive.

Start Backend

In one terminal, navigate to your Assignment 2 directory, and

npm start

Backend should be reachable at http://localhost:3000.

Frontend Implementation

In another terminal, navigate to Assignment 3 directory, and install dependencies:

npm install

Start the development server:

npm run dev

This will start the Vite development server with hot module replacement enabled.

Notes:

  • Make sure the backend server is running before testing API integration
  • Use browser’s developer tools to:
    • Debug React components
    • Monitor network requests
    • View console messages
  • Use React Developer Tools browser extension for better debugging experience

Development Tips

Development Order

  1. Set up routing and basic page structure (Home and EditPaper pages)
  2. Implement paper list display with mock data
  3. Add API integration for fetching papers
  4. Implement create paper form with author dropdown
  5. Add edit paper form functionality
  6. Add delete functionality with confirmation
  7. Enhance loading and error states using provided starter code

Testing Strategy

  • Verify all CRUD operations work end-to-end
  • Test both success and error scenarios
  • Check form validation for all required messages (e.g., Title is required)

Common Pitfalls to Avoid

  • Not updating loading states after API calls
  • Not setting error states on API failures
  • Not validating form inputs before submission
  • Incorrect routing setup (e.g., missing useParams for edit route)
  • Not using controlled components for forms (e.g., value and onChange)

Testing Your Implementation

To help you verify your Assignment 3 frontend, the starter code includes a sample Playwright  test suite tests/sample.test.ts. It automatically launches a real browser, simulates user interactions (typing, clicking, navigation), and checks the rendered UI and backend effects.

This sample test suite focuses on core functionality and correspond to approximately 75% of the autograder score. The autograder will run similar but more comprehensive tests that check all explicitly stated requirements in this handout, and it will not test anything beyond what is specified.

Prerequisites

Before running tests, make sure:

  • Assignment 2 Backend is running at http://localhost:3000
  • Assignment 3 Frontend is running at http://localhost:5173

Setup Instructions

Install Browser Binaries

From your assignment-3/ directory, run

npx playwright install

Run Tests

From assignment-3/, run the sample test:

npx playwright test tests/sample.test.ts

To run all tests in tests/:

npx playwright test

Run Tests with a Visible Browser

By default, Playwright runs tests in headless mode (no visible browser window). This is fast, but harder to debug.

You can run the test with a visible browser to watch what happens step by step:

npx playwright test tests/sample.test.ts --headed

(Optional) Reset Your Database

The sample test suite does not require resetting your database, as it will delete all papers and authors in the database before running tests. However, if you encounter unexpected behavior due to old data, or if you want to reset id counters to start from 1, you may reset your database.

  1. Create reset.sql in your assignment-2/ directory:

    assignment-2/reset.sql
    TRUNCATE TABLE "Paper" RESTART IDENTITY CASCADE; TRUNCATE TABLE "Author" RESTART IDENTITY CASCADE;
  2. From assignment-2/, run:

    npx prisma db execute --file reset.sql

Troubleshooting

  • Port Conflicts: Ensure ports 3000 (backend) and 5173 (frontend) are free.
  • Backend Errors: Check the backend terminal for validation errors or failed requests.
  • Frontend Errors: Open the browser console to look for JavaScript or network errors.
  • Timeouts: Some tests rely on network requests or UI updates, so adjust timeouts (e.g., { timeout: 5000 }) in test script if needed, but ensure your app responds reasonably fast.

Submission Instructions

Please follow the steps below to submit a .tar.gz archive to Quercus.

Prepare reasoning.md

In addition to the required code files, you must submit a short reflection file named reasoning.md.

  • Create a folder called assignment-3.
  • Inside the assignment-3 folder, create a file called reasoning.md.
  • Answer the three required questions described in the AI Usage Policy page.

Important Notes

  • Keep your responses brief and specific, with a total length of no more than 300 words.
  • This file is intended to capture your genuine thinking process. It is not a long writing assignment required polishing.
  • reasoning.md is worth 5% of this assignment grade. Its grading rubric is on the AI Usage Policy page.

Generate the Archive

Make your assignment-3 directory have exactly the following structure:

        • AuthorSelect.tsx
        • PaperForm.tsx
        • PaperList.tsx
        • EditPaper.tsx
        • Home.tsx
        • global.css
        • Home.module.css
        • PaperForm.module.css
        • PaperList.module.css
      • main.tsx
      • types.ts
    • eslint.config.js
    • index.html
    • package.json
    • tsconfig.app.json
    • tsconfig.json
    • tsconfig.node.json
    • vite.config.ts
    • reasoning.md

From the parent directory that contains the assignment-3 folder, create the submission archive:

tar zcvf 1234567890-1724-a3.tar.gz --exclude='.DS_Store' assignment-3
  • Replace 1234567890 with your student number.
  • The archive must contain exactly one top-level folder named assignment-3 with the required files inside.
  • Do not include node_modules/. The auto-grader will run npm install to install all dependencies specified in package.json.

Filename Format

Starting from Assignment 3, the archive filename follows the format <student_number>-1724-aX.tar.gz.

This is intentional and differs from A1/A2. Please make sure to follow the format specified for this assignment.

Any submission that fails to meet the specified format or structure and requires TA intervention for the autograder to work will receive a 25-point deduction.

Verify Your Submission

To avoid a 25-point deduction, use the provided Python script to verify your submission.

  1. Download verify_a3_submission.py to the same directory as your .tar.gz file:

    curl -o verify_a3_submission.py https://www.eecg.utoronto.ca/~cying/courses/ece1724-web/assignments/assignment-3/verify_a3_submission.py

    Alternatively, download the script here.

  2. Ensure you have Python installed. If not, install it from python.org .

  3. From the same directory as your 1234567890-1724-a3.tar.gz, run:

    python verify_a3_submission.py 1234567890-1724-a3.tar.gz
    • Replace 1234567890 with your student number.

Submit to Quercus

Submit your .tar.gz file to Quercus .

Note

You are allowed to submit unlimited times. Only your latest submission before the deadline will be graded. Quercus automatically appends a suffix to the file name after the first submission — this will not affect grading.

Grading Scheme (100 points)

The total 100 points correspond to 95% of this assignment’s grade. The remaining 5% comes from your reasoning.md submission.

Grades were released on March 12. If you would like to request a remark, please do so by March 26, following the instructions in the syllabus.

Home Route (/): Paper List and Creation (62 Points)

  • Paper List Display (20 points)

    • Loading State (3 points): Shows Loading papers... initially
    • Error State (3 points): Shows Error loading papers if GET /api/papers fails
    • Empty State (3 points): Shows No papers found when database contains no papers
    • Paper Rendering (11 points): After inserting two papers (each with two authors), verify the DOM contains the correct information
      • Authors are separated by commas (1 point)
      • First paper: correct title (1 point), venue (1 point), year (1 point), and authors (2 points; 1 point each)
      • Second paper: correct title (1 point), venue (1 point), year (1 point), and authors (2 points; 1 point each)
  • Paper Creation Form (32 points)

    • Form Rendering (6 points): Displays title (1 point), publishedIn (1 point), year inputs (1 point), and multi-select author dropdown (1 point). The multi-select author dropdown has all authors in DB (2 points)
    • Author Dropdown States (6 points):
      • Shows Error loading authors if GET /api/authors fails (2 points)
      • Shows No authors available when author list is empty (2 points)
      • Dropdown is disabled during loading state (1 point) and error state (1 point)
    • Validation (10 points): Shows correct first-error messages
      • Title is required if empty string "" (2 point)
      • Publication venue is required if empty string "" (2 point)
      • Publication year is required if empty (2 point)
      • Valid year after 1900 is required if year is 1900 (2 point)
      • Please select at least one author if no authors selected (2 point)
    • Successful Creation (10 points): Creates paper in DB, shows Paper created successfully, reloads after 3s
      • Paper created successfully is shown (2 points)
      • Paper is shown in the paper list after 3 seconds (4 points): correct title (1 point), publishedIn (1 point), year (1 point), and authors (1 point)
      • Paper is in DB with correct data (4 points): correct title (1 point), publishedIn (1 point), year (1 point), and authors (1 point)
  • Delete Functionality (10 points)

    • Confirmation Dialog (2 points): Shows Are you sure you want to delete [title]? on delete click
    • Successful Deletion (6 points):
      • Paper deleted successfully is shown (2 points)
      • Paper is deleted from DOM (2 points)
      • Paper is deleted from DB (2 points)
    • Cancel Behavior (2 points): If Cancel is clicked
      • Paper remains in DOM (1 point)
      • Paper remains in DB (1 point)

Edit Route (/edit/:id) (38 Points)

  • Page Rendering (17 points)

    • Loading State (3 points): Shows Loading paper details... initially
    • Error State (3 points): Shows Error loading paper if GET /api/papers/:id fails
    • Not Found State (3 points): Shows Paper not found if navigating to /edit/999
    • Form Pre-population (8 points):
      • Loads title (1 point), publishedIn (1 point), year (1 point), and displays authors (1 point)
      • title (1 point), publishedIn (1 point), year (1 point), and authors (1 point) match with the data in DB
  • Paper Update (21 points)

    • Validation (8 points): Shows correct first-error messages
      • Title is required if string containing only whitespace " " (2 point)
      • Publication venue is required if string containing only whitespace " " (2 point)
      • Publication year is required if empty (2 point)
      • Valid year after 1900 is required if year is 2000.3 (2 point)
    • Successful Update (9 points):
      • Paper updated successfully is shown (2 points)
      • Redirect to / after 3s (2 points)
      • Edit made during the 3-second delay is not recorded (1 point)
      • Paper is updated in DB (4 points)
        • Correct title (1 point), publishedIn (1 point), year (1 point)
        • Authors unchanged (1 point)
    • Cancel Button (4 points): Navigates to / without saving
      • URL changes to / (2 points)
      • DB unchanged (2 points)

Resources

Questions?

  1. Discussion Board:

    • Post questions on course discussion board 
    • Search existing discussions first
    • Use clear titles and provide relevant code snippets
  2. Office Hours:

    • Time: Wednesdays, 4:00 PM — 5:00 PM
    • Location: Room 7206, Bahen Centre for Information Technology
  3. Tips for Getting Help:

    • Start early to allow time for questions
    • Be specific about your problem
    • Share what you’ve tried
    • Include relevant error messages
Last updated on