.DEFAULT_GOAL := help COMPOSE ?= docker compose COMPOSE_DIR := infrastructure/dev COMPOSE_FILE := $(COMPOSE_DIR)/docker-compose.yml ENV_FILE := $(COMPOSE_DIR)/.env COMPOSE_CMD := $(COMPOSE) -f $(COMPOSE_FILE) --env-file $(ENV_FILE) --project-directory $(COMPOSE_DIR) COMPOSE_PROD_DIR := infrastructure/prod COMPOSE_PROD_FILE := $(COMPOSE_PROD_DIR)/docker-compose.yml ENV_PROD_FILE := $(COMPOSE_PROD_DIR)/.env.prod COMPOSE_PROD_CMD := $(COMPOSE) -f $(COMPOSE_PROD_FILE) --env-file $(ENV_PROD_FILE) --project-directory $(COMPOSE_PROD_DIR) ifneq ("$(wildcard $(ENV_FILE))","") include $(ENV_FILE) endif POSTGRES_USER ?= knowfoolery POSTGRES_PASSWORD ?= knowfoolery POSTGRES_PORT ?= 5432 POSTGRES_DB ?= knowfoolery REDIS_PORT ?= 6379 ZITADEL_PORT ?= 8080 PROMETHEUS_PORT ?= 9091 GRAFANA_PORT ?= 3001 JAEGER_UI_PORT ?= 16686 ZITADEL_ADMIN_USERNAME ?= admin ZITADEL_ADMIN_PASSWORD ?= AdminPassword123! GRAFANA_ADMIN_USER ?= admin BACKEND_MODULES := \ services/admin-service \ services/game-session-service \ services/gateway-service \ services/leaderboard-service \ services/question-bank-service \ services/user-service \ shared .PHONY: help dev dev-full dev-auth dev-gateway stop clean \ infra-build-images infra-up-prod \ task-security-scan task-deploy-dev task-deploy-prod task-k6-smoke task-k6-load \ backend-lint backend-test backend-build \ frontend-dev frontend-lint frontend-test frontend-e2e frontend-build \ db-up db-down db-logs db-shell redis-shell \ lint test build # Default target help: @echo "KnowFoolery Development Commands" @echo "" @echo "Development Environment:" @echo " make dev - Start core infrastructure (PostgreSQL, Redis)" @echo " make dev-full - Start core infrastructure + observability" @echo " make dev-auth - Start core infrastructure + Zitadel auth" @echo " make dev-full-auth - Start core infrastructure + observability + Zitadel auth" @echo " make dev-gateway - Start core infrastructure + gateway ingress (NGINX + gateway service)" @echo " make stop - Stop all containers" @echo " make clean - Stop containers and remove volumes" @echo " make infra-build-images - Build all production service images via compose" @echo " make infra-up-prod - Run production compose stack locally (simulation)" @echo "" @echo "Task Workflows:" @echo " make task-security-scan - Run Task CI security pipeline" @echo " make task-deploy-dev - Run Task development deployment pipeline" @echo " make task-deploy-prod - Run Task production deployment pipeline" @echo " make task-k6-smoke - Run k6 smoke profile (requires K6_BASE_URL)" @echo " make task-k6-load - Run k6 load profile (requires K6_BASE_URL)" @echo "" @echo "Backend:" @echo " make backend-lint - Run Go linters" @echo " make backend-test - Run Go tests" @echo " make backend-build - Build all services" @echo "" @echo "Frontend:" @echo " make frontend-dev - Start frontend dev server" @echo " make frontend-lint - Run ESLint and Prettier" @echo " make frontend-test - Run frontend tests" @echo " make frontend-e2e - Run frontend Playwright critical-flow tests" @echo " make frontend-build - Build frontend for production" @echo "" @echo "Database:" @echo " make db-up - Start PostgreSQL and Redis" @echo " make db-down - Stop PostgreSQL and Redis" @echo " make db-logs - Show PostgreSQL logs" @echo " make db-shell - Open PostgreSQL shell" @echo " make redis-shell - Open Redis CLI" @echo "" @echo "All:" @echo " make lint - Run all linters" @echo " make test - Run all tests" @echo " make build - Build everything" # ============================================================================= # Development Environment # ============================================================================= dev: @echo "Starting core infrastructure..." @$(COMPOSE_CMD) up -d postgres redis @echo "Waiting for services to be healthy..." @sleep 5 @echo "" @echo "Infrastructure ready:" @echo " PostgreSQL: localhost:$(POSTGRES_PORT) (user: $(POSTGRES_USER), password: $(POSTGRES_PASSWORD))" @echo " Redis: localhost:$(REDIS_PORT)" dev-full: dev @echo "Starting observability stack..." @$(COMPOSE_CMD) --profile observability up -d @echo "" @echo "Observability ready:" @echo " Prometheus: http://localhost:$(PROMETHEUS_PORT)" @echo " Grafana: http://localhost:$(GRAFANA_PORT) (admin: $(GRAFANA_ADMIN_USER))" @echo " Jaeger: http://localhost:$(JAEGER_UI_PORT)" dev-auth: dev @echo "Starting authentication stack..." @$(COMPOSE_CMD) --profile auth up -d @echo "" @echo "Zitadel ready at http://localhost:$(ZITADEL_PORT)" @echo "Admin credentials: $(ZITADEL_ADMIN_USERNAME) / $(ZITADEL_ADMIN_PASSWORD)" dev-full-auth: dev-full @echo "Starting authentication stack..." @$(COMPOSE_CMD) --profile auth up -d @echo "" @echo "Zitadel ready at http://localhost:$(ZITADEL_PORT)" @echo "Admin credentials: $(ZITADEL_ADMIN_USERNAME) / $(ZITADEL_ADMIN_PASSWORD)" dev-gateway: dev @echo "Starting gateway ingress stack..." @$(COMPOSE_CMD) --profile gateway up -d gateway-service nginx @echo "" @echo "Gateway ingress ready:" @echo " Public entrypoint (NGINX): http://localhost:$(GATEWAY_PORT)" stop: @echo "Stopping all containers..." @$(COMPOSE_CMD) down clean: @echo "Stopping containers and removing volumes..." @$(COMPOSE_CMD) down -v infra-build-images: @echo "Building production service images..." @$(COMPOSE_PROD_CMD) build infra-up-prod: @echo "Starting production compose stack locally..." @$(COMPOSE_PROD_CMD) up -d # ============================================================================= # Backend # ============================================================================= backend-lint: @echo "Running Go linters..." @for module in $(BACKEND_MODULES); do \ echo "-> $$module"; \ (cd backend/$$module && golangci-lint run ./...); \ done backend-test: @echo "Running Go tests..." @for module in $(BACKEND_MODULES); do \ echo "-> $$module"; \ (cd backend/$$module && go test -v -race -cover ./...); \ done backend-build: @echo "Building all services..." @for module in $(BACKEND_MODULES); do \ echo "-> $$module"; \ (cd backend/$$module && go build ./...); \ done # ============================================================================= # Frontend # ============================================================================= frontend-dev: @echo "Starting frontend development server..." @cd frontend && yarn dev frontend-lint: @echo "Running frontend linters..." @cd frontend && yarn lint && yarn format:check frontend-test: @echo "Running frontend tests..." @cd frontend && yarn test frontend-e2e: @echo "Running frontend Playwright critical-flow tests..." @cd frontend && yarn test:e2e frontend-build: @echo "Building frontend..." @cd frontend && yarn build # ============================================================================= # Database Utilities # ============================================================================= db-up: @$(COMPOSE_CMD) up -d postgres redis db-down: @$(COMPOSE_CMD) stop postgres redis db-logs: @$(COMPOSE_CMD) logs -f postgres db-shell: @docker exec -it knowfoolery-postgres psql -U $(POSTGRES_USER) -d $(POSTGRES_DB) redis-shell: @docker exec -it knowfoolery-redis redis-cli # ============================================================================= # Task Workflows # ============================================================================= task-security-scan: @task ci:security-scan task-deploy-dev: @task cd:deploy-dev task-deploy-prod: @task cd:deploy-prod task-k6-smoke: @task ci:k6-smoke task-k6-load: @task ci:k6-load # ============================================================================= # Combined Commands # ============================================================================= lint: backend-lint frontend-lint @echo "All linters passed!" test: backend-test frontend-test @echo "All tests passed!" build: backend-build frontend-build @echo "Build complete!"