How srimayeebhattacharyya/happyhappy-mental-wellness-website- works
Project type and purpose
• This is a monolithic, server-rendered web application built with Python’s Flask framework.
• Purpose: a mental-wellness website (“HappyHappy”) offering static pages (Affirmations, Stories, Self-help), user journal, moods logging, and a chatbot-like interface.
• Likely deployed on Heroku (Procfile present), using SQLite for persistence.
File structure
Top-level files
• Procfile – deployment manifest (Heroku).
• requirements.txt – Python dependencies (Flask, flask-session, etc.).
• app.py – main Flask application defining routes and business logic.
• create_db.py – script to initialize or migrate the SQLite database (happyhappy.db).
• happyhappy.db – SQLite database storing user data (journals, moods).
• flask_session/ – server-side session store directory.
Folders
• static/
– images, seven CSS files (style.css, style1.css … style7.css).
• templates/
– Jinja2 HTML templates for each page (index, login, chatbot, journal, moods, etc.).
README
• Minimal content: “WELCOME TO MENTAL WELLNESS WEBSITE: HAPPYHAPPY.”
Components
a. End Users & Clients
• Web Browser (desktop/mobile).
b. Web Server Layer
• Flask Application (app.py)
• Route Handlers / Controllers (login, journal, moods, chatbot endpoints).
• Template Engine (Jinja2 → HTML).
• Static File Server (serves CSS/images).
c. Persistence Layer
• SQLite database (happyhappy.db) via SQLAlchemy or raw SQLite calls.
• Server-side Session Store (flask_session directory).
d. Deployment & Infrastructure
• Heroku Dyno (Procfile).
• Local filesystem (for sessions and DB).
e. (Optional) External Services
Relationships and data-flow
1. Browser issues HTTP(S) request →
2. Heroku load-balancer → Flask App (Procfile declares web: gunicorn app:app or similar) →
3. Flask route logic:
– Reads/Writes user data from SQLite.
– Reads/Writes session data in flask_session.
– Renders a Jinja2 template (templates/*.html) with dynamic data.
– Serves CSS/images from /static.
4. Flask returns HTTP response → Browser renders HTML + CSS.
Architectural patterns & design principles
• MVC-style separation:
– Model: SQLite + session files.
– View: Jinja2 templates + static assets.
– Controller: Flask route functions in app.py.
• Monolithic deployment: all layers bundled into a single Heroku dyno.
• Server-side sessions (flask_session) instead of client cookies.
• Simple layering—no microservices.
Detailed callouts
• Procfile generating a Gunicorn worker:
[Procfile] → “web: gunicorn app:app” → Flask process.
• Create_db.py as a one-time or CI/CD step for DB initialization.