This project is a Spring Boot microservices-based fitness platform that generates AI-driven recommendations based on user fitness activities. It leverages modern distributed system patterns, messaging queues, and GenAI to provide intelligent insights that help users improve their health and workout routines.
The system is designed with scalability, resilience, and modularity in mind using a microservices architecture.
The application is composed of the following services:
ai_powered_fitness_app/
│
├── configService # Centralized configuration management
├── eurekaServer # Service discovery
├── gateway # API Gateway (entry point)
├── userService # User management (PostgreSQL)
├── activityService # Activity tracking (MongoDB)
├── aiservice # AI recommendation engine (GenAI + MongoDB)
-
Backend: Spring Boot, Spring Cloud
-
Service Discovery: Eureka Server
-
API Gateway: Spring Cloud Gateway
-
Messaging: RabbitMQ
-
Databases:
- PostgreSQL (User Service)
- MongoDB (Activity & AI Services)
-
AI Integration: Gemini (GenAI)
-
Configuration Management: Spring Cloud Config Server
-
Build Tool: Maven/Gradle
-
Containerization (optional): Docker
-
User registers via User Service
-
User logs activity via Activity Service
-
Activity is:
- Stored in MongoDB
- Published to RabbitMQ
-
AI Service consumes activity events
-
AI Service:
- Processes activity data
- Calls GenAI (Gemini API)
- Generates personalized recommendations
-
Recommendations are stored and made accessible via API Gateway
-
Tracks user fitness activities
-
Includes:
- Duration
- Calories burned
- Activity type
- Additional metrics
-
AI-generated insights:
- Improvements
- Suggestions
- Safety measures
- Natural language recommendation
-
Stores user profile:
- Name
- Password (should be encrypted)
-
Activities are published using:
rabbitTemplate.convertAndSend(exchange, routingKey, savedActivity);
-
Enables asynchronous communication between services
-
Decouples Activity Service from AI Service
All services fetch configurations from a centralized Config Server, including:
- Database credentials
- RabbitMQ configs
- API keys (Gemini)
- Service-specific properties
AI Service integrates with Gemini API using:
@ConfigurationProperties(prefix = "gemini.api")Used to:
- Analyze user activity
- Generate contextual fitness advice
- Provide safety-aware recommendations
git clone https://github.com/EmmanuelAdah/fitness-app-microservices.git
cd ai-fitness-appEnsure the following are running:
- MongoDB
- PostgreSQL
- RabbitMQ
(Optional via Docker)
- configService
- eurekaServer
- gateway
- userService
- activityService
- aiservice
All services are exposed through the API Gateway:
http://localhost:8080/api/...
-
Create a user
-
Log an activity:
{ "userId": "123", "activityType": "RUNNING", "duration": 30, "caloriesBurned": 250 } -
AI Service generates:
- Suggestions to improve endurance
- Safety recommendations
- Personalized fitness advice
- ✅ Microservices architecture
- ✅ Event-driven communication (RabbitMQ)
- ✅ AI-powered recommendations
- ✅ Multi-database support
- ✅ Centralized configuration
- ✅ Scalable and extensible design
- JWT Authentication & Authorization
- Rate limiting at API Gateway
- Circuit breakers (Resilience4j)
- Observability (Prometheus + Grafana)
- Model fine-tuning for better recommendations
- Ensure sensitive configs (API keys, DB passwords) are stored securely.
- Use environment variables for production deployments.
- Add validation and encryption for user credentials.