How nietocurcio/cs50-final-project works
Main Components
• Web Server / Application Layer:
• Files: application.py and login.py contain the core Flask routes and business logic.
• Frontend:
• Templates: HTML files (layout.html, index.html, adopt.html, login.html, recordsDonation.html, register.html) represent different web pages.
• Static Assets: stylesheets (static/styles.css) and static images (in static/images and static/images/users) are used to display the site’s visual content.
• Database Layer:
• The SQLite database (dogscats.db as described in the README) accessed via Flask-SQLAlchemy.
• Tables: users, cases, and selectedcases with defined relationships (e.g., foreign keys between users and cases).
• File Management:
• Handling of file uploads using Flask-WTF, ensuring image filenames are validated and stored safely (into static/images/users).
Relationships and Interactions
• The Frontend (client-side) sends HTTP requests to the backend.
• The Flask application receives these requests (from application.py and login.py), processes the business logic, and interacts with the database through SQLAlchemy.
• File uploads (e.g., pet images) are processed, validated, and saved to the filesystem (static/images/users), while their metadata (the filename) is stored in the database.
• After processing, Flask renders the appropriate HTML templates (from the templates folder) and sends an HTTP response back to the client.
• The database holds all user records, donation cases, and relationships (selectedcases) and is accessed for creating, reading, updating, and deleting records.
Architectural Patterns
• MVC (Model-View-Controller) Pattern:
• The ‘Model’ is represented by the SQLAlchemy models (even if not explicitly named as such, they are created via SQLAlchemy in the application).
• The ‘View’ is constructed via HTML templates.
• The ‘Controller’ aspect is handled in the Flask routes defined in application.py and login.py.
• Separation of Concerns:
• Frontend (templates, static resources) is cleanly separated from backend logic (Python scripts).
• Database interactions are centralized via Flask-SQLAlchemy.
Technologies and Frameworks
• Python, Flask, Flask-SQLAlchemy, Flask-WTF, and SQLite.
• HTML/CSS for client-side presentation.
• sqlite3 for database management.
Final Advice
• On potential extensions by including any external libraries (Flask-WTF for file handling, etc.) that add value to the architecture.