DEV Community

Cover image for MovieNest Gets a Mood Ring: Recommending Films with Weather, Time & Tears
Shravan Bobade
Shravan Bobade

Posted on

MovieNest Gets a Mood Ring: Recommending Films with Weather, Time & Tears

๐ŸŽฎ MovieNest Gets a Mood Ring: Recommending Films with Weather, Time & Tears

So I was staring out my window one rainy night, thinking:

โ€œWouldnโ€™t it be cool if my app felt the vibe and showed me a romantic thriller?โ€

And thatโ€™s how I spiraled into turning my chill movie app into a mood-sensing, AI-powered, vibe-aware recommender system.

Spoiler: The mood logic was easier than the geolocation permission denial logic.


๐Ÿ”ง Goal: Make MovieNest Feel Emotions (Kind Of)

This update was all about personalization. I wanted the app to:

  • Detect the current weather and time
  • Guess your mood from that combo (like a fortune teller... but with JavaScript)
  • Recommend movies that match that vibe

Also:

  • Handle permission denial gracefully (not by throwing an error and dying ๐Ÿ˜ต)
  • Keep everything snappy with virtual scroll + debounce

๐Ÿง  The (Questionable) AI Logic

Step 1: Mood Detection

I hooked into OpenWeatherโ€™s API + good olโ€™ Date() and assigned moods like:

  • Rainy Night โ†’ Romantic Thriller ๐ŸŒง๏ธ๐ŸŒ™
  • Sunny Morning โ†’ Feel-Good Comedy โ˜•โ˜€๏ธ
  • Foggy Afternoon โ†’ Mystery Drama ๐Ÿ•ต๏ธโ€โ™€๏ธ

Basically, my app is now a softboi who asks,

*"Are you okay? Here's a comfort film."

Step 2: Mood โ†’ Genre

I made a neat moodGenreMapping object:

{
  feelgood: [35, 10751], // Comedy, Family
  cozy: [10749, 18], // Romance, Drama
  adventure: [12, 28], // Adventure, Action
  mystery: [9648, 53], // Mystery, Thriller
}
Enter fullscreen mode Exit fullscreen mode

So each mood maps to TMDB genres โ€” and my app fetches them dynamically.

Step 3: Smart Fetching Flow

If you allow location:
โ†’ Weather + Time โ†’ Mood โ†’ Genre โ†’ Movies

If you deny location (you rebel):
โ†’ Time-only Mood โ†’ Genre โ†’ Movies

If you search manually:
โ†’ I shut up and show you what you want.

And just to be polite, I added a ๐Ÿง  Mood Explanation Banner โ€”

โ€œItโ€™s raining in your area at night, so hereโ€™s a romantic thriller.โ€
Because transparency matters. Even in movie logic.

Image description


๐Ÿ˜ฎโ€๐Ÿ˜ด Challenges, AKA โ€œWhy Am I Like This?โ€

โŒ Weather API 401

I foolishly used OpenWeather's fancy 3.0 OneCall endpoint.
Turns out, that one costs real money ๐Ÿ˜ญ
So I switched to a free and functional endpoint. Budget dev life.


๐Ÿ“ No Location? No Problem.

I realized users could deny geolocation (how dare they), and I wasnโ€™t handling it.
Now I fallback like a champion:\
โ†’ Just use the time and pretend we know the weather ๐Ÿ•ฐ๏ธโœจ


โ™ป Infinite Fetch Bug

Forgot to reset the pagination page when a new mood or search triggered.
The app said, โ€œMore movies! More!โ€
I said, โ€œPlease stop.โ€
It now stops.


๐Ÿค– Mood Mapping Misfire

I passed the time directly into moodGenreMapping like a rookie.
What I needed was:
getMoodFromContext(weather, time) โ†’ mood โ†’ genres

Fixed it.
Cried a bit.


๐Ÿ“ฑ Mobile Geolocation Weirdness

Some mobile devices didnโ€™t even ask for permission.
Added logs and tested denial flow manually. (Felt like QA. Still unemployed.)


๐Ÿš€ The Final Vibe

Now MovieNest can do this:

  • Itโ€™s raining in Mumbai at night?
    โ†’ You get romantic thrillers. ๐Ÿ’–๐Ÿ•ต๏ธโ€โ™‚๏ธ

  • Itโ€™s sunny in Paris?
    โ†’ Boom, comedies and feel-goods. โ˜€๏ธ๐Ÿ˜‚

  • Denied location?
    โ†’ Itโ€™s cool. Weโ€™ll guess. Weโ€™re chill like that.


๐ŸŒˆ Whatโ€™s Next?

Iโ€™m building in public โ€” crying in private. Here's whatโ€™s coming up:

  • ๐ŸŽž๏ธ Collaborative watchlists
  • ๐Ÿ”Š Voice-based search
  • ๐Ÿค– Better mood prediction using AI (GPT meets weather forecast??)

๐Ÿงฉ Try It Out

Live App: https://shravandev.com/movienest\
Blog 1: Proxy, Debounce & Glassmorphism\
Blog 2: Virtual Scroll + Lazy Loading


Thanks for scrolling through my chaos.
If your app isnโ€™t emotional yetโ€ฆ
Are you even building full-stack? ๐Ÿ˜Œ

Built with care, mood swings, and navigator.geolocation โ€”
Shravan ๐Ÿ’ป๐Ÿฟ

Top comments (0)