This guide helps you get started developing MLP.
Make sure you have the following dependencies installed before setting up your developer environment:
- Git
- Go 1.13 (see go.mod for minimum required version)
- Node.js 12 (LTS version or greater)
- Yarn
- Docker
MLP uses Google Sign-in to authenticate the user to access the API and UI. You can follow this tutorial to create your credential. After you get the client ID, specify it into OAUTH_CLIENT_ID
in the root's .env.development
and REACT_APP_OAUTH_CLIENT_ID
in the ui/packages/app/.env.development
.
We recommend using the Git command-line interface to download the source code for the MLP project:
- Create
github.com/caraml-dev
directory in your$GOPATH
by running:mkdir -p $GOPATH/src/github.com/caraml-dev
from your terminal. - Run
cd $GOPATH/src/github.com/caraml-dev
to go to the newly created caraml-dev directory. - Run
git clone [email protected]/caraml-dev/mlp.git mlp
to downloads MLP repository to a newmlp
directory. - Open the
mlp
directory using your favorite code editor.
MLP server consists of two components; the ui (frontend) and the api (backend).
Before we can build the UI assets, we need to install the dependencies:
make init-dep-ui
After the command has finished, we can start building our UI source code:
make start-ui
Once make start-ui
has built the assets, it will continue to do so whenever any of the UI files change. This means you don't have to manually build the assets every time you change the code.
Next, we'll build the web server that will serve the frontend assets we just built.
Build and run the backend by running:
make init-dep-api
make build-api
make local-db
make run
These commands download dependencies, compile the Go source code, start Postgres Docker container, and start the web server.
By default, you can access the web server at http://localhost:8080/.
The test suite consists of two types of tests: unit tests and end-to-end tests.
make test-api
make it-test-api
MLP follows the twelve-factor app by storing the config in the environment. By default, we include the .env.development
in the root directory into Makefile. You can override the default configuration by changing this file. If you run the MLP server without using make
command, you need to set the environment variables value by yourself.
MLP requires Postgresql to run. We uses Docker to make the task of setting up Postgresql databases a little easier.
make local-db
The script runs Postgresql Docker container.
To build a Docker image, run:
make build-image