A community based topic aggregation platform built on atproto
1.PHONY: help dev-up dev-down dev-logs dev-status dev-reset dev-db-up dev-db-down dev-db-reset test clean 2 3# Default target - show help 4.DEFAULT_GOAL := help 5 6# Colors for output 7CYAN := \033[36m 8RESET := \033[0m 9GREEN := \033[32m 10YELLOW := \033[33m 11 12##@ General 13 14help: ## Show this help message 15 @echo "" 16 @echo "$(CYAN)Coves Development Commands$(RESET)" 17 @echo "" 18 @awk 'BEGIN {FS = ":.*##"; printf "Usage: make $(CYAN)<target>$(RESET)\n"} \ 19 /^[a-zA-Z_-]+:.*?##/ { printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2 } \ 20 /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST) 21 @echo "" 22 23##@ Local Development (All-in-One) 24 25dev-up: ## Start PDS + PostgreSQL for local development 26 @echo "$(GREEN)Starting Coves development stack...$(RESET)" 27 @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres pds 28 @echo "" 29 @echo "$(GREEN)✓ Development stack started!$(RESET)" 30 @echo "" 31 @echo "Services available at:" 32 @echo " - PostgreSQL: localhost:5433" 33 @echo " - PDS (XRPC): http://localhost:3001" 34 @echo " - PDS Firehose (WS): ws://localhost:3001/xrpc/com.atproto.sync.subscribeRepos" 35 @echo " - AppView (API): http://localhost:8081 (when uncommented)" 36 @echo "" 37 @echo "Run 'make dev-logs' to view logs" 38 39dev-down: ## Stop all development services 40 @echo "$(YELLOW)Stopping Coves development stack...$(RESET)" 41 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down 42 @echo "$(GREEN)✓ Development stack stopped$(RESET)" 43 44dev-logs: ## Tail logs from all development services 45 @docker-compose -f docker-compose.dev.yml --env-file .env.dev logs -f 46 47dev-status: ## Show status of all development containers 48 @echo "$(CYAN)Development Stack Status:$(RESET)" 49 @docker-compose -f docker-compose.dev.yml --env-file .env.dev ps 50 51dev-reset: ## Nuclear option - stop everything and remove all volumes 52 @echo "$(YELLOW)⚠️ WARNING: This will delete ALL data (PostgreSQL + PDS)!$(RESET)" 53 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 54 @echo "$(YELLOW)Stopping and removing containers and volumes...$(RESET)" 55 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down -v 56 @echo "$(GREEN)✓ Reset complete - all data removed$(RESET)" 57 @echo "Run 'make dev-up' to start fresh" 58 59##@ Database Management 60 61db-shell: ## Open PostgreSQL shell for development database 62 @echo "$(CYAN)Connecting to development database...$(RESET)" 63 @docker exec -it coves-dev-postgres psql -U dev_user -d coves_dev 64 65db-migrate: ## Run database migrations 66 @echo "$(GREEN)Running database migrations...$(RESET)" 67 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" up 68 @echo "$(GREEN)✓ Migrations complete$(RESET)" 69 70db-migrate-down: ## Rollback last migration 71 @echo "$(YELLOW)Rolling back last migration...$(RESET)" 72 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" down 73 @echo "$(GREEN)✓ Rollback complete$(RESET)" 74 75db-reset: ## Reset database (delete all data and re-run migrations) 76 @echo "$(YELLOW)⚠️ WARNING: This will delete all database data!$(RESET)" 77 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 78 @echo "$(YELLOW)Resetting database...$(RESET)" 79 @docker-compose -f docker-compose.dev.yml --env-file .env.dev rm -sf postgres 80 @docker volume rm coves-dev-postgres-data || true 81 @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres 82 @echo "Waiting for PostgreSQL to be ready..." 83 @sleep 3 84 @make db-migrate 85 @echo "$(GREEN)✓ Database reset complete$(RESET)" 86 87##@ Testing 88 89test: ## Run all tests with test database 90 @echo "$(GREEN)Starting test database...$(RESET)" 91 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test 92 @echo "Waiting for test database to be ready..." 93 @sleep 3 94 @echo "$(GREEN)Running migrations on test database...$(RESET)" 95 @goose -dir internal/db/migrations postgres "postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" up || true 96 @echo "$(GREEN)Running tests...$(RESET)" 97 @TEST_DATABASE_URL="postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" go test ./... -v 98 @echo "$(GREEN)✓ Tests complete$(RESET)" 99 100test-db-reset: ## Reset test database 101 @echo "$(GREEN)Resetting test database...$(RESET)" 102 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test rm -sf postgres-test 103 @docker volume rm coves-test-postgres-data || true 104 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test 105 @echo "Waiting for PostgreSQL to be ready..." 106 @sleep 3 107 @goose -dir internal/db/migrations postgres "postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" up || true 108 @echo "$(GREEN)✓ Test database reset$(RESET)" 109 110test-db-stop: ## Stop test database 111 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test stop postgres-test 112 @echo "$(GREEN)✓ Test database stopped$(RESET)" 113 114##@ Build & Run 115 116build: ## Build the Coves server 117 @echo "$(GREEN)Building Coves server...$(RESET)" 118 @go build -o server ./cmd/server 119 @echo "$(GREEN)✓ Build complete: ./server$(RESET)" 120 121run: ## Run the Coves server (requires database running) 122 @echo "$(GREEN)Starting Coves server...$(RESET)" 123 @go run ./cmd/server 124 125##@ Cleanup 126 127clean: ## Clean build artifacts and temporary files 128 @echo "$(YELLOW)Cleaning build artifacts...$(RESET)" 129 @rm -f server main validate-lexicon 130 @go clean 131 @echo "$(GREEN)✓ Clean complete$(RESET)" 132 133clean-all: clean ## Clean everything including Docker volumes (DESTRUCTIVE) 134 @echo "$(YELLOW)⚠️ WARNING: This will remove ALL Docker volumes!$(RESET)" 135 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 136 @make dev-reset 137 @echo "$(GREEN)✓ All clean$(RESET)" 138 139##@ Workflows (Common Tasks) 140 141fresh-start: ## Complete fresh start (reset everything, start clean) 142 @echo "$(CYAN)Starting fresh development environment...$(RESET)" 143 @make dev-reset || true 144 @sleep 2 145 @make dev-up 146 @sleep 3 147 @make db-migrate 148 @echo "" 149 @echo "$(GREEN)✓ Fresh environment ready!$(RESET)" 150 @make dev-status 151 152quick-restart: ## Quick restart of development stack (keeps data) 153 @make dev-down 154 @make dev-up 155 156##@ Utilities 157 158validate-lexicon: ## Validate all Lexicon schemas 159 @echo "$(GREEN)Validating Lexicon schemas...$(RESET)" 160 @./validate-lexicon 161 @echo "$(GREEN)✓ Lexicon validation complete$(RESET)" 162 163##@ Documentation 164 165docs: ## Open project documentation 166 @echo "$(CYAN)Project Documentation:$(RESET)" 167 @echo " - Setup Guide: docs/LOCAL_DEVELOPMENT.md" 168 @echo " - Project Structure: PROJECT_STRUCTURE.md" 169 @echo " - Build Guide: CLAUDE.md" 170 @echo " - atProto Guide: ATPROTO_GUIDE.md" 171 @echo " - PRD: PRD.md"