Building MooVeeMatch: an emotion-based movie recommendation app
introduce
As part of Codecademy’s Computer Science course, I recently completed a portfolio project: MooVeeMatch. The program is a mood-based movie recommendation tool that allows users to discover movies that suit their feelings. Whether you want something exciting, adventurous, or mysterious, MooVeeMatch has you covered!
In this article, I’ll walk you through the inspiration behind the project, the technical details of its implementation, and the key lessons I learned during development. If you’re learning Python or taking a Codecademy course, this might inspire you to build your own emotion-based app!
About MooVeeMatch
MooVeeMatch is a command line application It accepts user input (for example, their mood) and returns a curated list of movies that match their vibe. This program is powered by Python dictionary (Essentially a hash map) Store emotions as keys and list of movies as values.
Main features:
- Emotion-based recommendations: Search for movies by mood (e.g. uplifting, dark, funny, etc.).
- Interactive CLI: A clean and user-friendly interface for browsing movie recommendations.
- Refactored code base: Includes the original implementation and a cleaner, more modular refactored version.
- Extensible database: Easily add more moods and movies to your library.
Technical overview
data structure
The core of MooVeeMatch is dictionary Mapping emotions to movie lists. This is an example of a hash map in Python, providing efficient O(1) sentiment lookup.
example:
movies_by_mood = {
"uplifting": [
("The Pursuit of Happyness", 2006, "A touching story about perseverance"),
("Soul", 2020, "An inspiring animated story about life's purpose")
],
"dark": [
("Se7en", 1995, "A gritty thriller about a serial killer"),
("The Dark Knight", 2008, "A darker take on the Batman legend")
],
# More moods...
}
algorithm
-
search algorithm:
- This program uses
startswith()
method to find emotions that match user input. - Example: If the user types “upl”, the program will match it to
"uplifting"
.
- This program uses
-
sorting algorithm:
- List of movies sorted alphabetically before using Python’s built-in display
sorted()
Function.
- List of movies sorted alphabetically before using Python’s built-in display
Program workflow
- welcome speech: Users will see a decorative ASCII banner.
- emotional input: The program prompts users to enter the first few letters of their mood.
-
mood match: The program uses the following command to find matching emotions from the database
startswith()
and returns a list of matching options. - suggestion: Users confirm their mood and receive a list of recommended movies with title, year of release and synopsis.
- repeat or exit: Users can explore other moods or exit the program.
Main challenges and refactoring
Challenge: Nested Logic
The original implementation had deeply nested loops and conditionals, making the code harder to read and maintain.
Solution: Refactor
I refactored the code into smaller, single-responsibility functions to make it more modular. For example:
- forward: Emotion matching and video display are handled within the main loop.
-
back: individual functions, e.g.
find_matching_moods()
anddisplay_movies_for_mood()
Simplified code.
Here is an example of a reconstructed function:
def find_matching_moods(input_mood_letters):
"""Search for moods matching the input letters."""
return [
mood for mood in movies_by_mood.keys()
if mood.startswith(input_mood_letters)
]
This refactoring makes the code base more readable and easier to debug, especially as I expand the movie database.
Lessons learned
-
The importance of refactoring:
Writing modular, clean code saves time in the long run. The refactored version of MooVeeMatch is not only easier to debug, but also easier to extend.
-
Effective use of hashmaps:
Python dictionaries are very powerful for efficient storage and retrieval of data. This project reinforces how hashmaps can be utilized in real-world scenarios.
-
Small iterative improvements:
Working in small increments—writing a feature, testing it, and improving it—helps me stay focused and avoid becoming overwhelmed.
-
CLI design is important:
Even in terminal-based programs, user experience is key. Simple things like clean banners and well-structured output can make a big difference.
in conclusion
MooVeeMatch was a rewarding project that allowed me to apply the knowledge I learned in Codecademy’s computer science courses to real-world scenarios. From handling user input to efficiently managing data, this project helped me solidify my Python skills and taught me the value of clean, modular code.
Check out MooVeeMatch on GitHub!
You can find the complete code library here: [GitHub Repository Link](#)
Feel free to clone, try and contribute if you like!