Final Project: Twitter Clone
For the final project, you will build a small Twitter-like site where people sign up, log in, post messages, and read a shared feed. Your Python web server will generate the pages and store the data in a database. The project includes both the front end and the back end shown in the comic.
Repository due: Wednesday, December 16 at 11:59pm. Live demo: Wednesday, December 16, 2:00–5:00pm, during the official final-exam slot; see Submit below.
Start
Continue on the default branch of the twitter-clone repository from the FastAPI lab. Leave the lab’s lab-submission branch unchanged.
Learning Objectives
- create large Python programs that span multiple files
- develop a CRUD (Create, Read, Update, Delete) web app
- understand how social media websites work
- integrate the Python, Markdown, HTML, CSS, Jinja2, and SQL languages
- practice using git
Build the Site
Extend the FastAPI app from the backend web development lab. The project uses Python across several files, a sqlite3 database, Jinja2 templates, CSS, and SQL.
The site implements CRUD: 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.
Grading Rubric
This project is graded out of 62 points. 30 points come from the required tasks that everyone must complete, and there are 138 points of optional tasks to choose from. Your grade is capped at 129/62 points, so choose the optional tasks you find most interesting.
The five required routes are checked by instructor-owned pytest tests in Gradescope (6 points each). The grader imports the FastAPI app, uses an isolated TestClient, creates unique test accounts and messages, and never contacts the public internet. Optional features are checked only when claimed in submission.toml. The grader exercises URL linking, automatic signup login, JSON messages, mentions, and Markdown through your app. Other optional features need a live demonstration or inspection of their SQL, browser behavior, or outside-service evidence. Their Gradescope results say that instructor review is pending and do not award points merely for finding a keyword in the code. The themed-design task remains a 4-point instructor review because visual quality is subjective. During the demo, the instructor also checks the required database fields, creation times, logout cookies, and injection protections. No particular timestamp format is required; if the grader cannot identify your displayed times, that route is flagged for review.
Warning: If I can break into your site with a SQL injection attack, you take a -13 point penalty.
Warning: If I can break into your site with an HTML injection attack, you take a -5 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 extra tasks as a buffer in case a feature breaks during the demo or does not meet the rubric.
Required Tasks
Each required task is worth 6 points and matches one route on your site.
-
-
(this check exists to make you confront SQL and HTML injection early)
-
-
Hint: Don’t use
type=texton yourinputtag. Find the input type meant for passwords.
-
-
Hint: We didn’t cover deleting cookies in class, but this StackOverflow post explains it.
-
-
Hint: You know an account already exists because the
INSERTfails with a sqlite error about violating a unique constraint.
-
Extra Credit
The following tasks are each worth 4 points:
-
I’ll use my own aesthetic judgment for what counts as “nicely themed,” but the simple CSS from the start of the course is sufficient.
-
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 8 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 4-point task for linking URLs.
The following tasks are each worth 12 points of extra credit:
-
Hint: This pairs well with the 8-point reply task.
Submit
Add submission.toml at the repository root so the grader does not have to guess your module, route names, or HTML form-field names:
[app]
module = "main" # Python import path, without .py
object = "app" # FastAPI object in that module
home = "/"
login = "/login"
logout = "/logout"
signup = "/create_user"
new_message = "/create_message"
[forms]
username = "username"
password = "password"
password_confirm = "password2"
message = "message"
[features]
# Use true for structural features, a route path for route-based features,
# and a URL for published_site. Delete or leave false anything not claimed.
linked_urls = false
large_seed = false
delete_messages = false
edit_messages = false
delete_accounts = false
signup_login = false
change_password = false
user_images = false
messages_json = false
published_site = false
pagination = false
profiles = false
mentions = false
search = false
fts5 = false
email_reset = false
replies = false
nested_replies = false
languages = false
markdown = false
javascript_crud = false
ai_account = falseFor example, claiming a JSON route would use messages_json = "/messages.json", and claiming a published site would use published_site = "https://your-site.example/". For a route with a parameter, use its registered pattern, such as delete_messages = "/messages/{message_id}/delete". Unclaimed optional tests are skipped and do not lower your score. Claimed features awaiting review retain their published point values; the instructor adds any earned points after the demonstration.
Commit and sync the required files. On Gradescope, choose GitHub and submit your twitter-clone repository and the branch containing your commit by 11:59pm on Wednesday, December 16.
You will also give a five-to-fifteen-minute one-on-one demo during the official final slot, Wednesday, December 16 from 2:00–5:00pm. The automated result shows the checks the grader can run; use the demo to show the themed design, claimed features awaiting review, and outside-service evidence. Before your slot, push the version you plan to show and confirm that the site launches.