Skip to content

ADiTyaRaj8969/ManTarang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ManTarang Banner

Typing SVG

Live Demo Python React FastAPI Docker


πŸ“Œ Table of Contents


🎡 About the Project

ManTarang is a Music Emotion Recognition (MER) system built on a 4-agent collaborative AI architecture. When a user types a natural-language query, four specialized AI agents coordinate in a pipeline β€” each with a distinct role β€” to produce ranked, explainable music recommendations.

Each agent contributes its expertise. The Planner leads, two specialists generate candidates, and the Judge delivers the final verdict.

Query Planner decides Agents activated Output
"songs like Radiohead" Similarity strategy Discovery + GenreMood Genre-DNA matched tracks
"chill lo-fi for studying" Context strategy GenreMood lo-fi / chillhop ranked list
"dark indie rock" Genre strategy GenreMood + Discovery Confidence-scored results
"energetic hip hop" Mood strategy GenreMood High-energy ranked tracks

πŸ€– 4-Agent Architecture

graph TD
    USER["πŸ‘€ User Query\nNatural Language Input"]

    subgraph AGENTS["  4-Agent Collaborative System  "]
        P["🧭 Planner Agent\n─────────────────\nOrchestrates the entire pipeline\nAnalyses query intent and complexity\nExtracts entities: artist, genre, mood\nCreates agent coordination plan\nDetermines which agents to activate"]

        G["🎼 GenreMood Agent\n─────────────────\nMood detection and analysis\nGenre matching and filtering\nTag generation and enhancement\nContext-aware intent adaptation\nCandidate generation by genre/mood"]

        D["πŸ”­ Discovery Agent\n─────────────────\nMulti-hop similarity exploration\nUnderground and hidden gem detection\nSerendipitous discovery beyond mainstream\nNovelty-optimized recommendations\nArtist similarity graph traversal"]

        J["βš–οΈ Judge Agent\n─────────────────\nCollects all agent candidates\nScores and ranks with RankingEngine\nOptimizes diversity with DiversityOptimizer\nGenerates human-readable explanations\nDelivers final ranked recommendations"]
    end

    RESULT["βœ… Final Recommendations\nRanked Β· Scored Β· Explained"]

    USER --> P
    P -->|genre/mood query| G
    P -->|similarity/discovery query| D
    G -->|genre candidates| J
    D -->|discovery candidates| J
    J --> RESULT

    style P fill:#2D1B69,stroke:#C9A227,color:#fff
    style G fill:#1e3a5f,stroke:#61DAFB,color:#fff
    style D fill:#1a3a1a,stroke:#6ee7b7,color:#fff
    style J fill:#3b1515,stroke:#f9a8d4,color:#fff
    style AGENTS fill:#0d0d1a,stroke:#7C3AED,color:#fff
Loading

πŸ”„ Agent Collaboration Flow

sequenceDiagram
    actor User
    participant P as 🧭 Planner Agent
    participant G as 🎼 GenreMood Agent
    participant D as πŸ”­ Discovery Agent
    participant J as βš–οΈ Judge Agent

    User->>P: Natural language query
    Note over P: Analyse intent, extract entities<br/>Determine strategy and complexity<br/>Build coordination plan

    P->>G: Activate with genre/mood parameters
    P->>D: Activate with similarity parameters

    Note over G: Detect mood signals<br/>Match genre tags<br/>Generate genre candidates
    Note over D: Explore artist similarity graph<br/>Detect underground gems<br/>Generate discovery candidates

    G-->>J: Genre/Mood candidate pool
    D-->>J: Discovery candidate pool

    Note over J: Merge all candidates<br/>Score with RankingEngine<br/>Optimise diversity<br/>Generate explanations

    J-->>User: Final ranked recommendations<br/>with metrics and confidence
Loading

🧠 Agent Deep Dive

🧭 Agent 1 β€” Planner Agent

The orchestrator. Runs first. Decides everything else.

flowchart TD
    QA["QueryAnalyzer\nParse query complexity\nDetect ambiguity\nExtract primary intent"]
    CA["ContextAnalyzer\nInterpret context signals\nHandle effective intent overrides\nTransform raw context"]
    EP["EntityProcessor\nExtract: artist name\nExtract: genre keywords\nExtract: mood signals\nExtract: context triggers"]
    SP["StrategyPlanner\nSelect recommendation strategy\nDecide agent activation order\nSet parameters per agent\nBuild coordination plan"]

    QA --> CA --> EP --> SP
Loading

Outputs to: GenreMood Agent + Discovery Agent with a structured coordination plan.


🎼 Agent 2 β€” GenreMood Agent

The emotion specialist. Translates feelings into music.

flowchart TD
    MA["MoodAnalyzer\nDetect mood from query\nhappy / sad / energetic\nchill / romantic / focused"]
    GP["GenreProcessor\nMatch genre tags\nExpand via alias maps\nFilter by genre overlap"]
    TG["TagGenerator\nGenerate enhanced tags\nCombine genre and mood signals\nContext-aware tag boost"]
    UCG["UnifiedCandidateGenerator\nGenerate candidates\nby genre and mood\nfrom dataset"]
    QS["QualityScorer\nScore genre fit\nScore mood alignment\nScore popularity balance"]

    MA --> TG
    GP --> TG
    TG --> UCG --> QS
Loading

Outputs to: Judge Agent with a pool of genre/mood-matched track candidates.


πŸ”­ Agent 3 β€” Discovery Agent

The explorer. Finds what you didn't know you needed.

flowchart TD
    DC["DiscoveryConfig\nSet novelty parameters\nConfigure similarity depth\nSet underground threshold"]
    SE["SimilarityExplorer\nMulti-hop artist graph\nExplore genre neighbours\nFind sonic relatives"]
    UD["UndergroundDetector\nDetect hidden gems\nScore novelty vs popularity\nFind non-mainstream tracks"]
    DF["DiscoveryFilter\nFilter irrelevant candidates\nRemove duplicates\nApply quality threshold"]
    DD["DiscoveryDiversity\nManage variety\nPrevent artist clustering\nBalance mainstream vs niche"]

    DC --> SE
    DC --> UD
    SE --> DF
    UD --> DF
    DF --> DD
Loading

Outputs to: Judge Agent with a pool of discovery/similarity candidates.


βš–οΈ Agent 4 β€” Judge Agent

The final decision maker. Ranks, diversifies, and explains.

flowchart TD
    CS["CandidateSelector\nCollect all agent pools\nFilter by quality threshold\nRemove duplicates"]
    RE["RankingEngine\nMulti-criteria scoring\nGenre match weight\nPopularity fit weight\nArtist credibility weight"]
    DO["DiversityOptimizer\nPrevent artist repetition\nBalance genre spread\nOptimize result variety"]
    EG["ExplanationGenerator\nGenerate per-track reasons\nCalculate confidence score\nBuild human-readable text"]

    CS --> RE --> DO --> EG
Loading

Outputs: Final ranked recommendations with metrics, confidence, and explanations.


πŸ—„ Data Pipeline

flowchart LR
    CSV1["track_data_final.csv\n8778 tracks\ntrack + artist + genres\npopularity + followers"]
    CSV2["spotify_data clean.csv\nGenre enrichment source"]

    PARSE["Parse Genres\nast.literal_eval\nfallback string split"]
    MERGE["Build Artist-Genre Map\nMerge both sources\n61% genre coverage"]
    ENRICH["Enrich Missing Genres\nBack-fill from merged map"]
    INDEX["Index Columns\nartist_lower\ntrack_lower\ngenres_lower"]
    RAM["Shared Agent Dataset\nLoaded once at startup\nShared across all agents"]

    CSV1 --> PARSE
    CSV2 --> PARSE
    PARSE --> MERGE
    MERGE --> ENRICH
    ENRICH --> INDEX
    INDEX --> RAM
Loading

πŸ“ Metric and Confidence Formulas

graph LR
    GM["Genre Match\nJaccard overlap x 100\nWeight 45%"]
    PF["Popularity Fit\ntrack_popularity / 100\nWeight 30%"]
    AS["Artist Score\nlog10 followers / 8 x 100\nWeight 25%"]
    RV["Overall Relevance\nGM x 0.45\nPF x 0.30\nAS x 0.25"]
    CF["Track Confidence\nGM x 0.50\nAS x 0.30\nPF x 0.20\ndivided by 100"]

    GM --> RV
    PF --> RV
    AS --> RV
    GM --> CF
    PF --> CF
    AS --> CF
Loading
Metric Formula Calculated By
Genre Match genre_overlap(track, target) x 100 GenreMood + Discovery Agents
Popularity Fit popularity / 100 x 100 Judge Agent
Artist Score min(100, log10(followers)/8 x 100) Judge Agent
Overall Relevance GM x 0.45 + PF x 0.30 + AS x 0.25 Judge Agent
Track Confidence (GM x 0.50 + AS x 0.30 + PF x 0.20) / 100 Judge Agent
System Confidence avg x 75 + strategy_premium + diversity_bonus Judge Agent

πŸ–₯ Frontend Component Tree

graph TD
    APP["App.jsx\nSearch Β· Results Β· State"]
    STARS["Stars.jsx\n200 canvas stars\ndrift + twinkle"]
    HERO["HeroTitle.jsx\nLetter hover animation\nColor wave + music notes"]
    SKEL["SkeletonCard x5\nDomino wave loading\n--wave-delay CSS var"]
    QP["QualityPanel\nSystem confidence\nCollapsible metric bars"]
    TC["TrackCard x N\nRank Β· Title Β· Artist\nGenre chips Β· Links"]
    GC["GlowCard\nMouse spotlight\n--gx --gy CSS vars"]
    MB["MetricsBar\nSVG confidence ring\n4 animated progress bars"]

    APP --> STARS
    APP --> HERO
    APP --> SKEL
    APP --> QP
    APP --> TC
    TC --> GC
    TC --> MB
Loading

πŸ›  Tech Stack

Layer Technology Purpose
πŸ€– Agents Python 3.11 β€” 4 agent classes Planner, GenreMood, Discovery, Judge
🐍 Backend FastAPI + Uvicorn REST API, routing, lifespan
πŸ“Š Data Pandas + Spotify CSV 8,778-track shared agent dataset
βš›οΈ Frontend React 18 + Vite SPA, hot reload, /api proxy
🎞 Animation Framer Motion Transitions, AnimatePresence
🌌 Canvas HTML5 Canvas API 200-star animated starfield
🐳 Container Docker multi-stage Node build then Python serve
☁️ Deploy HuggingFace Spaces CPU Basic, free, port 7860

πŸš€ Run Locally

# 1. Clone
git clone https://github.com/Ashutosh-177/ManTarang-AI-Powered-Music-Recommendation-System.git
cd ManTarang-AI-Powered-Music-Recommendation-System

# 2. Backend  (terminal 1)
pip install -r requirements-hf.txt
uvicorn mantarang.src.api.backend:app --host 0.0.0.0 --port 8000 --reload

# 3. Frontend  (terminal 2)
cd mantarang-ui
npm install
npm run dev
# open http://localhost:5173

πŸ“ Project Structure

ManTarang/
β”œβ”€β”€ mantarang/src/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ planner/           ← Agent 1: Orchestrates pipeline
β”‚   β”‚   β”‚   β”œβ”€β”€ agent.py
β”‚   β”‚   β”‚   β”œβ”€β”€ query_analyzer.py
β”‚   β”‚   β”‚   β”œβ”€β”€ context_analyzer.py
β”‚   β”‚   β”‚   β”œβ”€β”€ strategy_planner.py
β”‚   β”‚   β”‚   └── entity_processor.py
β”‚   β”‚   β”œβ”€β”€ genre_mood/        ← Agent 2: Emotion and genre specialist
β”‚   β”‚   β”‚   β”œβ”€β”€ agent.py
β”‚   β”‚   β”‚   └── components/
β”‚   β”‚   β”œβ”€β”€ discovery/         ← Agent 3: Similarity and novelty explorer
β”‚   β”‚   β”‚   β”œβ”€β”€ agent.py
β”‚   β”‚   β”‚   β”œβ”€β”€ similarity_explorer.py
β”‚   β”‚   β”‚   └── underground_detector.py
β”‚   β”‚   └── judge/             ← Agent 4: Ranks and explains results
β”‚   β”‚       β”œβ”€β”€ agent.py
β”‚   β”‚       └── components/
β”‚   β”‚           β”œβ”€β”€ ranking_engine.py
β”‚   β”‚           β”œβ”€β”€ diversity_optimizer.py
β”‚   β”‚           └── explanation_generator.py
β”‚   └── api/
β”‚       └── backend.py         ← FastAPI routes
β”‚
β”œβ”€β”€ mantarang-ui/src/
β”‚   β”œβ”€β”€ App.jsx
β”‚   └── components/
β”‚       β”œβ”€β”€ HeroTitle.jsx
β”‚       β”œβ”€β”€ TrackCard.jsx
β”‚       β”œβ”€β”€ MetricsBar.jsx
β”‚       β”œβ”€β”€ SkeletonCard.jsx
β”‚       β”œβ”€β”€ Stars.jsx
β”‚       └── GlowCard.jsx
β”‚
β”œβ”€β”€ track_data_final.csv        ← Shared agent dataset (8,778 tracks)
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ METRICS.md
└── PROJECT_REPORT.md

πŸ‘₯ Built By

Ashutosh Kumar Singh Enrollment No. 92301733016
Aditya Raj Enrollment No. 92301733062

Music Emotion Recognition (MER) β€” 2026

footer

About

ManTarang uses four AI agents collaborating via LangGraph to turn natural language queries into ranked, explained music recommendations using Gemini and Spotify.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors