How xhxhkxh/lfm works
Project Type & Purpose
• This is a monolithic full-stack web application: a lightweight, responsive forum built with Flask (Python) and MySQL.
• The “app.py” file contains all route handlers and the SQL class (Model), while the “templates/” folder holds the view layer (HTML + inline CSS/JS), and “static/” holds supporting assets (robots.txt, fonts).
a. Client (Browser/Mobile)
• Sends HTTP(s) requests and renders HTML/CSS/JS.
• Interacts with both desktop templates and mobile-specific templates (e.g., forum-m.htm).
b. Reverse Proxy / Load Balancer (optional in production)
• Nginx or similar that fronts your Gunicorn WSGI server.
c. WSGI Application Server
• Gunicorn (for production) or Flask’s built-in development server.
• Hosts the Flask app (app.py).
d. Flask Application (“app.py”)
• Router / Controller layer: defines endpoints (/forum, /home/login, /post/comment/<id>, etc.).
• Business logic: session management, Argon2 hashing, hCaptcha validation, Markdown processing.
• SQL class: encapsulates MySQL connection parameters and query execution.
e. Templates & Static Assets
• templates/: HTML view layer (Jinja2 templates).
• templates/scripts/crypto.js: client-side crypto routines.
• static/: CSS, robots.txt, optional images.
• fonts/: HarmonyOS Sans TTF.
f. MySQL Database
• Tables: users, posts, reply.
• Data persistence for forum content, user credentials, comments.
g. External Services
• hCaptcha API: spam/bot protection.
• (Future) Email provider for verification.
• User → HTTP Request → Nginx → Gunicorn → Flask Routes
• Flask Route → (reads/writes) → MySQL
• Flask Route → selects Jinja template → renders HTML → Response → Browser
• Browser → loads CSS/JS/Fonts from static/ and fonts/
• During signup/login → Flask → hCaptcha service (verify token) → hCaptcha API → Flask
• Session cookies set in HTTP response and returned on subsequent requests
Architectural Patterns & Design Principles
• MVC-inspired separation:
• Model: SQL class + MySQL
• View: Jinja2 templates + static assets
• Controller: Flask route handlers in app.py
• Modular design: clearly separated folders for templates and static.
• Security best practices: parameterized queries, Argon2 hashing, XSS prevention via automatic escaping, session timeouts.
• Mobile-first design: dedicated mobile templates under templates/
• Python 3.7+ / Flask
• MySQL
• Gunicorn + Nginx (production)
• Jinja2 templating
• Argon2 (password hashing)
• hCaptcha API
• Markdown parser (if used)