Skip to content

DermaSeer/DermaSeer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bangkit 2024 Batch 2 Capstone Team C242-PS189

DermaSeer API - Cloud Computing

Table of Contents πŸ“

  1. Overview
  2. Getting Started
  3. Setup Guide
  4. env Configuration
  5. API Endpoints

Overview 🌐

  • DermaSeer API is an app that analyzes skin condition images using machine learning that provide diagnoses and use AI-powered to get product recommendations.

Contributor

Name Bangkit-ID Github-Profile LinkedIn
Rojak Kurniawan C318B4KY3957 @rojakkurniawan LinkedIn
Muhammad Rizqi Faadhilah C318B4KY3071 @mr-fadh LinkedIn

Getting Started πŸ› οΈ

Tech stack

NodeJS Express PostgreSQL Prisma Firebase Docker Google Cloud Storage Google Cloud Run Google Cloud Artifact Registry Google Vertex AI

Setup Guide πŸ§‘β€πŸ’»

1. Clone the Repo πŸ“©

  • Ensure you are on the right or your desired directory.
git clone https://github.com/DermaSeer/DermaSeer-api.git

2. Deploy Machine Learning Model API & VertexAI Models πŸ€–

  • Machine Learning Model API

    • Ensure that you already have the machine learning model deployed. You can follow the instructions in the DermaSeer-Model-API.
    • Save the deployed model URL to the .env file.
    # example: https://dermaseer-ml-api-id.asia-southeast2.run.app
    MODEL_API_URL=""
  • VertexAI Models

    # Vertex AI Model Endpoint
    VERTEX_AI_PROJECT_ID=""
    VERTEX_AI_LOCATION=""
    VETEX_AI_ENDPOINT_ID=""

3. Database PostgreSQL πŸ—„οΈ

  • PostgreSQL Installation

  • Create Database

    • Create a new PostgreSQL database for the project.
    CREATE DATABASE [db_name]
  • Configure .env file

    • Use PostgreSQL
    • Create Database and setup DATABASE_URL in .env
    DATABASE_URL=postgresql://username:password@localhost:5432/[db_name]

4. Cloud Storage ☁️

  • Create a Storage Bucket
    • Create a storage bucket on Google Cloud Platform.
    • Save the bucket name to the .env file.
    # Google Cloud Storage
    GOOGLE_CLOUD_PROJECT_ID=""
    GOOGLE_CLOUD_BUCKET_NAME=""
  • Fine-Grained Access Control
    • Ensure that you enable Fine-grained access control for your bucket.
  • Service Account Permissions
    • Create a Service Account in Google Cloud IAM with Storage Object Admin permissions.
    • Download the Service Account JSON key file
  • Save Credentials
    • Save the downloaded Service Account credentials file to:
    ./src/application/credentials/cloudStorage.json

5. Firebase Setup πŸ”₯

  • Firebase Admin
    • Go to your Firebase project settings.
    • Under Service Accounts, generate a new private key.
    • Save the Firebase Admin Service Account JSON file to:
    ./src/application/credentials/firebaseAdmin.json
  • Firebase App Web
    • In Firebase project settings, click General then add a new Web App.
    • Copy the Firebase configuration object.
    • Save the Firebase configuration object to ./src/application/firebaseAuth.js Example of firebaseAuth.js :
    const firebaseConfig = {
      apiKey: "",
      authDomain: "",
      projectId: "",
      storageBucket: "",
      messagingSenderId: "",
      appId: ""
    };

6. Running the Application πŸš€

  • Local Development
    • Install dependencies
      npm install
    • Run database migrations
      npx prisma migrate
    • Start the application
      # Production mode
      npm run start
      
      # Development mode
      npm run dev
  • Docker Deployment
    • Build docker image
      docker build -t dermaseer-api:1.0.0 .
    • Run the container
      docker run -d -p 5001:5001 --name backend dermaseer-api:1.0.0
  • Google Cloud Run Deployment
    • Create Artifact Registry Repository
      gcloud artifacts repositories create dermaseer \
      --repository-format=docker \
      --location=asia-southeast2
    • Set Up Environment Variables
      # Set your project ID
      export GOOGLE_CLOUD_PROJECT=your-project-id
      
      # Set your region
      export REGION=asia-southeast2
      
      # Set your service name
      export SERVICE_NAME=dermaseer-api
      
      # Setu your Artifact Registry Repository
      export ARTIFACT_REPO=dermaseer
    • Build and push docker image to Artifact Registry
      gcloud builds submit --tag asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/${ARTIFACT_REPO}/dermaseer-api:1.0.0
    • Deploy to Cloud Run
      gcloud run deploy ${SERVICE_NAME} \
      --image asia-southeast2-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/${ARTIFACT_REPO}/dermaseer-api:1.0.0 \
      --platform managed \
      --region ${REGION} \
      --allow-unauthenticated \
      --port 5001

Once the installation is complete:

env Configuration βš™οΈ

Variable Description
DATABASE_URL Connection string for the PostgreSQL database
PORT Port number for the Express.js server
GOOGLE_CLOUD_PROJECT_ID Google Cloud project ID
GOOGLE_CLOUD_BUCKET_NAME Name of Google Cloud Storage bucket
MODEL_API_URL URL for the external model API (e.g., deployed on Google Cloud Run)
VERTEX_AI_PROJECT_ID Google Cloud project ID for Vertex AI
VERTEX_AI_LOCATION Location for the Vertex AI model
VERTEX_AI_ENDPOINT_ID Endpoint ID for the deployed Vertex AI model

API Endpoints πŸ“‘

You can also explore and interact with these endpoints directly using our Postman collection: Postman API Documentation