Final Project: Twitter Clone
This is the last project of the course, and it ties together nearly everything we’ve built. You’re going to write your own Twitter: a site where people sign up, log in, post short messages, and scroll through everyone else’s, all served by a web server you wrote and stored in a database you designed.
The comic above is a fight every web team eventually has. Back-end developers think the front end is “just playing with JS and HTML/CSS.” Front-end developers think the back end is “only CRUD all day long.” For this project you are both people at once, so you get to settle the argument yourself.
Due: Wednesday, December 16, the final project, demoed live during finals week. See the schedule and Submission below.
Learning objectives
- create large Python programs that span multiple files
- develop a CRUD (Create, Read, Update, Delete) web app
- understand how social media websites actually work
- integrate the Python, Markdown, HTML, CSS, Jinja2, and SQL languages
- practice using git
Instructions
None of the tools are new. You’ll write Python spread across several files, serve pages with FastAPI, store data in a sqlite3 database, generate HTML with Jinja2 templates, style it with CSS, and pull everything back out with SQL. It’s the same stack from the backend web dev unit, and the final project extends the FastAPI app you started in that lab, so you’re not beginning from an empty folder.
The shape underneath a site like this has a name, and the front-end developer in the comic already gave it away: CRUD, for Create, Read, Update, and Delete. Users create accounts and post messages, read the feed, update posts they want to fix, and delete the ones they regret. Almost every application you use is some arrangement of those four operations, and by the end of this you’ll have written all four yourself.
Grading rubric
This project is graded out of 48 points. 25 points come from the required tasks that everyone must complete, and there are roughly 99 points of optional tasks to choose from. Your grade is capped at 100/48 points, so there is far more extra credit available than you need; complete the tasks you find most interesting. The extra credit is deliberately generous, and you should lean on it.
Warning: If I can break into your site with a SQL injection attack, you take a -10 point penalty.
Warning: If I can break into your site with an HTML injection attack, you take a -4 point penalty.
Warning: While grading, I’ll actively try to make your site throw an
Internal Server Error. If I manage it, you get no points for the task that caused it.
Hint: Complete more tasks than you think you need. The buffer protects you if I break something or don’t award points for a task you thought you’d finished.
Required tasks
Each required task is worth 5 points and matches one route on your site.
Home, 5 points
-
(this check exists to make you confront SQL and HTML injection early)
Log in, 5 points
-
Hint: Don’t use
type=texton yourinputtag. Find the input type meant for passwords.
Log out, 5 points
-
Hint: We didn’t cover deleting cookies in class, but this StackOverflow post explains it.
Create new user accounts, 5 points
-
Hint: You know an account already exists because the
INSERTfails with a sqlite error about violating a unique constraint.
Create a message, 5 points
Extra credit
The following tasks are each worth 3 points:
-
I’ll use my own aesthetic judgment for what counts as “nicely themed,” but nothing fancy is required; the simple CSS from the start of the course is plenty.
-
Hint: Modify the
db_create.pyfile to generate the messages randomly. -
Hint: If you haven’t tested the connection from a computer that isn’t yours, you haven’t finished this task and won’t get the points.
The following tasks are each worth 6 points. Each one needs either more advanced SQL (a trickier SELECT) or a change to your table schemas:
-
Hint: You can reuse the Markdown compiler you built in Project 1 to turn the Markdown into the HTML you display.
Hint: This combines easily with the 3-point task for linking URLs.
The following tasks are each worth 9 points of extra credit:
-
Hint: This pairs well with the 6-point reply task.
Submission
This one is a live demo instead of an upload. One-on-one, you’ll open your running site and walk me through each feature while I grade it, which usually takes five to fifteen minutes. Make sure your repository is pushed and your site is ready to launch before your slot.