How I built a Movie Suggestion CLI

Published: (January 17, 2026 at 02:33 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Introduction

I have always had a knack for movies—especially great ones that fit my current mood or the feeling I’d like afterward, and that suit the company I’m watching with. Finding the right film is usually tiring: I have to jump between providers, streaming services, or websites, applying filters while scanning ratings and summaries. Fed up with this cycle, I built a simple command‑line tool to make the process quicker and a bit more enjoyable.

The code is written purely in Java because it is versatile, has a strong object‑oriented model, and is the main language used in the course. No external libraries were used, keeping the implementation as simple as possible and allowing each feature to be understood “by hand” rather than relying on frameworks. The program is divided into several classes:

  • Main class – provides the command‑line interface (CLI)
  • Helper classes – handle authentication and movie data
  • Testing classes – ensure the code runs smoothly

Keeping things modular made it easier to work on one part at a time, applying standard OOP ideas such as separation of concerns and encapsulation, which eases maintenance and future extension.

From a user’s point of view, the workflow is intentionally simple: open a terminal, run the tool, receive a welcome message, log in, answer a few questions about mood and company, and receive one or more movie suggestions. Each suggestion includes the genres, title, and a short description.

Feature 1: User Input and Validation

The CLI prompts the user for input and validates it to ensure responses are in the expected format (e.g., non‑empty strings, numeric choices within range). Invalid input triggers a friendly re‑prompt, preventing the program from crashing.

Feature 2: Auth class and file‑based authentication

Authentication is handled by an Auth class that reads a plain‑text file where each line contains a username:password pair. The class loads these credentials into a collection of objects and provides methods to verify a user’s login attempt against the stored data.

Feature 3: Questions, preferences and loops

A list of question objects is processed in a loop. Each answer is mapped to one or more movie genres. For example, a preference for a “calm” atmosphere is translated into genres such as drama, romance, or slice‑of‑life. The resulting genre list may contain duplicates (e.g., ["Drama", "Action", "Comedy", "Drama"]). Duplicates are intentionally kept as an implicit weighting mechanism: the more a genre appears, the higher its influence on the final scoring.

Feature 4: Movie objects and scoring algorithm

Movies are represented by objects containing fields for title, description, and associated genres. After the user’s preferences are converted to a weighted genre list, the program scores each movie based on how many of its genres match the weighted list. Movies with higher scores are presented first, providing recommendations that best align with the user’s mood and company.

Issues Encountered

  1. Human Input – handling unpredictable user responses and ensuring robust validation.
  2. Designing a suitable scoring system – creating a simple yet effective algorithm without external libraries.
  3. Constraints without external libraries – implementing authentication, testing, and the UI using only core Java features.

Conclusion

The result is an elegant tool for power‑terminal users who want a quick movie recommendation tailored to their current circumstances. Future improvements could include integrating the IMDb API to fetch up‑to‑date movie data automatically, reducing the need for manual updates to the local movie database.

Back to Blog

Related posts

Read more »

2026: The Year of Java in the Terminal

Article URL: https://xam.dk/blog/lets-make-2026-the-year-of-java-in-the-terminal/ Comments URL: https://news.ycombinator.com/item?id=46445229 Points: 39 Comment...

2026: The Year of Java in the Terminal?

Article URL: https://xam.dk/blog/lets-make-2026-the-year-of-java-in-the-terminal/ Comments URL: https://news.ycombinator.com/item?id=46445229 Points: 51 Comment...