MayricoAK / Nyenyak-backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nyenyak Cloud Computing Documentation

Status: Active Version: 1.0.0 Contributors: 2

Project Summary

Nyenyak uses Google Cloud Platform (GCP) and Firebase to develop a system capable of classifying sleep disorders, such as insomnia and sleep apnea, based on user data. Additionally, the system will provide actionable suggestions to enhance the sleep quality of users experiencing sleep disturbances. The project involves a collaboration between machine learning, mobile development, and cloud computing teams.

Table of Contents

Cloud Architecture

Architecture Illustration

1. Setup Google Cloud Platform

  • Create Project & Configure Identity and Access Management.
  • Enable the following APIs:
    • App Engine API
    • Cloud Run Admin API
    • Google Container Registry API
    • Firebase API (Management, Realtime Database, etc.)
    • Cloud Monitoring API
    • Cloud Logging API

2. Setup Firebase

  • Open Firebase, go to the console, and connect it to your Google Cloud Project.
  • Activate Firebase Auth & Firebase Realtime Database.
  • Create a Service Account and download the corresponding seviceAccountKey.json file.

3. Clone Project and Set Google Cloud Account

  • Open cloud shell or your preferred code editor (Visual Studio Code).
  • Clone the Nyenyak project from Nyenyak-Backend-Repo using the command git clone -b BackEnd https://github.com/w0n0g1ren/Nyenyak.git.
  • Initialize a Git repository with git init and connect it to your Google Cloud account.

4. Set Project and Deploy Application

In the terminal, set your project by executing gcloud config set project nyenyak-project-dev. Deploy both nodeJS and model API to App Engine and Cloud Run.

Deploy Model API

  • Open Model-API directory
    cd Model-API
    
  • Follow readme to install depencies
  • Build and Push Docker Image
    docker build -t gcr.io/nyenyak-project-dev/nyenyak-api-model .
    docker push gcr.io/nyenyak-project-dev/nyenyak-api-model
    
  • Deploy Docker Image by Cloud Run
    gcloud run deploy nyenyak-api-model \
      --image gcr.io/nyenyak-project-dev/nyenyak-api-model \
      --platform managed \
      --allow-unauthenticated
    
  • Wait and save deployed Model-API link

Deploy Backend API to App Engine

  • Open Backend-API directory
    cd ../Backend-API
    
  • Follow readme to install depencies and add serviceAccountKey.json
  • Copy deployed Model-API link and paste to Backend-API/routes/diagnosis.js in line 156 (Make sure to add /prediction to endpoint, example: https://nyenyak-model-api-z2dhcxitca-et.a.run.app to https://nyenyak-model-api-z2dhcxitca-et.a.run.app/prediction)
  • Deploy to App Engine
    gcloud app deploy
    

5. API Documentation

Additional Backend Details:

  • Backend API is built using Node Express.js to handle user authentication, diagnosis, articles, and user details.
  • We deployed the backend API to App Engine for easier scalability and reliability.
  • A separate API for TensorFlow model, built using Flask and deployed to Cloud Run.
  • Utilize Cloud Monitoring & Logging for comprehensive resource monitoring and alerting.

Conclusion

The Nyenyak project integrates Google Cloud Platform and Firebase Realtime Database to create a robust and scalable solution. The backend architecture ensures efficient communication between the mobile app, backend API, and machine learning model, providing users with accurate sleep disorder diagnoses and solution for improvement.

About


Languages

Language:JavaScript 83.8%Language:Python 15.5%Language:Dockerfile 0.7%