# dhruvjoshi137/mood-match-final architecture

> Architecture diagram of the GitHub repository dhruvjoshi137/mood-match-final, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhruvjoshi137/mood-match-final
- Repository: https://github.com/dhruvjoshi137/mood-match-final

## Overview

#### Purpose and Entry Points
Mood Match generates Pinterest-style moodboards from user text: it derives emotional/design signals, finds matching images, coordinates colors, and returns a downloadable visual result. The primary backend entry point is `backend/app.py`; production WSGI hosting is exposed through `wsgi.py`. The browser-facing UI is static HTML/CSS, centered on `Main.html` and `Main.css`.

#### 1. Static Browser Interface
The frontend collects text input, presents generated moodboard output, and supports download-oriented interaction. It is intentionally separate from the Python service and can be opened directly or hosted as static files.
- `Main.html`
- `Main.css`
- `Home.html`

#### 2. Flask API and Request Orchestration
`backend/app.py` is the application boundary between the browser and generation pipeline. It should own HTTP routes, input validation, invoking emotion/image/moodboard stages, and serializing generated results. Backend behavior is therefore callable independently of the static frontend.
- `backend/app.py`
- `wsgi.py`
- `backend/README.md`

#### 3. Emotion and Prompt-Signal Extraction
Text is transformed into emotional labels and important terms before image selection. `detect_important.py` appears to isolate salient words/design concepts, while the ML package provides training and runtime inference. The dataset/keyword assets form the model’s local knowledge boundary.
- `backend/detect_important.py`
- `backend/ML/inference.py`
- `backend/emotion_design_dataset.json`

#### 4. ML Training versus Runtime Inference
Model development is separated from serving: `train.py` builds or updates the classifier, `model.py` defines model-related behavior, and `inference.py` applies it to live user text. Production requests should use inference only; retraining is an offline workflow with dependency and model-artifact implications.
- `backend/ML/train.py`
- `backend/ML/model.py`
- `backend/ML/inference.py`

#### 5. Image Discovery and Moodboard Composition
The generation stage uses external visual sources—Pinterest scraping and Pexels according to the project description—then composes selected images into a color-coordinated board. Selenium/Chrome WebDriver is a material runtime dependency for browser-driven scraping; Pillow handles image processing. Generated/intermediate image material is local to the backend image area.
- `backend/app.py`
- `backend/images`
- `backend/colour.json`

#### 6. Primary Control and Data Flow
1. A user submits descriptive text through the static UI.
2. The UI calls Flask in `backend/app.py`.
3. Flask derives important terms and emotion/design classification via `backend/detect_important.py` and `backend/ML/inference.py`.
4. Those signals drive remote image retrieval/scraping.
5. The backend selects colors, composes images, and returns a moodboard/download response to the client.

Important boundaries are: browser ↔ Flask HTTP API; Flask ↔ local ML/data assets; backend ↔ Pinterest/Pexels; and Selenium ↔ installed Chrome/WebDriver runtime.

#### 7. Deployment and Runtime Shape
The repository supports process-based Python deployment with a WSGI entry point and Heroku-oriented process metadata. It also includes Render/Nixpacks deployment descriptors, while the README identifies a split deployment model of backend hosting plus static frontend hosting.
- `Procfile`
- `runtime.txt`
- `render.yaml`
- `nixpacks.toml`
- `requirements.txt`

Main entry points: [`backend/app.py`](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py) (Flask API), [`Main.html`](https://github.com/dhruvjoshi137/mood-match-final/blob/main/Main.html) (Moodboard UI), [`backend/ML/inference.py`](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/inference.py) (Live inference), [`requirements.txt`](https://github.com/dhruvjoshi137/mood-match-final/blob/main/requirements.txt) (Python dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Static Frontend"]
  node_browser_ui["Moodboard UI<br/>static web UI<br/>[Main.html]"]
  node_ui_styles["UI styles<br/>CSS<br/>[Main.css]"]
  node_home_page["Home page<br/>static HTML<br/>[Home.html]"]
end

subgraph group_backend["Generation Backend"]
  node_flask_api["Flask API<br/>Python service<br/>[app.py]"]
  node_image_discovery["Image discovery<br/>retrieval stage<br/>[app.py]"]
  node_composition["Moodboard composition<br/>image processing<br/>[app.py]"]
  node_color_palette["Color mappings<br/>color data<br/>[colour.json]"]
  node_image_storage[("Generated images<br/>local image area")]
end

subgraph group_ml["ML Signals"]
  node_keyword_extractor["Important-term extraction<br/>signal extraction"]
  node_inference["Live inference<br/>ML runtime<br/>[inference.py]"]
  node_model["Model definition<br/>ML model<br/>[model.py]"]
  node_training["Offline training<br/>ML pipeline<br/>[train.py]"]
  node_emotion_dataset[("Emotion/design dataset<br/>local dataset")]
end

subgraph group_deployment["Deployment Runtime"]
  node_wsgi["WSGI entry<br/>WSGI adapter<br/>[wsgi.py]"]
  node_process_config["Process deployment<br/>deployment config"]
  node_dependencies["Python dependencies<br/>runtime dependencies<br/>[requirements.txt]"]
end

node_visual_sources(("Pinterest and Pexels<br/>external image sources"))
node_selenium{{"Chrome WebDriver<br/>browser runtime"}}

node_browser_ui -->|"styled by"| node_ui_styles
node_home_page -->|"links to"| node_browser_ui
node_browser_ui -->|"HTTP generation request"| node_flask_api
node_wsgi -->|"serves"| node_flask_api
node_flask_api -->|"extracts terms"| node_keyword_extractor
node_flask_api -->|"classifies text"| node_inference
node_keyword_extractor -->|"search signals"| node_image_discovery
node_inference -->|"emotion/design signals"| node_image_discovery
node_inference -->|"uses"| node_model
node_training -->|"trains"| node_model
node_emotion_dataset -->|"training data"| node_training
node_image_discovery -->|"retrieves images"| node_visual_sources
node_image_discovery -.->|"scraping runtime"| node_selenium
node_image_discovery -->|"selected images"| node_composition
node_color_palette -->|"color coordination"| node_composition
node_composition -->|"writes board assets"| node_image_storage
node_composition -->|"generated result"| node_flask_api
node_flask_api -->|"moodboard response"| node_browser_ui
node_process_config -->|"launches"| node_wsgi
node_dependencies -.->|"provides runtime packages"| node_flask_api
node_dependencies -.->|"provides automation package"| node_selenium

click node_browser_ui "https://github.com/dhruvjoshi137/mood-match-final/blob/main/Main.html"
click node_ui_styles "https://github.com/dhruvjoshi137/mood-match-final/blob/main/Main.css"
click node_home_page "https://github.com/dhruvjoshi137/mood-match-final/blob/main/Home.html"
click node_flask_api "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py"
click node_wsgi "https://github.com/dhruvjoshi137/mood-match-final/blob/main/wsgi.py"
click node_keyword_extractor "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/detect_important.py"
click node_inference "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/inference.py"
click node_model "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/model.py"
click node_training "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/train.py"
click node_emotion_dataset "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/emotion_design_dataset.json"
click node_image_discovery "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py"
click node_composition "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py"
click node_color_palette "https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/colour.json"
click node_image_storage "https://github.com/dhruvjoshi137/mood-match-final/tree/main/backend/images"
click node_process_config "https://github.com/dhruvjoshi137/mood-match-final/tree/main/Procfile"
click node_dependencies "https://github.com/dhruvjoshi137/mood-match-final/blob/main/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser_ui,node_ui_styles,node_home_page toneBlue
class node_flask_api,node_image_discovery,node_composition,node_color_palette,node_image_storage toneAmber
class node_keyword_extractor,node_inference,node_model,node_training,node_emotion_dataset toneMint
class node_wsgi,node_process_config,node_dependencies toneRose
class node_visual_sources,node_selenium toneNeutral
```

## Components

### Static Frontend

- [Moodboard UI](https://github.com/dhruvjoshi137/mood-match-final/blob/main/Main.html): static web UI · Collects text, displays boards, and supports downloads. · `Main.html`
- [UI styles](https://github.com/dhruvjoshi137/mood-match-final/blob/main/Main.css): CSS · `Main.css`
- [Home page](https://github.com/dhruvjoshi137/mood-match-final/blob/main/Home.html): static HTML · `Home.html`

### Generation Backend

- [Flask API](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py): Python service · Validates requests and orchestrates generation. · `backend/app.py`
- [Image discovery](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py): retrieval stage · Uses extracted signals to obtain candidate imagery. · `backend/app.py`
- [Moodboard composition](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/app.py): image processing · Coordinates colors and assembles the downloadable board. · `backend/app.py`
- [Color mappings](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/colour.json): color data · `backend/colour.json`
- [Generated images](https://github.com/dhruvjoshi137/mood-match-final/tree/main/backend/images): local image area · Stores intermediate and generated visual material. · `backend/images`

### ML Signals

- [Important-term extraction](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/detect_important.py): signal extraction · `backend/detect_important.py`
- [Live inference](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/inference.py): ML runtime · Classifies emotion and design signals for requests. · `backend/ML/inference.py`
- [Model definition](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/model.py): ML model · `backend/ML/model.py`
- [Offline training](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/ML/train.py): ML pipeline · Builds or updates model artifacts outside serving. · `backend/ML/train.py`
- [Emotion/design dataset](https://github.com/dhruvjoshi137/mood-match-final/blob/main/backend/emotion_design_dataset.json): local dataset · `backend/emotion_design_dataset.json`

### Deployment Runtime

- [WSGI entry](https://github.com/dhruvjoshi137/mood-match-final/blob/main/wsgi.py): WSGI adapter · `wsgi.py`
- [Process deployment](https://github.com/dhruvjoshi137/mood-match-final/tree/main/Procfile): deployment config · Defines Python process-based hosting. · `Procfile`
- [Python dependencies](https://github.com/dhruvjoshi137/mood-match-final/blob/main/requirements.txt): runtime dependencies · `requirements.txt`

### Other components

- **Pinterest and Pexels**: external image sources
- **Chrome WebDriver**: browser runtime · Supports browser-driven Pinterest scraping.

## Connections

- Moodboard UI → UI styles: styled by
- Home page → Moodboard UI: links to
- Moodboard UI → Flask API: HTTP generation request
- WSGI entry → Flask API: serves
- Flask API → Important-term extraction: extracts terms
- Flask API → Live inference: classifies text
- Important-term extraction → Image discovery: search signals
- Live inference → Image discovery: emotion/design signals
- Live inference → Model definition: uses
- Offline training → Model definition: trains
- Emotion/design dataset → Offline training: training data
- Image discovery → Pinterest and Pexels: retrieves images
- Image discovery → Chrome WebDriver: scraping runtime
- Image discovery → Moodboard composition: selected images
- Color mappings → Moodboard composition: color coordination
- Moodboard composition → Generated images: writes board assets
- Moodboard composition → Flask API: generated result
- Flask API → Moodboard UI: moodboard response
- Process deployment → WSGI entry: launches
- Python dependencies → Flask API: provides runtime packages
- Python dependencies → Chrome WebDriver: provides automation package
