Skip to content

MatthewBrandon21/Disease-Prediction-API-Capstone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Disease Prediction based Symptoms with Machine Learning

Product Capstone Bangkit Academy 2022

Tech Stack

Mobile: Kotlin

Machine Learning: Fast API, Tensorflow, Gunicorn

Client: React, React-dom, Axios, Bulma CSS, CKEditor 5, Lodash

Server: NodeJS, ExpressJS, MySQL, Sequelize, Google Cloud Storage, Multer, Joi, Jsonwebtoken, Cookie-Parser, Dotenv, Cors, Bcrypt

Scraping App: Python, request, ReGex, csv, GoogleTrans. & NodeJS, ExpressJs, Cheerio, Axios.

API and Admin dashboard Features

  • JWT Login with access and refresh token (http only cookie) (access token expired in 20s)

  • 2 Users role, admin & users with login validation and admin user management (ban, make admin, etc)

  • Role based route authorization

  • Upload files to Google Cloud Storage (Max 5mb)

  • CRUD diseases, diseases categories, drugs, deseases-drugs with deletion validation (won't delete data if used by other table)

  • Search to database

  • Form validation using JOI

  • SSL connection

API Deployment Link

https://api.capstone.matthewbd.my.id

deployed in GCP CE (N2 High CPU 2 Cores 2Gb ram) + Google Cloud Storage Bucket

ML API Deployment Link

https://ml.matthewbd.my.id

deployed in GCP CE (N2 High CPU 2 Cores 2Gb ram)

Admin Dashboard Deployment

https://capstone.matthewbd.my.id

deployed in GCP CE

User API Reference

Auto check user request from JWT Token (can't change another user's data when the token doesn't match).

Login

  POST /login
Parameter Type Description
email string Required
password string Required

notes

Already response with userdata. and if user "isactive" == 0 or banned, API will response 403.

Login - APP (without httponly Cookie)

  POST /login-app
Parameter Type Description
email string Required
password string Required

notes

Already response with userdata. and if user "isactive" == 0 or banned, API will response 403.

Register

  POST /register
Parameter Type Description
email string Required
username string Required
name string Required
address string
phonenum string
birthdate string
password string Required
confpassword string Required

notes

user image automatically use default profile picture. Update!, check email and username that exist and joi form validation

Get token

  GET /token

notes

Access token expired in 20s. Please read web in Acknowledgement

Get token

  POST /token-app
Parameter Type Description
refreshToken string Required

notes

Access token expired in 20s. Please read web in Acknowledgement

Logout

  GET /logout

Update profile

  POST /user/update
Parameter Type Description
email string Required
name string Required
address string
phonenum string
birthdate string

Update user password

  POST /user/updatepassword
Parameter Type Description
email string Required
oldpassword string Required
newpassword string Required
confpassword string Required

Update profile picture

  POST /user/update-profile-picture
Parameter Type Description
email string Required
file file Required

notes

"file" use http post file upload. Max file 5Mb (.jpg, .png, .jpeg). Please read web in Acknowledgement

Data API Reference (login required)

notes

use Authorization -> Bearer Token (.addHeader("Authorization", "Bearer " + token))

Get all Diseases

  GET /diseases

Get disease

  GET /diseases/${slug}

Get all Disease Categories

  GET /diseases-category

Get disease category

  GET /diseases-category/${slug}

Get all drugs

  GET /drugs

Get disease

  GET /drugs/${slug}

Get disease - drug

  GET /diseases-drugs/${slug}

Post search (also for find prediction result)

  POST /search
Parameter Type Description
keyword string Required. Anything in diseases and drugs

Post search disease

  POST /diseases
Parameter Type Description
keyword string Required. Anything in diseases

Post search drugs

  POST /drugs
Parameter Type Description
keyword string Required. Anything in drugs

Admin API Reference (Admin role required)

Post admin login

  POST /adminlogin

Get all users

  GET /users

Get ban users

  GET /banuser/:email

Get unban users

  GET /unbanuser/:email

Get make admin

  GET /makeadmin/:email

Get make user

  GET /makeuser/:email

Admin CRUD API Reference (Admin role required) (also applies to other tables)

Get all diseases

  GET /admin/diseases

Get diseases by slug

  GET /admin/diseases/:slug

Post make disease

  POST /admin/diseases

Patch update disease

  PATCH /admin/diseases/:slug

Delete disease

  DELETE /admin/diseases/:slug

Acknowledgements

Deployment

Install dependency first

  npm install

To deploy this project run

  npm run start

API app will run in port 5000 & React app will run in port 3000

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

ACCESS_TOKEN_SECRET

REFRESH_TOKEN_SECRET

GCS_BUCKET

GCLOUD_PROJECT

GCLOUD_CLIENT_EMAIL

GCLOUD_PRIVATE_KEY

Sequelize MySql database configuration in config/database.js

Set your frontend domain in cors configuration in index.js

If deployment have ssl, set secure mode in login cookie setting in app/controllers/Users.js

Releases

No releases published

Packages

No packages published