SavorSafe is a comprehensive microservices-based application designed to enhance food safety through efficient management of recipes, inventory, notifications, and secure authentication. Built with Spring Boot, it leverages modern Java technologies to provide scalable, secure, and user-friendly services for food-related operations.
The application consists of four core microservices:
- inventory-service: Handles inventory tracking and management.
- notification: Manages alerts and notifications for users.
- OAuthService: Provides OAuth-based authentication and authorization.
- recipe-service: Stores, retrieves, and manages recipes with associated data.
SavorSafe follows a microservices architecture, allowing each service to be developed, deployed, and scaled independently. Services communicate via RESTful APIs and can be containerized using Docker for easy deployment.
- inventory-service (
/inventory-service): Spring Boot app with Maven. Manages items, stock levels, and inventory operations. - notification (
/notification): Spring Boot app with Maven. Sends notifications via email, SMS, or in-app alerts. - OAuthService (
/OAuthService): Spring Boot app with Gradle. Handles user authentication, token management, and security. - recipe-service (
/recipe-service): Spring Boot app with Maven. Manages recipe creation, storage, and retrieval, including JSON data files.
Each service includes:
- RESTful APIs
- Configuration files (YAML/Properties)
- Docker support
- Unit tests and build artifacts
- 🔐 Secure Authentication: OAuth2 integration for user login and access control.
- 📦 Inventory Management: Track ingredients, quantities, and expiration dates.
- 🔔 Notification System: Automated alerts for low stock, recipe updates, or safety reminders.
- 🍳 Recipe Management: Create, edit, and search recipes with nutritional data.
- 📚 API Documentation: Interactive Swagger UI for all services.
- 🐳 Containerization: Docker support for easy deployment and scaling.
- 🧪 Testing: Unit tests included for reliability.
- 🔧 Configurable: Environment-specific configurations via YAML/Properties files.
Before running SavorSafe, ensure you have the following installed:
- Java 17 or higher
- Maven 3.8+ (for Maven-based services: inventory-service, notification, recipe-service)
- Gradle 7.6+ (for OAuthService)
- Docker (optional, for containerized deployment)
- Git (for cloning the repository)
-
Clone the Repository:
git clone https://github.com/your-repo/SavorSafe.git cd SavorSafe -
Build Each Service:
-
For Maven services (
inventory-service,notification,recipe-service):cd <service-name> ./mvnw clean install
This generates JAR files in the
target/directory, e.g.,inventory-service-0.0.1-SNAPSHOT.jar. -
For
OAuthService(Gradle-based):cd OAuthService ./gradlew buildThis creates JAR files in the
build/libs/directory, e.g.,OAuthService-0.0.1-SNAPSHOT.jar.
-
-
Verify Builds:
- Check for compiled classes in
target/classes/(Maven) orbuild/classes/(Gradle). - Run tests:
./mvnw testor./gradlew test.
- Check for compiled classes in
Each service includes a Dockerfile. To build and run containers:
-
Build Images:
cd <service-name> docker build -t savorsafe/<service-name> .
-
Run Containers:
docker run -p <port>:<port> savorsafe/<service-name>
- Example ports: inventory-service (8081), notification (8082), OAuthService (8083), recipe-service (8084).
For the full stack, consider using Docker Compose (if a docker-compose.yml is added in the future).
SavorSafe can be deployed on a Kubernetes cluster using Minikube for local development.
-
Start Minikube:
minikube start --cpus=3 --memory=3000
-
Enable Metrics Server:
minikube addons enable metrics-server -
Patch Metrics Server Deployment:
kubectl patch deployment metrics-server -n kube-system \ --type='json' \ -p='[ { "op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls" }, { "op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-preferred-address-types=InternalIP" } ]'
-
Verify Metrics Server:
kubectl get pods -n kube-system | grep metrics -
Apply Kubernetes Manifests:
kubectl apply -f k8s/
-
Port Forwarding: Run each command in a new terminal:
kubectl port-forward svc/notification-service 8083:8083 kubectl port-forward svc/recipe-service 8082:8082 kubectl port-forward svc/oauth-service 8080:8080 kubectl port-forward svc/inventory-service 8081:8081
Ensure the k8s/ directory contains the necessary YAML files for deployments, services, and other resources.
-
Start Services:
- Run JAR files directly:
java -jar target/<service-name>.jar - Or use Docker as above.
- Run JAR files directly:
-
Access APIs:
- Base URLs (default ports):
- inventory-service:
http://localhost:8081 - notification:
http://localhost:8082 - OAuthService:
http://localhost:8083 - recipe-service:
http://localhost:8084
- inventory-service:
- Base URLs (default ports):
-
API Documentation:
- Visit
http://localhost:<port>/swagger-ui.htmlfor interactive docs. - Example: OAuthService includes OpenAPI config for auth endpoints.
- Visit
-
Configuration:
- Edit
application.yamlorapplication.propertiesinsrc/main/resources/for settings like database connections or ports.
- Edit
-
Testing:
- Run unit tests:
./mvnw testor./gradlew test. - Check test reports in
target/surefire-reports/(Maven) orbuild/reports/tests/(Gradle).
- Run unit tests:
SavorSafe/
├── inventory-service/
│ ├── Dockerfile
│ ├── pom.xml
│ ├── src/main/java/com/savorsafe/inventory_service/
│ ├── src/main/resources/application.yaml
│ └── target/ (build artifacts)
├── notification/
│ ├── Dockerfile
│ ├── pom.xml
│ ├── src/main/java/com/example/notifications/
│ ├── src/main/resources/application.yml
│ └── target/ (build artifacts)
├── OAuthService/
│ ├── build.gradle
│ ├── Dockerfile
│ ├── src/main/java/ (includes config/OpenApiConfig.java)
│ ├── src/main/resources/
│ └── build/ (build artifacts)
├── recipe-service/
│ ├── Dockerfile
│ ├── pom.xml
│ ├── src/main/java/com/savoursafe/recipe_service/
│ ├── src/main/resources/application.properties
│ ├── src/main/resources/data/recipes.json
│ └── target/ (build artifacts)
└── README.md
We welcome contributions! Follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature. - Make changes and add tests.
- Commit:
git commit -m "Add your feature". - Push:
git push origin feature/your-feature. - Open a Pull Request with a detailed description.
Ensure code follows Java best practices and includes unit tests.
- Aniket Baidya
- Gunja Pandey
- Anurag Paul
This project is licensed under the MIT License. See LICENSE for details.
For issues or questions, open an issue on GitHub or contact the maintainers.
Built with ❤️ using Spring Boot and microservices architecture.