π‘ Day 6 β Building QuoteGenie | #30Days30Projects

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
Feature | Technology |
Programming Lang | Java |
Build Tool | CLI (javac , java ) |
API Source | Quotable.io |
JSON Library | org.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 requestsUnderstood how Java handles HTTP headers and input streams
β JSON Parsing
Learned how to parse dynamic JSON content using the
org.json
libraryHandled 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
Challenge | Solution |
ClassNotFoundException errors | Fixed classpath settings using -cp correctly |
SSL certificate expired error | Implemented TrustManager override temporarily |
JSON format mismatch | Adjusted response handling from JSONArray to JSONObject |
External JAR not loading | Used 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
Subscribe to my newsletter
Read articles from Rushikesh Unge directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
