diff --git a/Makefile b/Makefile index 0d75eb5..0697599 100644 --- a/Makefile +++ b/Makefile @@ -2,32 +2,61 @@ -include .env export -.PHONY: docker-up docker-down migrate-up migrate-down \ - run-backend run-frontend test test-coverage lint seed +.PHONY: install build \ + docker-up docker-down migrate-up migrate-down \ + run-backend run-frontend \ + dev-backend dev-frontend \ + test test-coverage lint seed + +## ── Setup ──────────────────────────────────────────────────────────────────── + +# Install all dependencies: Go CLI tools, Go modules, Node packages. +install: + go install github.com/pressly/goose/v3/cmd/goose@latest + go install github.com/air-verse/air@latest + cd backend && go mod download + cd frontend && npm ci + +# Build the Go binary and the Next.js production bundle. +build: + mkdir -p backend/bin + cd backend && go build -o bin/api ./cmd/api + cd frontend && npm run build + +## ── Infrastructure ─────────────────────────────────────────────────────────── -## Infrastructure docker-up: docker compose up -d postgres redis docker-down: docker compose down -## Migrations (requires goose: go install github.com/pressly/goose/v3/cmd/goose@latest) migrate-up: PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" up migrate-down: PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" down -## Development servers +## ── Production servers (require `make build` first) ───────────────────────── + +# Run the compiled Go binary. run-backend: + cd backend && ./bin/api + +# Run the Next.js production server on port 3001. +run-frontend: + cd frontend && env -u PORT npx next start -p 3001 + +## ── Development servers (hot reload) ──────────────────────────────────────── + +dev-backend: cd backend && PATH=$$HOME/go/bin:$$PATH air -# PORT is exported from .env (backend uses it); unset it so Next.js defaults to 3000. -run-frontend: +dev-frontend: cd frontend && env -u PORT npm run dev -## Testing +## ── Testing ────────────────────────────────────────────────────────────────── + test: cd backend && go test ./... && cd ../frontend && npm test -- --passWithNoTests @@ -35,11 +64,13 @@ test-coverage: cd backend && go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out -o coverage.html @echo "Coverage report: backend/coverage.html" -## Dev seed (local DB only — never run against production) +## ── Dev seed (local DB only — never run against production) ────────────────── + seed: cd backend && go run ./cmd/seed -## Linting +## ── Linting ────────────────────────────────────────────────────────────────── + lint: cd backend && golangci-lint run ./... cd frontend && npx tsc --noEmit && npx eslint .