How justinlin63/flask_project1130 works
Project type and purpose
• This is a monolithic, server-rendered full-stack web application built with Flask.
• It uses Blueprints (one per business function: home, login, register, cart, orders, pay, admin, redirect, reset_password) to separate routes/controllers.
• It renders HTML templates on the server side and persists data in a MySQL database.
File structure
• Top-level entrypoint: run.py – initializes Flask app, loads app/config.py, registers all Blueprints under app/functions/*/route.py.
• app/config.py – central configuration (e.g., database URI, secret keys).
• app/functions/ – each subfolder is a Flask Blueprint:
– route.py files define HTTP endpoints.
– use_model.py files encapsulate business logic and call into the model layer.
• app/functions/models/ – the data layer:
– sql_connect.py opens/closes MySQL connections.
– sql_setting.py holds SQL parameters.
– Domain objects/utilities (e.g., user.py, useful_string.py).
• app/templates/ – Jinja2 templates grouped per Blueprint.
• app/static/assets/ – CSS/JS/images for client.
• requirements.txt – Python dependencies (Flask, PyMySQL, etc.).
• Deployment consideration: likely run behind a WSGI server (e.g., Gunicorn).
Key insights from README
• The application requires MySQL.
• Developer must configure database connection in app/config.py before starting.
How to model the system
1. Client (browser)
2. Web Server/Flask App
– Entrypoint: run.py
– Config module
– Blueprints (controllers): home, login, register, cart, orders, pay, admin, redirect, reset_password
– Templates (views)
– Static assets
– Model layer (data access): sql_connect, domain model files
3. MySQL Database
• Client → HTTP request → Flask App (Blueprint route)
• Blueprint route → calls use_model → model layer → SQL connector → MySQL
• Model layer → returns results → Blueprint route → renders templates → HTTP response → Client
• Static asset requests → Flask static handler → Client
c. Architectural patterns & principles:
• MVC-style separation:
– Controllers = route.py
– Models = app/functions/models/*
– Views = app/templates/*
• Modularization via Flask Blueprints
• Single shared configuration file
• Centralized DB connection management
• Server-side rendering with Jinja2
d. Technologies / frameworks:
• Python 3, Flask
• Jinja2 templating
• PyMySQL or MySQLdb
• MySQL server
• WSGI server (Gunicorn/uWSGI) for production