Decorative Line

INDONESIA

2:59 AM, Cileungsi - Bogor

ARDHIDHANI

DEV

#2

Project

See All Projects

Project Foedtra - Bangkit 2022 Cloud Computing Capstone

Project Foedtra: Revolutionizing Indonesian Culinary Discovery

Published by Ardhi Ramadhani on June 13, 2022

Foedtra Cloud Architecture

Introduction

Foedtra is a cutting-edge application that bridges the gap between traditional Indonesian cuisine and modern technology. By leveraging advanced machine learning and cloud computing, Foedtra aims to predict and provide detailed information about traditional foods from user-uploaded images, while also recommending nearby restaurants that serve these dishes.

Background

In recent years, Indonesia has witnessed a significant shift in eating habits, largely influenced by the rapid expansion of global food chains. This trend has led to a concerning unfamiliarity with the rich variety of traditional Indonesian foods among both locals and tourists.

Research indicates that hundreds of global food brands are reshaping local dining preferences, potentially overshadowing the diverse and flavorful landscape of Indonesian cuisine. This situation presents both a challenge and an opportunity:

  • Challenge: Preserving and promoting awareness of Indonesia's culinary heritage.
  • Opportunity: Harnessing technology to reintroduce and celebrate traditional foods, while supporting local vendors and boosting culinary tourism.

Recognizing this, the Indonesian government has, over the past five years, intensified its support for culinary tourism as a key component of its international tourism strategy. Foedtra aligns perfectly with this initiative, offering an innovative solution to detect, recommend, and educate users about Indonesian foods.

Technical Implementation

Cloud Architecture and Data Flow

Foedtra API Flow

Foedtra's robust cloud-based architecture seamlessly integrates several key components:

  1. Mobile App: The user-friendly interface for image uploads and receiving recommendations.
  2. Backend API (Node.js): The central coordinator managing communication between all services.
  3. ML API (Flask): Handles image processing and food recognition using advanced machine learning models.
  4. Places API: Sources nearby restaurant information based on user location.

The data flow follows a streamlined process:

  1. User uploads an image via the mobile app.
  2. Backend API receives the image and location data.
  3. ML API processes the image for food recognition.
  4. Places API is queried for relevant restaurant recommendations.
  5. Compiled results are sent back to the user through the mobile app.

This architecture ensures efficient processing, accurate recognition, and personalized recommendations, all while maintaining scalability and responsiveness.

Backend API Infrastructure

Backend Infrastructure

Foedtra's Backend API leverages modern technologies and Google Cloud Platform services:

  1. Core Technologies:

    • Express.js and Node.js for efficient server-side operations
    • Terraform for Infrastructure as Code (IaC)
  2. GCP Services:

    • Cloud Build for automated CI/CD
    • Container Registry for Docker image management
    • Cloud Run for serverless container deployment
    • Secret Manager for secure credential storage
  3. Deployment Pipeline:

    • Triggered by GitHub pushes
    • Automated build and deployment process
    • Containerization for consistency across environments

This setup ensures a secure, efficient, and scalable backend infrastructure.

Link to the repository: backend-foedtra repository

How I Deploy this Backend API

1. Open Google Cloud Build

  • Navigate to Cloud Build from the Google Cloud Console.
  • Ensure that you have the necessary permissions to configure build triggers and deploy services.

2. Create a Secret in Google Secret Manager

  1. Go to Secret Manager (found under Security in the left-hand sidebar).
  2. Click on Create Secret.
    • Name: Provide a name for the secret (e.g., my-secret).
    • Secret value: Paste the secret content or value (e.g., API keys, credentials).
  3. Click Create Secret to save the new secret

Note: You can also choose the replication policy, such as automatic replication across multiple regions, based on your project requirements.

3. Navigate to Cloud Build Triggers

  1. Return to Cloud Build by selecting it from the navigation menu.
  2. Choose Triggers from the dashboard.
  3. Click Create Trigger to set up a new build trigger.r.

4. Configure the Trigger Details

  1. Under Repository, connect your source code repository (e.g., GitHub, GitLab, etc.).
    • Ensure that you have integrated your repository with GCP (this may involve authorizing Cloud Build to access your repository).
  2. Event: Select the event that will trigger the build (e.g., Push to a branch, Pull request, or Tag creation).
  3. Branch/Tag: Specify the branch (e.g., main, master) where the build should be triggered.

5. Define Build Configuration

  • Choose how to provide the build configuration:
    • You can either use an existing cloudbuild.yaml file from the repository or manually specify build steps.

Example cloudbuild.yaml (for Docker-based deployment):

steps:
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-app', '.']
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/$PROJECT_ID/my-app']
images:
  - 'gcr.io/$PROJECT_ID/my-app'

6. Add Environment Variables (Secrets)

  1. Under Advanced options, select the Secrets created in Secret Manager.
  2. These secrets can be injected into your build process or container as environment variables or files during the build.

7. Finalize and Deploy

  1. Once your configuration is complete, click Create Trigger to finalize the setup.
  2. On push or other specified events (as per your trigger configuration), Cloud Build will run the build, execute the defined steps, and deploy your service.
terraform init
trraform plan
terraform apply

Additional Resources

For detailed instructions and visual aids, you can refer to the picture step-by-step guide found in the backend-foedtra repository.

Machine Learning API Infrastructure

ML API Infrastructure

The ML component utilizes:

  1. Core Technologies:

    • TensorFlow for the food recognition model
    • Flask for API creation
    • Docker for containerization
  2. Deployment Process:

    • Packaging the TensorFlow model and Flask API into a Docker container
    • Deployment on Google Cloud Run

This infrastructure allows for efficient scaling and handling of food recognition requests, leveraging the benefits of containerization and serverless architecture.

Links to the repositories:

How i Deploy the ML API in Cloud Run via Cloud Console

Build Docker image Cloud shell

  • Docker build -t gcr.io/$MY_PROJECT_ID/foedtra-ml:v1 -f Dockerfile .
  • docker push gcr.io/$MY_PROJECT_ID/foedtra-ml:v1

Deploy in Cloud Run

Via Cloud Console

  • Container image URL -> Select Docker Image
  • Container port = 8080
  • Memory = 4 GiB
  • CPU = 2
  • Execution environment = Second generation
  • Auto Scalling =
    • Minimum instances = 1
    • Maximum instances = 5

Via Cloud Shell or Terminal/CMD VsCode with Cloud SDK

  • Open Cloud Shell/Terminal
  • gcloud init -> Select account and Project
gcloud run deploy foedtra-ml \
 --image gcr.io/$MY_PROJECT_ID/foedtra-ml:v1 \
 --region asia-southeast2 \
 --platform managed \
 --port 8080 \
 --memory 4GiB \
 --cpu 2 \
 --max-instances 5 \
 --min-instances 1 \
 --execution-environment gen2 \

Android Design

Android App Design

The Foedtra Android app features a user-friendly interface with a distinctive mustard yellow color scheme. Key features include:

  1. Firebase Authentication: Secure user login and account management.
  2. Food Recognition: A prominent "+" button for capturing or uploading food images, initiating the prediction process.
  3. Detailed Food Information: Displays information about recognized dishes, including origin and cultural significance.
  4. Restaurant Recommendations: Provides a list of nearby restaurants serving the recognized dish, with map integration.
  5. Intuitive Navigation: Clean, card-based design for easy browsing.

The app's design facilitates easy food recognition and discovery while creating an engaging and educational experience for users exploring Indonesian cuisine.

Link to the repository: android repository

Conclusion

Foedtra represents a significant step towards preserving and promoting Indonesian culinary heritage. By combining advanced technology with cultural appreciation, we're not only helping users discover traditional foods but also supporting local businesses and enhancing culinary tourism.


Decorative Line