Skip to content

Setup Guide

Complete guide to setting up Mend for local development.

  1. Install Go 1.21+

    Terminal window
    brew install go
    go version # Verify installation
  2. Install Redis

    Terminal window
    brew install redis
    brew services start redis
    redis-cli ping # Should return PONG
  3. Install FFmpeg

    Terminal window
    brew install ffmpeg
    ffmpeg -version
  1. Clone and Initialize

    Terminal window
    cd /path/to/your/projects
    git clone https://github.com/yourusername/mend.git
    cd mend
    # Download Go dependencies
    go mod download
    go mod tidy
  2. Configure Application

    Terminal window
    # Copy example configuration
    cp config.example.yaml config.yaml
    cp .env.example .env
  3. Edit Configuration Files

    config.yaml
    server:
    port: 8080
    mode: debug # Use 'debug' for development
    api_keys:
    - "${API_KEY_1}"
    redis:
    addr: localhost:6379
    password: ""
    db: 0
    s3:
    region: us-east-1
    access_key_id: "${AWS_ACCESS_KEY_ID}"
    secret_access_key: "${AWS_SECRET_ACCESS_KEY}"
    worker:
    concurrency: 5 # Adjust based on CPU cores
    processing:
    temp_dir: /tmp/mend
    ffmpeg_path: ffmpeg
  4. Create Temp Directory

    Terminal window
    mkdir -p /tmp/mend

Terminal 1 - API Server:

Terminal window
go run cmd/api/main.go

Terminal 2 - Worker:

Terminal window
go run cmd/worker/main.go
Terminal window
curl http://localhost:8080/health

Open in your browser:

http://localhost:8080/swagger/index.html
  1. Start MinIO

    Terminal window
    docker-compose up -d minio
  2. Access MinIO Console

  3. Create a Bucket

    • Click “Buckets” → “Create Bucket”
    • Name: test-bucket
  4. Upload Test Image

    • Navigate to bucket
    • Click “Upload” → Select an image file
  5. Test Resize Endpoint

    Terminal window
    curl -X POST http://localhost:8080/api/v1/jobs/image/resize \
    -H "Content-Type: application/json" \
    -H "X-API-Key: your_api_key_here" \
    -d '{
    "source_bucket": "test-bucket",
    "source_key": "test-image.jpg",
    "dest_bucket": "test-bucket",
    "dest_key": "resized-image.jpg",
    "width": 800,
    "height": 600
    }'
Terminal window
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package
go test ./internal/processor/image
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
Terminal window
# Format code
go fmt ./...
# Run linter
golangci-lint run
# Install linter if needed
brew install golangci-lint
Terminal window
# Install swag
go install github.com/swaggo/swag/cmd/swag@latest
# Generate docs
swag init -g cmd/api/main.go -o docs
# Docs available at /swagger/index.html
Terminal window
# Install Air
go install github.com/cosmtrek/air@latest
# Run with hot reload
air
  • Directorycmd/
    • Directoryapi/
      • main.go
    • Directoryworker/
      • main.go
  • Directoryinternal/
    • Directoryapi/
      • Directoryhandlers/
      • Directorymiddleware/
      • Directoryroutes/
    • Directoryprocessor/
      • Directoryimage/
      • Directoryvideo/
      • Directoryaudio/
    • Directoryqueue/
    • Directorystorage/
  • config.yaml
  • .env
  • docker-compose.yaml
  • Makefile
Terminal window
brew install go
# or download from go.dev
Terminal window
brew services start redis
Terminal window
# Install FFmpeg
brew install ffmpeg
# Or specify full path in config.yaml
processing:
ffmpeg_path: /usr/local/bin/ffmpeg
Terminal window
# Verify credentials are set
echo $AWS_ACCESS_KEY_ID
echo $AWS_SECRET_ACCESS_KEY
# Test with AWS CLI
aws s3 ls
  1. Check Redis is running:

    Terminal window
    redis-cli ping
  2. Check worker logs for errors

  3. Verify queue configuration in config.yaml

  4. Check Redis queue length:

    Terminal window
    redis-cli LLEN asynq:queues:image
config.yaml
server:
port: 8081 # Use different port

Build

Terminal window
make build

Test

Terminal window
make test

Clean

Terminal window
make clean

Docker Up

Terminal window
make docker-up

Recommended Extensions:

  • Go (golang.go)
  • Docker (ms-azuretools.vscode-docker)
  • YAML (redhat.vscode-yaml)
  • REST Client (humao.rest-client)

Project should work out of the box:

  1. Set GOROOT to your Go installation
  2. Enable Go Modules
  3. Set working directory to project root

Try Examples

Check the examples/ directory for sample code