Skip to content

krisnasaputtra/bitesense-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BiteSense-Api

The Bitesense-Api interacts with the client-side Mobile-Dev and Machine-Learning, to serving various request from client-side then bridges the requests from client-side to Machine-Learning model

Features

  • Deployed on Google Cloud Platform using Cloud Run for scalability.
  • Built with Node.js and Express framework.
  • Utilizes Google Cloud services such as Cloud SQL and Cloud Storage.
  • Implements a machine learning model for object detection
  • Provides CRUD operations for product,users items.

Prerequisites

Before running the project locally or deploying it, make sure you have the following prerequisites installed:

  • Node.js (v16 or above)
  • npm package manager
  • Google Cloud Platform account with enabled services:
    • Cloud Run
    • Cloud SQL
    • Cloud Storage

Cloud-Architecture:

cloud_arch

Collection Postman Link
Backend API collection Run in Postman

Getting Started:

Follow the steps below to get the backend API up and running:

  1. Make sure you have success deploy Machine Learning Model in here

  2. Clone this repository to your local machine:

    git clone https://github.com/BiteSense/bitesense-api.git
  3. Navigate to the project directory:

    cd bitesense-api
  4. Install the required dependencies:

    npm install
  5. Set Up database MySQL in phpMyAdmin according to the following specifications BiteSense Database

  6. Set up the environment variables by creating a .env file in the root directory. Use the .env.example file as a template and provide the necessary values.

  7. Start the development server:

    npm run start
  8. The API should now be accessible at http://localhost:8080.

Tutorials, get you started with understanding and using the Bitesense-Api:

Documentation:

Login

All request require API key. You can find your Api key if you Login. Signin user if already have an account. Return a token to use authenticate and authorization.

POST api/users/login
Parameter Type Description
email string Required.
password string Required.

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "success login",
    "data": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6TIsImV4cCI6MTY4NTMzODY5Mn0.sim8HNM8AELtNpwi6NvKZiv_EDO9YAau513u2cyIW_8"
    }
}

FAILED

{
    "statusCode": 400,
    "status": "error",
    "message": "Email not Register"
}

Register

Create user if any user already have an account.

POST api/users/logout
Parameter Type Description
email string Required.
password string Required.
repassword string Required.
username string Required.

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "success register"
}

FAILED

{
    "statusCode": 400,
    "status": "error",
    "message": "Email Already Excist"
}

Logout

DELETE api/users/register

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "Logout berhasil"
}

Get Data Profile

GET api/users/profile

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "Success Get Data User",
    "data": {
        "result": {
            "username": "chris",
            "email": "[email protected]",
            "no_telepon": null,
            "foto_user": "https://storage.googleapis.com/staging_product/default-profile.jpg"
        }
    }
}

Get Data Preference

GET api/users/preference

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "success get data",
    "data": {
        "dataPenyakit": [
            {
                "nama_penyakit": "Alergi Kacang",
                "triger_penyakit": "Kacang"
            },
        ],
        "dataKondisi": [
            {
                "name_condition": "Diabetes",
                "triger_condition": "Gula,Fruktosa"
            },
        ],
        "dataFood": [
            {
                "name_food": "Dairy",
                "triger_food": "Laktosa"
            },
        ]
    }
}

Change Profile

POST api/users/profile
Request Type Description Parameter Status
POST api/users/profile/email string Required. email Ok
POST api/users/profile/username string Required. username Ok
POST api/users/profile/telepon string Required. telepon Ok
POST api/users/profile/upload file Required. file Ok
DELETE api/users/profile/delete NONE Required. NONE Ok

Response

SUCCESS - Email

{
    "statusCode": 200,
    "status": "success",
    "message": "berhasil mengubah email"
}

SUCCESS - Username

{
    "statusCode": 200,
    "status": "success",
    "message": "berhasil mengubah username"
}

SUCCESS - Telepon

{
    "statusCode": 200,
    "status": "success",
    "message": "berhasil mengubah nomor telepon"
}

SUCCESS - Photo Profile

{
    "statusCode": 200,
    "status": "success",
    "message": "success upload image",
    "data": {
        "publicUrl": "https://storage.googleapis.com/staging_product/168525472329231619github.png"
    }
}

SUCCESS - Delete Photo Profile

{
    "statusCode": 200,
    "status": "success",
    "message": "succes delete profile"
}

Input Preference User

for Input preferences and also Update Preferences use a body with a request of type json then the number listed on the request body json is a numbering index which can be seen in the following table

Category Food Intolarance

Name Food Index
Dairy 1
Gluten 2
Kafein 3
Fruktosa 4
Biji Bijian 5
MSG 6
Salicylates 7
Ragi 8
Pewarna Makanan 9

Category Condition

Name Food Index
Diabetes 1
Hipertensi 2
Hamil 3
Obesitas 4
Maag 5
Stroke 6
Asam Urat 7

Category Disease

Name Food Index
Alergi Kacang 1
Alergi Telur 2
Alergi Kedelai 3
Alergi Gandum 4
Alergi Ikan 5
Alergi Susu 6
Alergi Shellfish 7
Alergi Kacang Pohon 8
POST api/users/preference

Request

SUCCESS

{
    "penyakit" : [
        {"id" : 2},
        {"id" : 3},
        {"id" : 5}
    ],
    "makanan" : [
        {"id" : 1},
        {"id" : 3},
        {"id" : 5}
    ],
    "kondisi" : [
        {"id" : 2},
        {"id" : 1},
        {"id" : 4}
    ]
}

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "Success Input Data Preference User"
}

Update Preference User

for Input preferences and also Update Preferences use a body with a request of type json then the number listed on the request body json is a numbering index which can be seen in the following table

Category Food Intolarance

Name Food Index
Dairy 1
Gluten 2
Kafein 3
Fruktosa 4
Biji Bijian 5
MSG 6
Salicylates 7
Ragi 8
Pewarna Makanan 9

Category Condition

Name Food Index
Diabetes 1
Hipertensi 2
Hamil 3
Obesitas 4
Maag 5
Stroke 6
Asam Urat 7

Category Disease

Name Food Index
Alergi Kacang 1
Alergi Telur 2
Alergi Kedelai 3
Alergi Gandum 4
Alergi Ikan 5
Alergi Susu 6
Alergi Shellfish 7
Alergi Kacang Pohon 8
POST api/users/update

Request

SUCCESS

{
    "penyakit" : [
        {"id" : 2},
        {"id" : 3},
        {"id" : 5}
    ],
    "makanan" : [
        {"id" : 1},
        {"id" : 3},
        {"id" : 5}
    ],
    "kondisi" : [
        {"id" : 2},
        {"id" : 1},
        {"id" : 4}
    ]
}

Response

SUCCESS

{
    "statusCode": 200,
    "status": "success",
    "message": "Success Update Data Preference User"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.9%
  • Dockerfile 1.1%