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
- 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.
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
Collection | Postman Link |
---|---|
Backend API collection |
Follow the steps below to get the backend API up and running:
-
Make sure you have success deploy Machine Learning Model in here
-
Clone this repository to your local machine:
git clone https://github.com/BiteSense/bitesense-api.git
-
Navigate to the project directory:
cd bitesense-api
-
Install the required dependencies:
npm install
-
Set Up database MySQL in phpMyAdmin according to the following specifications BiteSense Database
-
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.
-
Start the development server:
npm run start
-
The API should now be accessible at http://localhost:8080.
Tutorials, get you started with understanding and using the Bitesense-Api:
- Auth-Login
- Auth-Register
- Auth-Logout
- Profile-Get Data User
- Profile-Get Data Preference User
- Profile-Change Profile
- Preference-Input Preference User
- Preference-Update Preference User
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. |
SUCCESS
{
"statusCode": 200,
"status": "success",
"message": "success login",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6TIsImV4cCI6MTY4NTMzODY5Mn0.sim8HNM8AELtNpwi6NvKZiv_EDO9YAau513u2cyIW_8"
}
}
FAILED
{
"statusCode": 400,
"status": "error",
"message": "Email not 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. |
SUCCESS
{
"statusCode": 200,
"status": "success",
"message": "success register"
}
FAILED
{
"statusCode": 400,
"status": "error",
"message": "Email Already Excist"
}
DELETE api/users/register
SUCCESS
{
"statusCode": 200,
"status": "success",
"message": "Logout berhasil"
}
GET api/users/profile
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 api/users/preference
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"
},
]
}
}
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 |
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"
}
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
SUCCESS
{
"penyakit" : [
{"id" : 2},
{"id" : 3},
{"id" : 5}
],
"makanan" : [
{"id" : 1},
{"id" : 3},
{"id" : 5}
],
"kondisi" : [
{"id" : 2},
{"id" : 1},
{"id" : 4}
]
}
SUCCESS
{
"statusCode": 200,
"status": "success",
"message": "Success Input Data 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
SUCCESS
{
"penyakit" : [
{"id" : 2},
{"id" : 3},
{"id" : 5}
],
"makanan" : [
{"id" : 1},
{"id" : 3},
{"id" : 5}
],
"kondisi" : [
{"id" : 2},
{"id" : 1},
{"id" : 4}
]
}
SUCCESS
{
"statusCode": 200,
"status": "success",
"message": "Success Update Data Preference User"
}