open-sauced / pizza

This is an engine that sources git commits and turns them to insights
Apache License 2.0
32 stars 13 forks source link

Open Sauced

🍕 Pizza Oven Micro-service 🍕

A Go micro-service that sources git commits from any arbitrary git repo and indexes them into a postgres database.


GitHub code size in bytes GitHub issues GitHub Release Discord Twitter

🚀 Routes

/bake

The bake route accepts a POST request with the following json body:

{
    "url": "https://some-git-repo.com"
}

The server will then process the commits in the provided git repository by cloning the repo into memory, storing the individual commits and their authors.

Example:

curl -d '{"url":"https://github.com/open-sauced/insights"}' \
  -H "Content-Type: application/json" \
  -X POST http://localhost:8080/bake

🖥️ Local development

There are a few required dependencies to build and run the pizza-oven service:

Local postgres database setup

You can use a local postgres database (like with brew services start postgresql) configured to accept SSL connections that has been bootstrapped with the OpenSauced API migrations. It is highly recommended to follow the instructions in the API repository to get a locally running postgres going that can be used with the pizza oven micro-service.

You'll also need an .env file with the database's secrets (see .env.example in this repo for the required env variables), and a locally running version of the Go application.

To start the pizza oven service:

$ make run
{"level":"info","ts":1687800220.829255,"caller":"server/server.go:36","msg":"initiated zap logger with level: 0"}                                          │
{"level":"info","ts":1687800220.8293574,"caller":"server/server.go:48","msg":"Starting server on port 8080"}

This will start the go app, connect to your local postgres database using your .env file or existing environment variables, and start accepting requests.

See the .env.example file to see what environment variables are expected.

Local kubernetes setup

To get a local environment setup with a postgres database without having to start and configure one yourself, there is a convenience script that can be invoked with make setup-test-env which will bootstrap:

In order to run this setup script, you will also need:

Once you see the final step complete, the script will open a port to the pizza-oven service and be able to start accepting requests.