A community based topic aggregation platform built on atproto
1.PHONY: help dev-up dev-down dev-logs dev-status dev-reset test e2e-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# Load test database configuration from .env.dev 13include .env.dev 14export 15 16##@ General 17 18help: ## Show this help message 19 @echo "" 20 @echo "$(CYAN)Coves Development Commands$(RESET)" 21 @echo "" 22 @awk 'BEGIN {FS = ":.*##"; printf "Usage: make $(CYAN)<target>$(RESET)\n"} \ 23 /^[a-zA-Z_-]+:.*?##/ { printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2 } \ 24 /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST) 25 @echo "" 26 27##@ Local Development (All-in-One) 28 29dev-up: ## Start PDS + PostgreSQL + Jetstream + PLC Directory for local development 30 @echo "$(GREEN)Starting Coves development stack...$(RESET)" 31 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile jetstream --profile plc up -d postgres postgres-plc plc-directory pds jetstream 32 @echo "" 33 @echo "$(GREEN)✓ Development stack started!$(RESET)" 34 @echo "" 35 @echo "Services available at:" 36 @echo " - PostgreSQL: localhost:5435" 37 @echo " - PDS (XRPC): http://localhost:3001" 38 @echo " - PDS Firehose: ws://localhost:3001/xrpc/com.atproto.sync.subscribeRepos" 39 @echo " - Jetstream: ws://localhost:6008/subscribe $(CYAN)(Read-Forward)$(RESET)" 40 @echo " - Jetstream Metrics: http://localhost:6009/metrics" 41 @echo " - PLC Directory: http://localhost:3002 $(CYAN)(Local DID registry)$(RESET)" 42 @echo "" 43 @echo "$(CYAN)Next steps:$(RESET)" 44 @echo " 1. Run: make run (starts AppView)" 45 @echo " 2. AppView will auto-index users from Jetstream" 46 @echo "" 47 @echo "$(CYAN)Note:$(RESET) Using local PLC directory - DIDs registered locally (won't pollute plc.directory)" 48 @echo "Run 'make dev-logs' to view logs" 49 50dev-down: ## Stop all development services 51 @echo "$(YELLOW)Stopping Coves development stack...$(RESET)" 52 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down 53 @echo "$(GREEN)✓ Development stack stopped$(RESET)" 54 55dev-logs: ## Tail logs from all development services 56 @docker-compose -f docker-compose.dev.yml --env-file .env.dev logs -f 57 58dev-status: ## Show status of all development containers 59 @echo "$(CYAN)Development Stack Status:$(RESET)" 60 @docker-compose -f docker-compose.dev.yml --env-file .env.dev ps 61 62dev-reset: ## Nuclear option - stop everything and remove all volumes 63 @echo "$(YELLOW)⚠️ WARNING: This will delete ALL data (PostgreSQL + PDS)!$(RESET)" 64 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 65 @echo "$(YELLOW)Stopping and removing containers and volumes...$(RESET)" 66 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down -v 67 @echo "$(GREEN)✓ Reset complete - all data removed$(RESET)" 68 @echo "Run 'make dev-up' to start fresh" 69 70##@ Database Management 71 72db-shell: ## Open PostgreSQL shell for development database 73 @echo "$(CYAN)Connecting to development database...$(RESET)" 74 @docker exec -it coves-dev-postgres psql -U dev_user -d coves_dev 75 76db-migrate: ## Run database migrations 77 @echo "$(GREEN)Running database migrations...$(RESET)" 78 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" up 79 @echo "$(GREEN)✓ Migrations complete$(RESET)" 80 81db-migrate-down: ## Rollback last migration 82 @echo "$(YELLOW)Rolling back last migration...$(RESET)" 83 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" down 84 @echo "$(GREEN)✓ Rollback complete$(RESET)" 85 86db-reset: ## Reset database (delete all data and re-run migrations) 87 @echo "$(YELLOW)⚠️ WARNING: This will delete all database data!$(RESET)" 88 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 89 @echo "$(YELLOW)Resetting database...$(RESET)" 90 @docker-compose -f docker-compose.dev.yml --env-file .env.dev rm -sf postgres 91 @docker volume rm coves-dev-postgres-data || true 92 @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres 93 @echo "Waiting for PostgreSQL to be ready..." 94 @sleep 3 95 @make db-migrate 96 @echo "$(GREEN)✓ Database reset complete$(RESET)" 97 98##@ Testing 99 100test: ## Run fast unit/integration tests (skips slow E2E tests) 101 @echo "$(GREEN)Starting test database...$(RESET)" 102 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test 103 @echo "Waiting for test database to be ready..." 104 @sleep 3 105 @echo "$(GREEN)Running migrations on test database...$(RESET)" 106 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true 107 @echo "$(GREEN)Running fast tests (use 'make e2e-test' for E2E tests)...$(RESET)" 108 @go test ./cmd/... ./internal/... ./tests/... -short -v 109 @echo "$(GREEN)✓ Tests complete$(RESET)" 110 111e2e-test: ## Run automated E2E tests (requires: make dev-up + make run in another terminal) 112 @echo "$(CYAN)========================================$(RESET)" 113 @echo "$(CYAN) E2E Test: Full User Signup Flow $(RESET)" 114 @echo "$(CYAN)========================================$(RESET)" 115 @echo "" 116 @echo "$(CYAN)Prerequisites:$(RESET)" 117 @echo " 1. Run 'make dev-up' (starts PDS + Jetstream)" 118 @echo " 2. Run 'make run' in another terminal (AppView must be running)" 119 @echo "" 120 @echo "$(GREEN)Running E2E tests...$(RESET)" 121 @go test ./tests/e2e -run TestE2E_UserSignup -v 122 @echo "" 123 @echo "$(GREEN)✓ E2E tests complete!$(RESET)" 124 125e2e-vote-test: ## Run vote E2E tests (requires: make dev-up) 126 @echo "$(CYAN)========================================$(RESET)" 127 @echo "$(CYAN) E2E Test: Vote System $(RESET)" 128 @echo "$(CYAN)========================================$(RESET)" 129 @echo "" 130 @echo "$(CYAN)Prerequisites:$(RESET)" 131 @echo " 1. Run 'make dev-up' (starts PDS + Jetstream + PostgreSQL)" 132 @echo " 2. Test database will be used (port 5434)" 133 @echo "" 134 @echo "$(GREEN)Running vote E2E tests...$(RESET)" 135 @echo "" 136 @echo "$(CYAN)Running simulated E2E test (fast)...$(RESET)" 137 @go test ./tests/integration -run TestVote_E2E_WithJetstream -v 138 @echo "" 139 @echo "$(CYAN)Running live PDS E2E test (requires PDS + Jetstream)...$(RESET)" 140 @go test ./tests/integration -run TestVote_E2E_LivePDS -v || echo "$(YELLOW)Live PDS test skipped (run 'make dev-up' first)$(RESET)" 141 @echo "" 142 @echo "$(GREEN)✓ Vote E2E tests complete!$(RESET)" 143 144test-db-reset: ## Reset test database 145 @echo "$(GREEN)Resetting test database...$(RESET)" 146 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test rm -sf postgres-test 147 @docker volume rm coves-test-postgres-data || true 148 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test 149 @echo "Waiting for PostgreSQL to be ready..." 150 @sleep 3 151 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true 152 @echo "$(GREEN)✓ Test database reset$(RESET)" 153 154test-db-stop: ## Stop test database 155 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test stop postgres-test 156 @echo "$(GREEN)✓ Test database stopped$(RESET)" 157 158##@ Code Quality 159 160fmt: ## Format all Go code with gofmt 161 @echo "$(GREEN)Formatting Go code...$(RESET)" 162 @gofmt -w ./cmd ./internal ./tests 163 @echo "$(GREEN)✓ Formatting complete$(RESET)" 164 165fmt-check: ## Check if Go code is properly formatted 166 @echo "$(GREEN)Checking code formatting...$(RESET)" 167 @unformatted=$$(gofmt -l ./cmd ./internal ./tests); \ 168 if [ -n "$$unformatted" ]; then \ 169 echo "$(RED)✗ The following files are not formatted:$(RESET)"; \ 170 echo "$$unformatted"; \ 171 echo "$(YELLOW)Run 'make fmt' to fix$(RESET)"; \ 172 exit 1; \ 173 fi 174 @echo "$(GREEN)✓ All files are properly formatted$(RESET)" 175 176lint: fmt-check ## Run golangci-lint on the codebase (includes format check) 177 @echo "$(GREEN)Running linter...$(RESET)" 178 @golangci-lint run ./cmd/... ./internal/... ./tests/... 179 @echo "$(GREEN)✓ Linting complete$(RESET)" 180 181lint-fix: ## Run golangci-lint and auto-fix issues 182 @echo "$(GREEN)Running linter with auto-fix...$(RESET)" 183 @golangci-lint run --fix ./cmd/... ./internal/... ./tests/... 184 @gofmt -w ./cmd ./internal ./tests 185 @echo "$(GREEN)✓ Linting complete$(RESET)" 186 187##@ Build & Run 188 189build: ## Build the Coves server 190 @echo "$(GREEN)Building Coves server...$(RESET)" 191 @go build -o server ./cmd/server 192 @echo "$(GREEN)✓ Build complete: ./server$(RESET)" 193 194run: ## Run the Coves server with dev environment (requires database running) 195 @./scripts/dev-run.sh 196 197##@ Cleanup 198 199clean: ## Clean build artifacts and temporary files 200 @echo "$(YELLOW)Cleaning build artifacts...$(RESET)" 201 @rm -f server main validate-lexicon 202 @go clean 203 @echo "$(GREEN)✓ Clean complete$(RESET)" 204 205clean-all: clean ## Clean everything including Docker volumes (DESTRUCTIVE) 206 @echo "$(YELLOW)⚠️ WARNING: This will remove ALL Docker volumes!$(RESET)" 207 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 208 @make dev-reset 209 @echo "$(GREEN)✓ All clean$(RESET)" 210 211##@ Workflows (Common Tasks) 212 213fresh-start: ## Complete fresh start (reset everything, start clean) 214 @echo "$(CYAN)Starting fresh development environment...$(RESET)" 215 @make dev-reset || true 216 @sleep 2 217 @make dev-up 218 @sleep 3 219 @make db-migrate 220 @echo "" 221 @echo "$(GREEN)✓ Fresh environment ready!$(RESET)" 222 @make dev-status 223 224quick-restart: ## Quick restart of development stack (keeps data) 225 @make dev-down 226 @make dev-up 227 228##@ Mobile Testing 229 230mobile-setup: ## Setup Android port forwarding for USB-connected devices (recommended) 231 @echo "$(CYAN)Setting up Android mobile testing environment...$(RESET)" 232 @./scripts/setup-mobile-ports.sh 233 234mobile-reset: ## Remove all Android port forwarding 235 @echo "$(YELLOW)Removing Android port forwarding...$(RESET)" 236 @adb reverse --remove-all || echo "$(YELLOW)No device connected$(RESET)" 237 @echo "$(GREEN)✓ Port forwarding removed$(RESET)" 238 239ngrok-up: ## Start ngrok tunnels (for iOS or WiFi testing - requires paid plan for 3 tunnels) 240 @echo "$(GREEN)Starting ngrok tunnels for mobile testing...$(RESET)" 241 @./scripts/start-ngrok.sh 242 243ngrok-down: ## Stop all ngrok tunnels 244 @./scripts/stop-ngrok.sh 245 246##@ Utilities 247 248validate-lexicon: ## Validate all Lexicon schemas 249 @echo "$(GREEN)Validating Lexicon schemas...$(RESET)" 250 @./validate-lexicon 251 @echo "$(GREEN)✓ Lexicon validation complete$(RESET)" 252 253##@ Documentation 254 255docs: ## Open project documentation 256 @echo "$(CYAN)Project Documentation:$(RESET)" 257 @echo " - Setup Guide: docs/LOCAL_DEVELOPMENT.md" 258 @echo " - Project Structure: PROJECT_STRUCTURE.md" 259 @echo " - Build Guide: CLAUDE.md" 260 @echo " - atProto Guide: ATPROTO_GUIDE.md" 261 @echo " - PRD: PRD.md"