The app architecture in the cloud will be like this :
We use Cloud Run, Cloud Firestore, and Vertex AI services to support our applications. The frontend utilizes APIs from two servers: the backend and machine learning models. The backend is directly connected to Cloud Firestore as its database and to Vertex AI for the food recommendation feature. We deploy these services in the Asia-Southeast2 region and the Asia-Southeast2-B zone.
Our application's database utilizes Firestore, which contains a primary `User` collection. Each document within this *User* collection represents an individual user and includes a tracker subcollection that stores related tracking information specific to that user. Additionally, there is a `Food` subcollection related to the user's tracking data. This subcollection stores details about various foodsEndpoint | Method | Body | Description |
---|---|---|---|
/ | GET | - | Accessing our root endpoints |
/auth/register | POST | firstName, lastName, phoneNumber, email, password, gender, weight, height, age | Register account for new user |
/auth/login | POST | email, password | Login to access the feature in application |
/user/profile | GET | - | Show the detail data from user |
/user/update | PUT | Anything you want to edit from firstName, lastName, phoneNumber, email, password, gender, weight, height, age |
Edit profile from user |
/user/delete | DELETE | - | Delete profile from user |
/tracker | GET | - | Show all glucose trackers from user |
/tracker/add | POST | glucose, condition, notes, datetime | Create new glucose tracker |
/tracker/delete/{{trackerId}} | DELETE | - | Delete glucose tracker from user |
/food | GET | name -> Query for search food by name |
Show all food from user or Search food |
/food/today | GET | - | Show all today's food from users |
/food/detail/{{foodId}} | GET | - | Show the detail food data |
/food/add | POST | foodName, gIndex, gLoad, giCategory, glCategory, carbs, calories, fats, proteins, category | Save food to firestore DB |
/food/delete/{{foodId}} | DELETE | - | Delete food from user |
/dataset | GET | - | Show all data from dataset |
/dataset/detail/{{dataId}} | GET | - | Show the detail data from dataset |
/ai/recommend | POST | foodName | Food recommendation by Vertex AI |
Endpoint | Method | Body | Description |
---|---|---|---|
/predict_new_data |
POST | foodName, category, calories, proteins, carbs, fats | Returns new meal's GI & GL |
- First, make sure the Artifact Registry, Cloud Run, and Cloud Build APIs are active by running the following command (click Authorize if the popup appears):
gcloud services enable artifactregistry.googleapis.com cloudbuild.googleapis.com run.googleapis.com
- Create an Artifact Registry repository by running the following command:
gcloud artifacts repositories create backend --repository-format=docker --location=asia-southeast2 --async
- Create a new container image by running the following command:
gcloud builds submit --tag asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/backend/glucofy-api:1.0.0
- Deploy a new container image to Google Cloud Run:
gcloud run deploy --image asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/backend/glucofy-api:1.0.0