πŸ’‘ Day 6 – Building QuoteGenie | #30Days30Projects

Rushikesh UngeRushikesh Unge
4 min read

Welcome to Day 6 of my #30DaysOfCode challenge! Today, I built a lightweight and refreshing terminal application called QuoteGenie. This little utility serves one purpose: to deliver motivational and insightful quotes in real time right in your terminal window.


πŸš€ What is QuoteGenie?

QuoteGenie is a Java command-line application that fetches a random inspirational quote from a public API and displays it with a clean and simple output in the terminal.

It combines:

  • βœ… Core Java concepts

  • 🌐 Real-time API calls (HTTPS)

  • πŸ“¦ JSON parsing using the org.json library

  • πŸ”’ Handling SSL certificates

  • 🧹 Clean output formatting


πŸ› οΈ Tech Stack & Tools Used

FeatureTechnology
Programming LangJava
Build ToolCLI (javac, java)
API SourceQuotable.io
JSON Libraryorg.json (20210307 version)

πŸ“¦ Project Structure

QuoteGenie/
β”œβ”€β”€ lib/
β”‚   └── json-20210307.jar
β”œβ”€β”€ src/
β”‚   └── Quote.java

lib/ holds the external JSON library.
src/ holds the core application logic.


πŸ“ˆ Key Features

  • βœ… Fetch Quotes: Uses https://api.quotable.io/quotes/random?tags=technology,famous-quotes

  • πŸ” Handles SSL: Bypasses SSL errors for smooth API integration

  • πŸ§ͺ Minimal Dependencies: Uses only one external JAR for JSON parsing

  • ✨ Simple Output: Terminal-friendly, readable quote display


πŸ’» How It Works (Code Overview)

Here’s a simplified version of the working code:

import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class Quote {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://api.quotable.io/quotes/random?tags=technology,famous-quotes");
            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            StringBuilder jsonStr = new StringBuilder();
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                jsonStr.append(inputLine);
            }
            in.close();

            // Handle API response as array
            String response = jsonStr.toString();
            response = response.substring(1, response.length() - 1); // Remove [ ]
            JSONObject json = new JSONObject(response);

            System.out.println("\nπŸ“œ Quote of the Day:");
            System.out.println("\"" + json.getString("content") + "\"");
            System.out.println("\nβ€” " + json.getString("author"));
        } catch (Exception e) {
            System.out.println("⚠️ Failed to fetch quote: " + e.getMessage());
        }
    }
}

🧠 What I Learned

This small project may seem basic, but it gave me a solid refresher on multiple core concepts:

βœ… API Integration in Java

  • Used Java’s native HttpsURLConnection class to make GET requests

  • Understood how Java handles HTTP headers and input streams

βœ… JSON Parsing

  • Learned how to parse dynamic JSON content using the org.json library

  • Handled JSON arrays and object conversions

βœ… SSL and Certificates

  • Encountered SSL certificate issues and resolved them using a temporary workaround by trusting all certificates (not recommended for production)

βœ… Terminal UI Design

  • Focused on clean and simple formatting of terminal output

  • Used emojis and spacing to improve readability without being overly fancy


πŸ“Έ Output Snapshot

πŸ“œ Quote of the Day:
"Technology is best when it brings people together."

β€” Matt Mullenweg

🚧 Challenges Faced

ChallengeSolution
ClassNotFoundException errorsFixed classpath settings using -cp correctly
SSL certificate expired errorImplemented TrustManager override temporarily
JSON format mismatchAdjusted response handling from JSONArray to JSONObject
External JAR not loadingUsed correct path: -cp .;lib\json-20210307.jar;src on Windows

🧭 Next Steps & Improvements

  • Add support for fetching quotes by category or author

  • Build a simple GUI version using Java Swing

  • Package into a JAR file for easier distribution

  • Add a loading spinner for better UX

  • Implement unit tests for API response handling


πŸ”— API Reference

We used the Quotable API
Example endpoint used:

https://api.quotable.io/quotes/random?tags=technology,famous-quotes

Returns a JSON array with a single quote object.


🌟 Final Thoughts

QuoteGenie is proof that even the smallest tools can bring joy and value.

This project was an opportunity to revisit Java fundamentals, explore external API usage, and solve real-world issues like SSL verification and JSON handling.

It’s just a small app, but for me, it's a gentle push toward building tools that enhance productivity or bring daily motivation β€” one quote at a time. 😊


πŸ’¬ Want to try QuoteGenie?

Clone it, add your own quote sources, and keep your terminal inspiring!

πŸ”– GitHub Repo : https://github.com/Rushi-Unge/30Days30Projects/tree/main/QuoteGenie

0
Subscribe to my newsletter

Read articles from Rushikesh Unge directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rushikesh Unge
Rushikesh Unge