<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Spring Boot + AI]]></title><description><![CDATA[Spring Boot + AI]]></description><link>https://spring-boot-ai.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 18:28:19 GMT</lastBuildDate><atom:link href="https://spring-boot-ai.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Building an AI-Powered Spring Boot Microservices Application: My Journey, Issues & Fixes]]></title><description><![CDATA[In this post, I’ll walk you through my experience building an AI-powered fitness recommendation app using Spring Boot microservices, integrated with MongoDB Atlas, Eureka Service Discovery, and Google Gemini for personalized AI recommendations.
🎯 In...]]></description><link>https://spring-boot-ai.hashnode.dev/building-an-ai-powered-spring-boot-microservices-application-my-journey-issues-and-fixes</link><guid isPermaLink="true">https://spring-boot-ai.hashnode.dev/building-an-ai-powered-spring-boot-microservices-application-my-journey-issues-and-fixes</guid><category><![CDATA[Java]]></category><category><![CDATA[Springboot]]></category><category><![CDATA[Microservices]]></category><category><![CDATA[eureka-server]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[PostgreSQL]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Rudra Narayan]]></dc:creator><pubDate>Mon, 21 Jul 2025 16:12:43 GMT</pubDate><content:encoded><![CDATA[<p>In this post, I’ll walk you through my experience building an <strong>AI-powered fitness recommendation app</strong> using <strong>Spring Boot microservices</strong>, integrated with <strong>MongoDB Atlas</strong>, <strong>Eureka Service Discovery</strong>, and <strong>Google Gemini</strong> for personalized AI recommendations.</p>
<h3 id="heading-in-this-post-ill-highlight">🎯 In this post, I’ll highlight:</h3>
<ul>
<li><p>🧱 <strong>The architecture I used</strong></p>
</li>
<li><p>🔨 <strong>Key steps in building it</strong></p>
</li>
<li><p>❗ <strong>Challenges I faced</strong></p>
</li>
<li><p>✅ <strong>How I fixed them</strong></p>
</li>
</ul>
<hr />
<h3 id="heading-project-architecture">🏗️ Project Architecture</h3>
<p>My application is made up of <strong>three microservices (so far)</strong>:</p>
<ol>
<li><p><strong>User Service</strong> – Handles user data (uses <strong>PostgreSQL</strong>)</p>
</li>
<li><p><strong>Activity Service</strong> – Stores activity logs (uses <strong>MongoDB Atlas</strong>)</p>
</li>
<li><p><strong>AI Recommendation Service</strong> – Generates personalized fitness plans using <strong>Google Gemini</strong></p>
</li>
</ol>
<p>All services are registered with the <strong>Eureka Server</strong> for <strong>service discovery</strong>.</p>
<hr />
<h3 id="heading-tech-stack">🔧 Tech Stack</h3>
<ul>
<li><p><strong>Java 17</strong></p>
</li>
<li><p><strong>Spring Boot 3.1.9</strong></p>
</li>
<li><p><strong>Spring Cloud 2025.0.0</strong></p>
</li>
<li><p><strong>MongoDB Atlas</strong></p>
</li>
<li><p><strong>PostgreSQL</strong></p>
</li>
<li><p><strong>Google Gemini (AI API)</strong></p>
</li>
<li><p><strong>Eureka Server</strong></p>
</li>
<li><p><strong>Docker</strong> (for future deployment)</p>
</li>
</ul>
<hr />
<h3 id="heading-steps-i-followed">🛠️ Steps I Followed</h3>
<ul>
<li><p>✅ Created microservices using <strong>Spring Initializr</strong></p>
</li>
<li><p>✅ Integrated <strong>JPA &amp; PostgreSQL</strong> for <code>user-service</code></p>
</li>
<li><p>✅ Set up <strong>MongoDB Atlas</strong> for <code>activity-service</code></p>
</li>
<li><p>✅ Integrated <strong>Google Gemini API</strong> in <code>ai-service</code></p>
</li>
<li><p>✅ Added <strong>Eureka Server</strong> and registered all services</p>
</li>
<li><p>✅ Tested all APIs using <strong>Postman</strong></p>
</li>
<li><p>✅ Used <strong>Spring Cloud OpenFeign</strong> for inter-service communication</p>
</li>
</ul>
<hr />
<h3 id="heading-problems-i-faced-amp-how-i-solved-them">🧱 Problems I Faced &amp; How I Solved Them:</h3>
<h4 id="heading-1-mongosocketreadexception-mongodb-atlas-connection-issue">1. ❌ <strong>MongoSocketReadException — MongoDB Atlas Connection Issue</strong></h4>
<ul>
<li><p><strong>Issue</strong>: While connecting <code>activity-service</code> to MongoDB Atlas, I got a <code>MongoSocketReadException</code>.</p>
</li>
<li><p><strong>Root Cause</strong>: I had not <strong>whitelisted my current IP address</strong> in the MongoDB Atlas dashboard.</p>
</li>
<li><p><strong>Fix</strong>:</p>
<ul>
<li><p>Go to <strong>MongoDB Atlas Console → Network Access</strong></p>
</li>
<li><p>Click <strong>Add IP Address</strong></p>
</li>
<li><p>Use <strong>"Allow access from anywhere" (0.0.0.0/0)</strong> or your specific IP</p>
</li>
<li><p><strong>Save</strong> and reconnect</p>
</li>
</ul>
</li>
</ul>
<hr />
<h4 id="heading-2-eureka-client-not-registering-microservices">2. ❌ <strong>Eureka Client Not Registering Microservices</strong></h4>
<ul>
<li><p><strong>Issue</strong>: Microservices were not appearing in the <strong>Eureka Dashboard</strong>.</p>
</li>
<li><p><strong>Root Cause</strong>: I <strong>forgot to add the Eureka Client dependency</strong> in the <code>pom.xml</code>.</p>
</li>
<li><p><strong>Fix</strong>:</p>
<ul>
<li><p>Add the following to each microservice:  </p>
<p>  <strong>&lt;dependency&gt; &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt; &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt; &lt;/dependency&gt;</strong>  </p>
</li>
<li><p>Also add these properties:  </p>
<p>  <strong>eureka.client.register-with-eureka=true eureka.client.fetch-registry=true eureka.client.service-url.defaultZone=http://localhost:8761/eureka/</strong></p>
</li>
<li><p>Make sure every service has a <strong>unique</strong> <a target="_blank" href="http://spring.application.name"><code>spring.application.name</code></a></p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-learnings">💡 Learnings</h3>
<ul>
<li><p>✅ Always <strong>whitelist your IP in MongoDB Atlas</strong></p>
</li>
<li><p>✅ Never miss essential dependencies like <strong>Eureka Client</strong></p>
</li>
<li><p>✅ Use <strong>Spring Profiles</strong> for environment-specific configs</p>
</li>
<li><p>✅ Test each microservice <strong>individually</strong> before full integration</p>
</li>
</ul>
<hr />
<h3 id="heading-conclusion">📌 Conclusion</h3>
<p>This project helped me:</p>
<ul>
<li><p>🧩 Build <strong>scalable microservices</strong> using Spring Boot</p>
</li>
<li><p>🔐 Securely connect to <strong>external databases</strong></p>
</li>
<li><p>🧠 Integrate <strong>AI-powered services</strong> using Google Gemini</p>
</li>
<li><p>🛠️ Troubleshoot <strong>real-world issues</strong> with networking and microservice registration</p>
</li>
</ul>
<hr />
<h3 id="heading-whats-next">🔗 What’s Next?</h3>
<ul>
<li><p>⚙️ <strong>Setting up asynchronous communication using RabbitMQ</strong> for better service decoupling</p>
</li>
<li><p>🛡️ <strong>Implementing authentication &amp; authorization using Keycloak</strong></p>
</li>
<li><p>💻 <strong>Adding a frontend</strong> using <strong>React</strong> or <strong>Next.js</strong></p>
</li>
</ul>
<hr />
]]></content:encoded></item></channel></rss>