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 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 up -d postgres pds jetstream
32 @echo ""
33 @echo "$(GREEN)✓ Development stack started!$(RESET)"
34 @echo ""
35 @echo "Services available at:"
36 @echo " - PostgreSQL: localhost:5433"
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 ""
42 @echo "$(CYAN)Next steps:$(RESET)"
43 @echo " 1. Run: make run (starts AppView)"
44 @echo " 2. AppView will auto-index users from Jetstream"
45 @echo ""
46 @echo "Run 'make dev-logs' to view logs"
47
48dev-down: ## Stop all development services
49 @echo "$(YELLOW)Stopping Coves development stack...$(RESET)"
50 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down
51 @echo "$(GREEN)✓ Development stack stopped$(RESET)"
52
53dev-logs: ## Tail logs from all development services
54 @docker-compose -f docker-compose.dev.yml --env-file .env.dev logs -f
55
56dev-status: ## Show status of all development containers
57 @echo "$(CYAN)Development Stack Status:$(RESET)"
58 @docker-compose -f docker-compose.dev.yml --env-file .env.dev ps
59
60dev-reset: ## Nuclear option - stop everything and remove all volumes
61 @echo "$(YELLOW)⚠️ WARNING: This will delete ALL data (PostgreSQL + PDS)!$(RESET)"
62 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
63 @echo "$(YELLOW)Stopping and removing containers and volumes...$(RESET)"
64 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down -v
65 @echo "$(GREEN)✓ Reset complete - all data removed$(RESET)"
66 @echo "Run 'make dev-up' to start fresh"
67
68##@ Database Management
69
70db-shell: ## Open PostgreSQL shell for development database
71 @echo "$(CYAN)Connecting to development database...$(RESET)"
72 @docker exec -it coves-dev-postgres psql -U dev_user -d coves_dev
73
74db-migrate: ## Run database migrations
75 @echo "$(GREEN)Running database migrations...$(RESET)"
76 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" up
77 @echo "$(GREEN)✓ Migrations complete$(RESET)"
78
79db-migrate-down: ## Rollback last migration
80 @echo "$(YELLOW)Rolling back last migration...$(RESET)"
81 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" down
82 @echo "$(GREEN)✓ Rollback complete$(RESET)"
83
84db-reset: ## Reset database (delete all data and re-run migrations)
85 @echo "$(YELLOW)⚠️ WARNING: This will delete all database data!$(RESET)"
86 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
87 @echo "$(YELLOW)Resetting database...$(RESET)"
88 @docker-compose -f docker-compose.dev.yml --env-file .env.dev rm -sf postgres
89 @docker volume rm coves-dev-postgres-data || true
90 @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres
91 @echo "Waiting for PostgreSQL to be ready..."
92 @sleep 3
93 @make db-migrate
94 @echo "$(GREEN)✓ Database reset complete$(RESET)"
95
96##@ Testing
97
98test: ## Run fast unit/integration tests (skips slow E2E tests)
99 @echo "$(GREEN)Starting test database...$(RESET)"
100 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test
101 @echo "Waiting for test database to be ready..."
102 @sleep 3
103 @echo "$(GREEN)Running migrations on test database...$(RESET)"
104 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true
105 @echo "$(GREEN)Running fast tests (use 'make e2e-test' for E2E tests)...$(RESET)"
106 @go test ./... -short -v
107 @echo "$(GREEN)✓ Tests complete$(RESET)"
108
109e2e-test: ## Run automated E2E tests (requires: make dev-up + make run in another terminal)
110 @echo "$(CYAN)========================================$(RESET)"
111 @echo "$(CYAN) E2E Test: Full User Signup Flow $(RESET)"
112 @echo "$(CYAN)========================================$(RESET)"
113 @echo ""
114 @echo "$(CYAN)Prerequisites:$(RESET)"
115 @echo " 1. Run 'make dev-up' (if not already running)"
116 @echo " 2. Run 'make run' in another terminal (AppView must be running)"
117 @echo ""
118 @echo "$(GREEN)Running E2E tests...$(RESET)"
119 @go test ./tests/e2e -run TestE2E_UserSignup -v
120 @echo ""
121 @echo "$(GREEN)✓ E2E tests complete!$(RESET)"
122
123test-db-reset: ## Reset test database
124 @echo "$(GREEN)Resetting test database...$(RESET)"
125 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test rm -sf postgres-test
126 @docker volume rm coves-test-postgres-data || true
127 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test
128 @echo "Waiting for PostgreSQL to be ready..."
129 @sleep 3
130 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true
131 @echo "$(GREEN)✓ Test database reset$(RESET)"
132
133test-db-stop: ## Stop test database
134 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test stop postgres-test
135 @echo "$(GREEN)✓ Test database stopped$(RESET)"
136
137##@ Build & Run
138
139build: ## Build the Coves server
140 @echo "$(GREEN)Building Coves server...$(RESET)"
141 @go build -o server ./cmd/server
142 @echo "$(GREEN)✓ Build complete: ./server$(RESET)"
143
144run: ## Run the Coves server (requires database running)
145 @echo "$(GREEN)Starting Coves server...$(RESET)"
146 @go run ./cmd/server
147
148##@ Cleanup
149
150clean: ## Clean build artifacts and temporary files
151 @echo "$(YELLOW)Cleaning build artifacts...$(RESET)"
152 @rm -f server main validate-lexicon
153 @go clean
154 @echo "$(GREEN)✓ Clean complete$(RESET)"
155
156clean-all: clean ## Clean everything including Docker volumes (DESTRUCTIVE)
157 @echo "$(YELLOW)⚠️ WARNING: This will remove ALL Docker volumes!$(RESET)"
158 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
159 @make dev-reset
160 @echo "$(GREEN)✓ All clean$(RESET)"
161
162##@ Workflows (Common Tasks)
163
164fresh-start: ## Complete fresh start (reset everything, start clean)
165 @echo "$(CYAN)Starting fresh development environment...$(RESET)"
166 @make dev-reset || true
167 @sleep 2
168 @make dev-up
169 @sleep 3
170 @make db-migrate
171 @echo ""
172 @echo "$(GREEN)✓ Fresh environment ready!$(RESET)"
173 @make dev-status
174
175quick-restart: ## Quick restart of development stack (keeps data)
176 @make dev-down
177 @make dev-up
178
179##@ Utilities
180
181validate-lexicon: ## Validate all Lexicon schemas
182 @echo "$(GREEN)Validating Lexicon schemas...$(RESET)"
183 @./validate-lexicon
184 @echo "$(GREEN)✓ Lexicon validation complete$(RESET)"
185
186##@ Documentation
187
188docs: ## Open project documentation
189 @echo "$(CYAN)Project Documentation:$(RESET)"
190 @echo " - Setup Guide: docs/LOCAL_DEVELOPMENT.md"
191 @echo " - Project Structure: PROJECT_STRUCTURE.md"
192 @echo " - Build Guide: CLAUDE.md"
193 @echo " - atProto Guide: ATPROTO_GUIDE.md"
194 @echo " - PRD: PRD.md"