# Clipper

[![Build Status](https://drone.netflux.io/api/badges/rob/clipper/status.svg?ref=refs/heads/main)](https://drone.netflux.io/rob/clipper)

Clipper is a Youtube audio clipper developed using modern web technologies.

* Go
* protobuf, grpc-web
* Typescript
* React

It is currently in early development.

## Development

### Dependencies

It is required that an [ffmpeg](https://ffmpeg.org/download.html) binary is available in the current path.

### Running the app

The backend requires configuration via environment variables - see `backend/.env.example`. All variables must be set unless they are marked as optional.

Then, the server can be started with:

```
cd backend/
go run cmd/clipper/main.go
```

The frontend can be launched on localhost:3000 with:

```
cd frontend/
yarn start
```
### Code generation

To regenerate protobuf code and GRPC stubs, first install [protoc](https://grpc.io/docs/protoc-installation/) and the GRPC dependencies:

```
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```

Then generate the code with:

```
./protogen.sh
```

To regenerate the database access layer, first install [sqlc](https://sqlc.dev/). New queries can be added to `backend/sql/queries.sql`, and code regenerated with:

```
cd backend/
sqlc generate
```

Mocks require [mockery](https://github.com/vektra/mockery) to be installed, and can be regenerated with:

```
go generate ./...
```

### Migrations

Database migrations require [golang-migrate](https://github.com/golang-migrate/migrate).

```
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
```

Migrations then can be run with:

```
cd backend/
migrate -path sql/migrations -database $DATABASE_URL up
```
