.PHONY: build run clean help infra-up infra-down infra-logs run-engine run-web

# Command Variables
DOCKER_COMPOSE=docker compose
GO=go
NPM=npm

## infra-up: Start Valkey and Redis Insight containers in the background
infra-up:
	$(DOCKER_COMPOSE) up -d

## infra-down: Stop Valkey and Redis Insight containers
infra-down:
	$(DOCKER_COMPOSE) down

## infra-logs: Follow logs of the infrastructure containers
infra-logs:
	$(DOCKER_COMPOSE) logs -f

## run-engine: Build and run the Tongo Core backend engine daemon
run-engine:
	$(MAKE) -C tongo-core run

## run-web: Run the TanStack Start frontend web terminal dev server
run-web:
	cd web-terminal && $(NPM) run dev

## clean: Stop containers and clean all build artifacts and volumes
clean: infra-down
	$(MAKE) -C tongo-core clean
	$(DOCKER_COMPOSE) down -v

## help: Show this help
help:
	@grep -E '^## ' Makefile | sed 's/## //' | column -t -s ':'
