# srimayeebhattacharyya/happyhappy-mental-wellness-website- architecture

> Architecture diagram of the GitHub repository srimayeebhattacharyya/happyhappy-mental-wellness-website-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-
- Repository: https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components
    subgraph "User Layer"
        Browser["Web Browser (Desktop/Mobile)"]:::frontend
    end

    subgraph "Heroku Dyno" 
        direction TB
        ProcfileNode["Procfile"]:::infra
        Gunicorn["Gunicorn Worker"]:::backend
        FlaskApp["Flask Application"]:::backend
        Controllers["Route Handlers / Controllers"]:::backend
        TemplateEngine["Template Engine (Jinja2)"]:::backend
        StaticServer["Static File Server (CSS & Images)"]:::frontend
        createDB["Database Init Script (create_db.py)"]:::infra
        ProcfileNode -->|"web: gunicorn app:app"| Gunicorn
        Gunicorn -->|"WSGI"| FlaskApp
        FlaskApp --> Controllers
        FlaskApp --> TemplateEngine
        FlaskApp --> StaticServer
    end

    subgraph "Persistence Layer"
        direction TB
        SQLiteDB["SQLite Database (happyhappy.db)"]:::data
        SessionStore["Server-side Session Store"]:::data
    end

    subgraph "External Services"
        NLP["External NLP/AI Service"]:::external
    end

    %% Connections
    Browser -->|"HTTP Request"| ProcfileNode
    Controllers -->|"SQL Read/Write"| SQLiteDB
    Controllers -->|"Session Read/Write"| SessionStore
    Controllers -->|"Render HTML"| TemplateEngine
    Browser -->|"Static GET"| StaticServer
    Controllers -->|"Chatbot Query"| NLP
    NLP -->|"AI Response"| Controllers
    FlaskApp -->|"HTTP Response"| Browser
    createDB -->|"Initializes"| SQLiteDB

    %% Click Events
    click FlaskApp "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/app.py"
    click Controllers "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/app.py"
    click TemplateEngine "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/tree/main/templates/"
    click StaticServer "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/tree/main/static/"
    click SQLiteDB "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/happyhappy.db"
    click DBInit "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/create_db.py"
    click SessionStore "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/tree/main/flask_session/"
    click ProcfileNode "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/tree/main/Procfile"
    click Requirements "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/requirements.txt"
    click README "https://github.com/srimayeebhattacharyya/happyhappy-mental-wellness-website-/blob/main/README.md"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef data fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef infra fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef external fill:#f5f5f5,stroke:#000,stroke-width:1px;
```
