Hey everyone! ๐
Picking up right from where we left off โ both the frontend and backend of my project were working beautifully on my local system.
All that was left was to deploy everything to the real worldโฆ where the real magic (and bugs ๐
) happen.
๐ Deployment Setup
Frontend (GitHub Pages)
I took the straightforward route and deployed my frontend using GitHub Pages. The process was smooth, and the site was up and running almost instantly. No major issues here since it was a static frontend.
The real challenge? The backend.
โ๏ธ Backend Deployment (Render)
I used Render to deploy my backend because:
- Itโs beginner-friendly
- Free to use
- I had prior experience with it
Initially, my backend was connected to local MongoDB (Compass).
Once deployed, everything stopped working.
๐ The Problem (Symptoms)
Clicking Generate did absolutely nothing:
- No new quote
- No background change
- No errors on the UI
That meant one thing:
quotes was empty, so newQuote() exited immediately.
if (quotes.length === 0) return;
So the real question became:
Why was fetchQuotes() no longer populating data?
๐ Debugging the Issue
Hereโs the logic trail I followed:
- Frontend now points to Render backend
- Render backend CANNOT access local MongoDB (the part I had missed)
- API returns an empty response
- Frontend correctly refuses to render empty data
So technicallyโฆ nothing was โbrokenโ.
The system was doing exactly what it was told to do.
โ The Real Fix: MongoDB Atlas
The solution was to move from local MongoDB to a cloud-based database. I:
- Set up MongoDB Atlas
- Created a new cluster
- Seeded the database with sample quotes
- Connected Atlas to Render using environment variables
MONGO_URI = mongodb+srv://quoteAdmin:YOUR_PASSWORD@.../quoteGeneratorDB
PORT = 5000
Then I updated the frontend API_URL:
let API_URL = "http://localhost:5000";
โฌ๏ธโฌ๏ธโฌ๏ธ
let API_URL = "https://YOUR-RENDER-URL.onrender.com";
๐ Debugging (The Second Heartbreak๐)
After connecting MongoDB Atlas, Render, and updating all the environment variables, I was confident everything should work.
Butโฆ clicking Generate still did nothing.
Same symptom. Same silence. Honestly, it was heartbreaking.
At this point, I had no idea what was wrong because everything was technically correct.
To dig deeper, I directly visited my API endpoint in the browser:
https://quote-generator-5qei.onrender.com/quotes
I saw the words Cannot GET and assumed it was an error and something was wrong with my code, but after repeatedly checking my console and recieving no errors -
Thatโs when it finally clicked.
There was nothing wrong with my code, deployment, or API.
I had simply forgotten to seed data into MongoDB Atlas. All my quotes were still sitting in my local database.
A painful but valuable lesson:
Sometimes, the bug isnโt in the code โ itโs in the data.
๐ Final Result
Andโฆ voilร ! ๐
Once the database was seeded with sample quotes and connected properly:
- Quotes started loading
- Generate button worked
- Categories functioned perfectly
- Full-stack data flow was live
This felt like the moment the project officially became real.
๐ฎ Whatโs Coming Next
Next up:
- ๐ง AI integration ideas (brief planning)
- โจ Generating original quotes
- ๐ฏ Personalization & scalability
See you in the next post โ stay tuned! ๐
Top comments (0)