.PHONY: help install dev build test test-e2e e2e-full clean migrate

help:
	@echo "Available targets:"
	@echo "  install    - Install dependencies"
	@echo "  dev        - Start development environment"
	@echo "  build      - Build all services"
	@echo "  test       - Run backend + frontend tests (go test, lint, type-check)"
	@echo "  test-e2e   - Run Playwright E2E tests (default: explorer.d-bis.org)"
	@echo "  e2e-full   - Boot full stack locally (docker compose + backend + frontend) and run Playwright"
	@echo "  clean      - Clean build artifacts"
	@echo "  migrate    - Run database migrations"

install:
	cd backend && go mod download
	cd frontend && npm install

dev:
	docker-compose -f deployment/docker-compose.yml up -d postgres elasticsearch redis
	@echo "Waiting for services to be ready..."
	sleep 5
	cd backend && go run database/migrations/migrate.go
	@echo "Starting services..."
	cd backend/indexer && go run main.go &
	cd backend/api/rest && go run main.go &
	cd frontend && npm run dev

build:
	cd backend && go build ./...
	cd frontend && npm run build

test:
	cd backend && go test ./...
	cd frontend && npm test

test-e2e:
	npx playwright test

e2e-full:
	./scripts/e2e-full.sh

clean:
	cd backend && go clean ./...
	cd frontend && rm -rf .next node_modules

migrate:
	cd backend && go run database/migrations/migrate.go

