# chitranshu0/music-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/chitranshu0/music-recommendation-system
- Repository: https://github.com/chitranshu0/music-recommendation-system

## Overview

##### Project type and purpose
- This is a full-stack, single-page Flask web application that serves as a music recommendation system.
- Purpose: Users enter a song name via a web form; the backend uses a pre-trained ML model (CountVectorizer + cosine similarity) to return a list of similar songs.

##### File structure
- Top-level:
- app.py – Flask application entry point
- data/ – raw CSV (ex.csv) of song features
- model/ – serialized artifacts (musicrec.pkl, similarities.pkl) and a CSV copy
- static/ – CSS file for styling
- templates/ – Jinja2 HTML views (index.html, recommend.html)
- Training Notebooks (optional) – illustrate model-building process but not part of runtime
- No separate frontend framework; UI lives in Flask’s templates.
- No external database: recommendations run in memory, loading pickles and CSV at startup.

##### README for additional insights
- Tech stack: Python (pandas, scikit-learn), Flask, CountVectorizer, Cosine Similarity
- Workflow: Data cleaning → vectorization → similarity matrix → serve via web form.

##### Elements
– Clear labels: “Browser,” “Flask app.py,” “Recommendation Engine,” “Pickle Files,” “Templates/Static”
- Browser → Flask (form data)
- Flask → Recommendation Engine (function call)
- Engine → Data Storage (file read)
- Flask → Browser (HTML response)
- Rectangle (services/components)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser UI"]:::client

    %% Presentation Layer
    subgraph "Presentation Layer"
        Index["templates/index.html"]:::view
        Recommend["templates/recommend.html"]:::view
        Style["static/style.css"]:::view
    end

    %% Server Layer
    App["Flask app.py\n(routes: '/', '/recommend')"]:::server

    %% ML Components
    subgraph "ML Components"
        ModelLoader["Model Loader"]:::ml
        Engine["Recommendation Engine\n(CountVectorizer + Cosine Similarity)"]:::ml
    end

    %% Data Storage
    subgraph "Data Storage" 
        RawCSV["data/ex.csv"]:::storage
        ModelCSV["model/ex.csv"]:::storage
        Pickle1["model/musicrec.pkl"]:::storage
        Pickle2["model/similarities.pkl"]:::storage
    end

    %% Offline Training
    subgraph "Offline Training"
        Notebook1["Training Model.ipynb"]:::offline
        Notebook2[".ipynb_checkpoints/Training Model-checkpoint.ipynb"]:::offline
        Notebook3[".ipynb_checkpoints/Untitled-checkpoint.ipynb"]:::offline
    end

    %% Connections
    Browser -->|GET form| App
    Browser -->|POST song name| App
    App -->|loads at startup| ModelLoader
    ModelLoader -->|reads| Pickle1
    ModelLoader -->|reads| Pickle2
    ModelLoader -->|reads| ModelCSV
    App -->|invoke| Engine
    Engine -->|lookup metadata| RawCSV
    Engine -->|uses vectorizer+similarity| ModelLoader
    Engine -->|returns recommendations| App
    App -->|render HTML| Index
    App -->|render HTML| Recommend
    Index -->|loads CSS| Style
    Recommend -->|loads CSS| Style
    Notebook1 --->|produces artifacts| Pickle1
    Notebook1 --->|produces artifacts| Pickle2
    Notebook1 --->|produces artifacts| ModelCSV

    %% Click Events
    click Index "https://github.com/chitranshu0/music-recommendation-system/blob/main/templates/index.html"
    click Recommend "https://github.com/chitranshu0/music-recommendation-system/blob/main/templates/recommend.html"
    click Style "https://github.com/chitranshu0/music-recommendation-system/blob/main/static/style.css"
    click App "https://github.com/chitranshu0/music-recommendation-system/blob/main/app.py"
    click Pickle1 "https://github.com/chitranshu0/music-recommendation-system/blob/main/model/musicrec.pkl"
    click Pickle2 "https://github.com/chitranshu0/music-recommendation-system/blob/main/model/similarities.pkl"
    click ModelCSV "https://github.com/chitranshu0/music-recommendation-system/blob/main/model/ex.csv"
    click RawCSV "https://github.com/chitranshu0/music-recommendation-system/blob/main/data/ex.csv"
    click Notebook1 "https://github.com/chitranshu0/music-recommendation-system/blob/main/Training Model.ipynb"
    click Notebook2 "https://github.com/chitranshu0/music-recommendation-system/blob/main/.ipynb_checkpoints/Training Model-checkpoint.ipynb"
    click Notebook3 "https://github.com/chitranshu0/music-recommendation-system/blob/main/.ipynb_checkpoints/Untitled-checkpoint.ipynb"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef server fill:#bbf,stroke:#333,stroke-width:1px
    classDef view fill:#bfb,stroke:#333,stroke-width:1px
    classDef ml fill:#ffb,stroke:#333,stroke-width:1px
    classDef storage fill:#fbf,stroke:#333,stroke-width:1px
    classDef offline fill:#ddd,stroke:#333,stroke-width:1px
```
