API Installation
Required
To run the API on your local machine, make sure these items are installed on your computer:
- Ensure you have Golang installed. Refer to the official Golang website for installation instructions: https://go.dev/doc/install (opens in a new tab).
- Ensure you have Docker installed. Refer to the official Docker website for installation instructions: https://docs.docker.com/desktop/ (opens in a new tab).
- Ensure you have MongoDB installed. Refer to the official MongoDB website for installation instructions: https://www.mongodb.com/docs/manual/installation/ (opens in a new tab). Or You can use MongoDB Atlas instead.
The other items that You need to setup are:
- Create App Password using Your Google Account. You can follow the step on this blog: https://knowledge.workspace.google.com/kb/how-to-create-app-passwords-000009237 (opens in a new tab)
- Create Oauth2 credential use Google API Client Libraries or Google OAuth 2.0 endpoints to implement OAuth 2.0 authorization to access Google APIs. You can follow the step on this docs: https://developers.google.com/identity/protocols/oauth2/web-server (opens in a new tab)
- Create Oauth2 credential use Facebook Developer. You can follow the step on this docs: https://baserow.io/user-docs/configure-facebook-for-oauth-2-sso (opens in a new tab)
- Create Your Midtrans account for the payment gateway that using by this project. Note: use the sandbox version. You see the documentation here (opens in a new tab)
Steps
To run the API on your local machine, make sure You follow these steps:
Clone the Repository
git clone https://github.com/IndraSty/GreenBasket.git
cd GreenBasket
Initialize Go module and download dependencies:
go mod init GreenBasket
go mod download
Start up a docker container running MongoDB and Redis. A docker-compose
file is provided to make this easier.Make sure you are in the same root folder as docker-compose
is located.
docker compose up
Create an .env
file and fill it according to the .env.example
file which has been completed according to the required items explained previously.
Import data from the /data
folder to your database. We recommend using a GUI like MongoDB Compas to make this easier.
Run the API on Your local machine
go run cmd/server/main.go
To build the source code running
go build