How ttt3216/quiz_cs402 works
Project type and purpose
• This is a lightweight, full-stack web application built in Python (likely using Flask) that serves a quiz to users via HTML templates.
• Key indicators: a single Python script (q2.py), a templates/ folder with HTML files, words.json for quiz data, a requirements.txt for dependencies, and a Procfile (suggesting deployment on Heroku or a similar PaaS).
File structure
• Top-level files:
• q2.py: the main application entry point (defines routes, quiz logic, data loading)
• requirements.txt: Python packages (Flask, etc.)
• Procfile: process declaration for deployment
• words.json: quiz questions/answers datastore
• templates/: directory containing view templates (index.html, quiz.html, log.html, confirm_quit.html)
• There are no separate “frontend” and “backend” folders; instead, this is a monolithic web app where Python code serves HTML.
README
• Very minimal (# quiz_cs402). No architecture notes, so we infer from file names and conventions: routing → template rendering → data store access.
a. Main components:
• Client Browser (User Interface)
• Web Server / WSGI Container (e.g., Gunicorn, Flask built-in)
• Flask Application (q2.py)
• Template Engine (Jinja2, built into Flask)
• Data Store (words.json)
• Logging Component (could be a log file or database)
• Deployment Platform (Heroku dyno or equivalent)
b. Relationships / Interactions:
1. User (Client) sends HTTP request → Web Server
2. Web Server forwards request → Flask App
3. Flask App reads words.json (data store) to generate quiz content
4. Flask App uses Template Engine to render HTML with data
5. Flask App returns HTTP response → Web Server → Client
6. Flask App writes user responses / quiz logs to a log file or database (if implemented)
7. Web Server / Procfile indicates how the application is run on the Deployment Platform
c. Architectural patterns / design principles:
• MVC-style separation:
• Model: words.json and log storage
• View: HTML templates in templates/
• Controller: route handlers in q2.py
• Single-page flow with multiple routes (/, /quiz, /log, /confirm_quit)
d. Key technologies / frameworks:
• Python 3.x, Flask (HTTP routing + template rendering), Jinja2 (templating), JSON file as simple datastore, Gunicorn or Flask dev server, deployed via Heroku (Procfile).