Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SavorSafe

Java Spring Boot Maven Gradle Docker License: MIT

📖 Overview

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.

🏗️ Architecture

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.

Service Breakdown

  • 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

🚀 Features

  • 🔐 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.

📋 Prerequisites

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)

🛠️ Installation

  1. Clone the Repository:

    git clone https://github.com/your-repo/SavorSafe.git
    cd SavorSafe
  2. 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 build

      This creates JAR files in the build/libs/ directory, e.g., OAuthService-0.0.1-SNAPSHOT.jar.

  3. Verify Builds:

    • Check for compiled classes in target/classes/ (Maven) or build/classes/ (Gradle).
    • Run tests: ./mvnw test or ./gradlew test.

🐳 Docker Deployment (Optional)

Each service includes a Dockerfile. To build and run containers:

  1. Build Images:

    cd <service-name>
    docker build -t savorsafe/<service-name> .
  2. 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).

☸️ Kubernetes Deployment

SavorSafe can be deployed on a Kubernetes cluster using Minikube for local development.

  1. Start Minikube:

    minikube start --cpus=3 --memory=3000
  2. Enable Metrics Server:

    minikube addons enable metrics-server
  3. 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" } ]'
  4. Verify Metrics Server:

    kubectl get pods -n kube-system | grep metrics
  5. Apply Kubernetes Manifests:

    kubectl apply -f k8s/
  6. 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.

📖 Usage

  1. Start Services:

    • Run JAR files directly: java -jar target/<service-name>.jar
    • Or use Docker as above.
  2. Access APIs:

    • Base URLs (default ports):
      • inventory-service: http://localhost:8081
      • notification: http://localhost:8082
      • OAuthService: http://localhost:8083
      • recipe-service: http://localhost:8084
  3. API Documentation:

    • Visit http://localhost:<port>/swagger-ui.html for interactive docs.
    • Example: OAuthService includes OpenAPI config for auth endpoints.
  4. Configuration:

    • Edit application.yaml or application.properties in src/main/resources/ for settings like database connections or ports.
  5. Testing:

    • Run unit tests: ./mvnw test or ./gradlew test.
    • Check test reports in target/surefire-reports/ (Maven) or build/reports/tests/ (Gradle).

📁 Project Structure

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

🤝 Contributing

We welcome contributions! Follow these steps:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-feature.
  3. Make changes and add tests.
  4. Commit: git commit -m "Add your feature".
  5. Push: git push origin feature/your-feature.
  6. Open a Pull Request with a detailed description.

Ensure code follows Java best practices and includes unit tests.

👥 Contributors

  • Aniket Baidya
  • Gunja Pandey
  • Anurag Paul

📄 License

This project is licensed under the MIT License. See LICENSE for details.

🆘 Support

For issues or questions, open an issue on GitHub or contact the maintainers.


Built with ❤️ using Spring Boot and microservices architecture.

About

A microservices-based application for food safety management, featuring recipe storage, inventory tracking, notifications, and OAuth authentication. Built with Spring Boot, Java, Maven, and Gradle. Supports Docker containerization and API documentation via Swagger.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages