Skip to content

BangkitCapstone2023/BarKit-CC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

logo

BarKit (Barang Kita) Backend

Backend For Bangkit 2023 Final Capstone Project

contributors last update forks stars open issues


πŸ“” Table of Contents

🌟 About the Project

πŸ“· Screenshots

Arc-Barkit drawio Database drawio

πŸ‘Ύ Tech Stack

BackEnd:

Cloud:

Tools:

🎯 Features

You can see all api feature at our API documentation

πŸ”‘ Credential File

To run this project, you will need the following credential file:

  • Firebase Admin SDK
    Go to firebase console -> pick your project -> project setting -> service account tab -> genereate new private key
  • Firebase Config/Client
    Go to firebase console -> pick your project -> project setting -> in general tab scroll down -> click add app button -> pick web logo "<\>" -> fill app nickname & click register app -> copy all const firebaseConfig variabel value -> make a new json file -> paste value from firebaseConfig variabel before and save the json file
  • Cloud Storage Credential
    Go to google cloud console -> go to IAM & Admin tab -> service account -> create service account -> fill service account name (ex: cloud-storage-barkit-admin) -> select the role to cloud storage admin -> click done -> click your service account you already created -> go to KEYS tab -> click add key -> create new key -> pick json -> create

Note: Note: if you are someone i know, request & download our credential Here

🧰 Getting Started

‼️ Prerequisites

  • Install node.js version 18.16.0 here
    Make sure your node.js and npm already install in your device using, open cmd and run:
    node -v
    npm -v
    Note: In development we are using Windows 10 Pro, Visual Studio Code, node version 18.16.0, and npm version 9.5.1.
  • Credential File
  • Docker, if you want to run this repostory with docker (recommended) and deploy to cloud run
  • Google Cloud Platform Account & Cloud Storage Bucket

πŸƒ Run Locally With NPM

Follow this step to run this repostory code in your local device:

  1. Open git bash and Clone the repo
git clone https://github.com/BangkitCapstone2023/BarKit-CC.git
  1. Go to project folder
cd BarKit-CC
  1. Open the project at VS Code
code . 
  1. open terminal & install Package
npm install
  1. Make sure you already have the Credential File and store the credential file name in app/config/config-template.json file.
  2. And also Change projectID, bucketName, and databaseURL value at app/config/config-template.json file, with your GCP project id, bucket name, and firestore database url, see the example here
  3. Change config-template.json file name to config.json
  4. Start the server
    npm start, or
    npm run dev (using nodemon)

Note:

  1. Steps 5-7 are only performed if you do not have access to Our Credential. If you are someone we know, please request to obtain our credentials and config file. After you download our credential make sure to store it at app/config folder.
  2. If there are any errors with tfjs-node, try this step

πŸ‹ Run Locally With Docker

Using Docker so you dont need to configure node version or get any error with tfjs-node

  1. Open git bash and Clone the repo
git clone https://github.com/BangkitCapstone2023/BarKit-CC.git
  1. Go to project folder
cd BarKit-CC
  1. Open the project at VS Code
code . 
  1. Make sure you already have the Credential File and store the credential file name in app/config/config-template.json file.
  2. And also Change projectID, bucketName, and databaseURL value at app/config/config-template.json file, with your GCP project id, bucket name, and firestore database url, see the example here
  3. Change config-template.json file name to config.json
  4. open terminal & build docker image
docker build -t barkit-backend .
  1. Run the docker image
docker run -p 8080:8080 barkit-backend

Note:

  1. Steps 4-6 are only performed if you do not have access to Our Credential. If you are someone we know, please request to obtain our credentials and config file. After you download our credential make sure to store it at app/config folder.
  2. You can use another name & add tag for the image

πŸ”§ Handle Error

You can ask us about your error here ,but If you have a problem with tensforflow.js when run locally with NPM, here some tips:

  1. npm install -g node-gyp
  2. Install the current version of Python here or from the Microsoft Store package in our development we are suing python 3.9.6.
  3. Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload)
  4. Go to powershell -> Run as administrator -> npm install -g --production windows-build-tools

Note: For TFJS-Node Error

  1. If you already done with 1 step (ex: install node-gcp), try running the server again. If the error persists, move on to the next step.
  2. If there is any error with node-gyp, try going here.
  3. If there is any error when trying steps 3 (install Python & Visual C++ build tools), check here.
  4. If there is any error with step 4 (install windows-build-tools), check here.

☁️ Deployment

To deploy this project we are using cloud run at GCP (you can use another service), this is the way to deploy it at cloud run:

  1. Build Container Image
  docker build -t IMAGE-NAME . 
  1. Run the docker image for make sure everything okay
docker run -p 8080:8080 IMAGE-NAME
  1. Make a repostory at artifact registery
  2. Push the Docker image to a artifact registery
docker tag SOURCE-IMAGE LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG
docker push YOUR-TAGGED-IMAGE-NAME
  1. Create a cloud run service and use your image at artifac registery repostory
  2. Check your deployed API Link

Note:

  1. Replace IMAGE-NAME, PROJECT-ID, REPOSTORY, TAG, YOUR-TAGGED-IMAGE-NAME according to what you have/want
  2. You can also use our cloudbuild.yaml file to CI/CD using cloud build at GCP, but dont forget to replace some variabel there

πŸ‘€ Usage

After you running the server you can testing it at postman, you can see our API Documentation for more detail

πŸ‘‹ Contributing

Contributtor in this repostory:

Contributions are always welcome! See CONTRIBUTING.md for ways to get started.

🀝 Contact

Muhammad Thoriq Ali Said - LinkedIn - Github - Instagram

πŸ’Ž Acknowledgements

Bellow is useful resource that we used in our project