
Have you ever wondered what goes into building a production-ready, highly resilient fitness application? In this post, I want to pull back the curtain on Fit&Fantastic—a scalable and production-ready AI-powered fitness tracking platform.
Beyond just tracking workouts and getting Gemini AI-powered insights, I designed this system using a Microservices Architecture to ensure that one failing component doesn't bring the whole house down.
🎥 See It In Action
Check out this quick demo of the platform, including the sleek Tailwind CSS dark theme and the full user journey:
Why This Project?
Most fitness applications today are built as monolithic systems, which limits scalability and makes it difficult to integrate advanced features like AI-driven recommendations.
This project was designed to overcome those limitations by adopting a microservices architecture, where each component is independently deployable, scalable, and maintainable.
Additionally, the goal was to simulate a real-world production system, incorporating:
- Secure authentication
- Distributed communication
- Asynchronous processing
- AI-powered insights
This makes the project not just a functional application, but a comprehensive learning experience in building scalable distributed systems.
🏗️ System Architecture

Architecture Highlights
- Microservices-based architecture for separation of concerns
- API Gateway for centralized routing and security
- Eureka for dynamic service discovery
- Config Server for centralized configuration management
- Keycloak for robust Authentication & Authorization
- RabbitMQ for event-driven asynchronous communication
- AI integration using the Google Gemini API
Request Flow
- Client (Web/Mobile) interacts with the React Frontend.
- Requests go through the API Gateway.
- Authentication is handled seamlessly via Keycloak.
- Gateway routes the request to the appropriate microservice.
- Services communicate internally via REST API (synchronous) or RabbitMQ (asynchronous).
- AI Service processes workout data using the Gemini API.
- Data is stored in respective databases depending on the service.
Microservices Breakdown
| Service | Description | Database |
|---|---|---|
| User Service | Manages users and metadata | PostgreSQL |
| Activity Service | Tracks fitness activities securely | MongoDB |
| AI Service | Generates personalized AI recommendations | MongoDB |
| API Gateway | Secure request routing | — |
| Eureka Server | Dynamic service discovery | — |
| Config Server | Centralized configurations | — |
Key Design Decisions
- Why Microservices? To ensure massive scalability and strict separation of concerns.
- Why RabbitMQ? To decouple services and handle asynchronous workflows efficiently without blocking HTTP threads.
- Why MongoDB + PostgreSQL?
- PostgreSQL provides rock-solid relational data integrity for user data.
- MongoDB offers the flexible document structure needed for highly dynamic activity and AI-related logs.
- Why API Gateway? To provide a single, secure entry point and simplify client interaction.
Designing for Resilience: Surviving Service Failures
In a monolithic architecture, if the AI processing module goes down, the entire app crashes. My primary goal with Fit&Fantastic was to achieve zero Single Points of Failure. Here is how we did it:
1. Asynchronous Decoupling with RabbitMQ
When you log a workout, the Activity Service saves your data instantly. But instead of calling the AI Service directly via a blocking HTTP request, it drops an event into a RabbitMQ queue. If the AI Service goes offline or crashes due to high load, the Activity Service doesn't care. It successfully saves your workout. The moment the AI Service spins back up, it pulls from the queue and generates your recommendation. No data is lost.
2. Client-Side Load Balancing with Eureka Service Discovery
Static IP addresses are brittle. Fit&Fantastic relies on a Netflix Eureka Server for dynamic service registration. If one instance of a service crashes, the Gateway automatically detects the failure and routes subsequent traffic exclusively to the healthy instances.
3. Graceful UI Degradation
The React frontend is built to handle partial data. If the AI Recommendation hasn't been generated yet (or if the AI service is temporarily delayed), the user interface gracefully displays a "Recommendation not ready - analyzing..." state rather than throwing an error page.
Authentication & Communication
- Authentication: Implemented using Keycloak. We utilize OAuth2 & OpenID Connect-based authentication to enforce centralized identity management across all services.
- Synchronous Communication: Internal REST APIs accessible exclusively via the API Gateway.
- Asynchronous Communication: RabbitMQ handles an event-driven architecture to keep background processing uncoupled.
Tech Stack
Backend
- Java 17 & Spring Boot
- Spring Cloud (Eureka, Gateway, Config Server)
- RabbitMQ
- Keycloak
Frontend
- React.js with Tailwind CSS
Databases & AI
- PostgreSQL (User Data)
- MongoDB (Activity & AI Logs)
- Google Gemini API
🌐 Port Mapping
Understanding the internal networking of a microservice architecture is crucial. Here is how our services map to ports:

This illustrates how services operate on discrete network ports and interface with each other securely.
Challenges Faced
Building a microservices-based system introduced several complex but rewarding challenges:
- Service Communication Complexity: Managing communication between multiple services required safely balancing REST APIs and RabbitMQ.
- Service Discovery & Routing: Ensuring all services dynamically register and communicate via Eureka required careful configuration and frustrating debugging.
- Authentication Integration: Integrating Keycloak with multiple discrete services and securing endpoints using JWT tokens was non-trivial.
- Data Consistency Across Services: Since each service has its own dedicated database (Database-per-Service pattern), maintaining consistency required deliberate design.
- Handling Asynchronous Workflows: Designing robust event-driven flows using RabbitMQ required understanding message queues, idempotency, and consumer patterns.
📚 What I Learned
Through this project, I gained invaluable hands-on experience in:
- Designing and implementing a production-grade microservices architecture.
- Working with Spring Cloud components like Eureka and API Gateway.
- Implementing rock-solid secure authentication using Keycloak and OAuth2.
- Designing an event-driven architecture utilizing RabbitMQ.
- Integrating external AI APIs (Google Gemini) into responsive backend systems.
- Managing multiple distinct databases (SQL + NoSQL) in a distributed network.
Most importantly, I learned how to think fundamentally in terms of system design rather than just writing code lines.
⚙️ Setup & Execution
Prerequisites
- Java 17+
- Node.js & npm
- Docker Desktop (for databases & messaging)
- A Google Gemini API Key
Step-by-Step Execution Order
1. Clone the repository
git clone https://github.com/UmashankarGouda/springboot-microservices-fitness-app.git
cd springboot-microservices-fitness-app
2. Start the Infrastructure (Databases, Message Broker, Keycloak) Rely on Docker Compose to spin up your dependency infrastructure in the background. This will seamlessly launch PostgreSQL, MongoDB, RabbitMQ, and the Keycloak server all at once:
docker compose up -d
3. Run Backend Services Run the services in this strict operational order to ensure they interlock correctly:
configservereurekakeycloakserver (assuming it isn't fully booted by Docker alone)gatewayuserservice,activityservice,aiservice
cd <service-folder>
mvn spring-boot:run
4. Run Frontend
cd fitness-app-frontend
npm install
npm run dev
Future Vision & Enhancements
This project can be dramatically extended into an enterprise-scale production platform by:
| Planned Enhancements |
|---|
| Docker containerization of all distinct backend services |
| Kubernetes-based deployment for elastic scaling |
| Full CI/CD pipeline integration |
| Real-time analytics dashboard via WebSockets |
| Wearable device data (IoT) integration |
| Multi-channel Notification system (Email/SMS) |
Conclusion
This project demonstrates how modern technologies can be elegantly combined to build a scalable, secure, and highly intelligent application.
It highlights the paramount importance of:
- Proper system design
- Decoupled architecture
- Secure, token-based communication
- Pragmatic AI integration
Overall, it serves as a powerful foundation for building complex real-world distributed systems.
If you found this helpful, let me know in the comments below or star the repo on GitHub!