-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
201 lines (156 loc) Β· 7.16 KB
/
Makefile
File metadata and controls
201 lines (156 loc) Β· 7.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
.PHONY: install install-backend install-frontend dev dev-backend dev-frontend test test-backend test-frontend lint lint-backend lint-frontend format format-backend format-frontend db-push db-types db-start db-stop clean
# =============================================================================
# Installation
# =============================================================================
install: install-backend install-frontend ## Install all dependencies
install-backend: ## Install backend dependencies
cd backend && uv sync
install-frontend: ## Install frontend dependencies
cd frontend && npm install
# =============================================================================
# Development
# =============================================================================
dev: ## Run both backend and frontend dev servers
@make -j2 dev-backend dev-frontend
dev-backend: ## Run backend dev server
cd backend && uv run uvicorn app.main:app --reload --port 8000
dev-frontend: ## Run frontend dev server
cd frontend && npm run dev
# =============================================================================
# Testing
# =============================================================================
test: test-backend test-frontend ## Run all tests
test-backend: ## Run backend tests
cd backend && uv run pytest
test-frontend: ## Run frontend tests
cd frontend && npm test
test-backend-cov: ## Run backend tests with coverage
cd backend && uv run pytest --cov=app --cov-report=html
# =============================================================================
# Linting
# =============================================================================
lint: lint-backend lint-frontend ## Run all linters
lint-backend: ## Run backend linters
cd backend && uv run ruff check .
cd backend && uv run mypy app
lint-frontend: ## Run frontend linter
cd frontend && npm run lint
# =============================================================================
# Formatting
# =============================================================================
format: format-backend format-frontend ## Format all code
format-backend: ## Format backend code
cd backend && uv run ruff format .
cd backend && uv run ruff check --fix .
format-frontend: ## Format frontend code
cd frontend && npm run format
# =============================================================================
# Database (Supabase)
# =============================================================================
db-start: ## Start local Supabase
supabase start
db-stop: ## Stop local Supabase
supabase stop
db-push: ## Push database migrations
supabase db push
db-reset: ## Reset database (destructive)
supabase db reset
db-types: ## Generate TypeScript types from schema
supabase gen types typescript --local > frontend/types/supabase.ts
db-migrate: ## Create a new migration
@read -p "Migration name: " name; \
supabase migration new $$name
# =============================================================================
# Docker
# =============================================================================
docker-build: ## Build Docker images
docker-compose build
docker-up: ## Start Docker containers
docker-compose up -d
docker-down: ## Stop Docker containers
docker-compose down
docker-logs: ## View Docker logs
docker-compose logs -f
# =============================================================================
# Restart Services
# =============================================================================
restart: ## Restart both backend and frontend servers
@echo "π Restarting all services..."
@echo ""
@echo "1οΈβ£ Stopping services..."
@echo " β’ Killing port 8000 (backend)..."
@lsof -ti:8000 | xargs kill -9 2>/dev/null || echo " β Port 8000 already free"
@echo " β’ Killing port 3000 (frontend)..."
@lsof -ti:3000 | xargs kill -9 2>/dev/null || echo " β Port 3000 already free"
@pkill -f "uvicorn app.main:app" 2>/dev/null || true
@pkill -f "next dev" 2>/dev/null || true
@sleep 2
@echo ""
@echo "2οΈβ£ Starting backend..."
@cd backend && uv run uvicorn app.main:app --reload --port 8000 > /dev/null 2>&1 &
@sleep 3
@echo " β
Backend started on http://localhost:8000"
@echo ""
@echo "3οΈβ£ Starting frontend..."
@cd frontend && npm run dev > /dev/null 2>&1 &
@sleep 3
@echo " β
Frontend started on http://localhost:3000"
@echo ""
@echo "β¨ All services restarted successfully!"
@echo " Backend: http://localhost:8000"
@echo " Frontend: http://localhost:3000"
@echo " API Docs: http://localhost:8000/docs"
restart-backend: ## Restart backend server only
@echo "π Restarting backend..."
@lsof -ti:8000 | xargs kill -9 2>/dev/null || echo "Port 8000 already free"
@pkill -f "uvicorn app.main:app" 2>/dev/null || true
@sleep 2
@cd backend && uv run uvicorn app.main:app --reload --port 8000 > /dev/null 2>&1 &
@sleep 3
@echo "β
Backend restarted on http://localhost:8000"
restart-frontend: ## Restart frontend server only
@echo "π Restarting frontend..."
@lsof -ti:3000 | xargs kill -9 2>/dev/null || echo "Port 3000 already free"
@pkill -f "next dev" 2>/dev/null || true
@sleep 2
@cd frontend && npm run dev > /dev/null 2>&1 &
@sleep 3
@echo "β
Frontend restarted on http://localhost:3000"
stop-backend: ## Stop backend server
@echo "Stopping backend..."
@lsof -ti:8000 | xargs kill -9 2>/dev/null || true
@pkill -f "uvicorn app.main:app" 2>/dev/null || true
@echo "β
Backend stopped"
stop-frontend: ## Stop frontend server
@echo "Stopping frontend..."
@lsof -ti:3000 | xargs kill -9 2>/dev/null || true
@pkill -f "next dev" 2>/dev/null || true
@echo "β
Frontend stopped"
stop: stop-backend stop-frontend ## Stop all services
status: ## Check status of all services
@echo "π Service Status:"
@echo ""
@echo "Backend (port 8000):"
@lsof -ti:8000 > /dev/null 2>&1 && echo " β
Running (PID: $$(lsof -ti:8000))" || echo " β Not running"
@echo ""
@echo "Frontend (port 3000):"
@lsof -ti:3000 > /dev/null 2>&1 && echo " β
Running (PID: $$(lsof -ti:3000))" || echo " β Not running"
@echo ""
@echo "URLs:"
@lsof -ti:8000 > /dev/null 2>&1 && echo " β’ Backend: http://localhost:8000" || true
@lsof -ti:8000 > /dev/null 2>&1 && echo " β’ API Docs: http://localhost:8000/docs" || true
@lsof -ti:3000 > /dev/null 2>&1 && echo " β’ Frontend: http://localhost:3000" || true
# =============================================================================
# Utilities
# =============================================================================
clean: ## Clean build artifacts
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".next" -exec rm -rf {} + 2>/dev/null || true
rm -rf backend/.venv 2>/dev/null || true
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help