HW4: Backend + Frontend

CMU 15-113: Effective Coding with AI

Due Date: Sat. 2/14 at 8:00 PM
Time Estimate: ~3 hours
Deliverables: Backend code on Render + frontend code on GitHub + brief form response

Assignment Overview

Goal: Build a simple backend service on Render.com and integrate it with your portfolio website or a GitHub Pages site. This assignment teaches you how to build server-side code that handles operations that are better done on the backend (like using APIs securely, storing data, or processing user input).

Why This Matters: Many features are best implemented on the backend because: (1) you can keep API keys and secrets secure, (2) you can process and store data safely, (3) you can do computationally intensive work, and (4) you can validate user input before using it. This assignment teaches you to identify when a backend is useful and how to build one quickly using AI.

Examples of what you might build:

See the course website for an example: check out this Carnegie Chat example, which uses a Python backend on Render to power an AI chatbot.

Tutorial: Watch this first!

This video walks through the steps for getting an example up and running on Render. We strongly recommend you watch this first so that you can see what steps you should take, and so that you can get some inspiration for how to prompt for what you need. Your code will be different, so focus on capturing the main ideas, and refer back to HW3 for help with APIs.

Requirements & Scoring

What You Must Submit

Privacy and Security: Once again, do not commit API keys, credentials, or secrets to GitHub. Keep all secrets on the Render backend using environment variables or an uploaded secret file that is not in your repository. We will not accept submissions that expose private keys publicly. Watch the tutorial video for information on how to do this.

Grading

You'll receive full credit for submitting a working backend-frontend integration with clear documentation and clean communication: Your frontend should make requests to your backend and display the results or confirm that the request was handled successfully. It should handle errors gracefully. Focus on core functionality and clean communication between frontend and backend rather than UI polish.

Detailed Instructions

  1. Choose what your backend will do. Decide on something interesting that requires server-side logic: handle authentication, process data, call a third-party API securely, store information, etc.
Focus on functionality: For this assignment, prioritize getting the backend and frontend working together over adding lots of features and polishing the UI or user experience. Don't spend much time on design details. Later in the course (Project 2), we'll bring together your knowledge of frontends, APIs, and backends into one really polished project. For that and any future work, you can either build on earlier assignments in this class or start fresh with an entirely new idea, as long as your work meets the assignment specifications.
  1. Write your backend. We recommend using Python with Flask, but you may also use FastAPI or another backend framework, or you may use a different language altogether. Use AI tools to help you write the code. Make sure your backend:
    • Has at least one endpoint that accepts data and returns a meaningful response
    • Handles any API keys or secrets using environment variables or a secret file that is not present on your repo or your frontend
    • Returns JSON or another structured format that your frontend can use
  2. Deploy your backend to Render. Create a free account at render.com, create a new Web Service, connect your GitHub repo, and deploy. Render will give you a public URL (e.g., https://my-backend.onrender.com).
  3. Write your frontend. Create an HTML/CSS/JavaScript page (on your portfolio or a new repo) that:
    • Makes requests to your backend using fetch() or another HTTP client
    • Displays the responses nicely (or provides confirmation that the request was handled)
    • Handles errors (e.g., if the backend is down or the user provides bad input)
  4. Test end-to-end. Make sure your frontend can call your backend and display real results. Test error cases too (e.g., what happens if the user submits an empty form).
  5. Document everything. Write a clear README explaining what your backend does, how to run it locally, how the frontend calls it, and where secrets are stored.
  6. Push both repos to GitHub (backend + frontend) and fill out the Google form with your Render URL and GitHub repos before the deadline.
  7. Make your video and upload it, and fill out the google form before the deadline.

What is a Backend? Key Concepts

A backend is a program running on a server that your frontend (website) can communicate with. Here are some key ideas:

When you use AI to write your backend, ask it to explain what each endpoint does and how to test it locally.

Tips

Getting Started with Render

Backend Framework Resources

Frontend-Backend Communication

Questions? Ask on Ed, attend office hours, or email the instructor. Consult the course AI usage and collaboration policies on the course homepage.