.PHONY: help sync-contracts up down db-init api-dev api-test web-dev

DOC_ROOT := doc/Kids_AI_Posture_Platform_BUSINESS_DELIVERY_V1.0

help:
	@echo "happy-up monorepo"
	@echo ""
	@echo "  make sync-contracts  从 doc/ 同步 openapi + database.sql"
	@echo "  make up              启动 MySQL + Redis + MinIO"
	@echo "  make down            停止容器"
	@echo "  make db-init         初始化数据库（需 up 后执行）"
	@echo "  make api-dev         启动 FastAPI 开发服务"
	@echo "  make api-test        运行 API 单元测试"
	@echo "  make web-dev         启动 Vue H5 前端（需 npm install）"

sync-contracts:
	cp $(DOC_ROOT)/07_API接口/openapi.yaml contracts/openapi.yaml
	cp $(DOC_ROOT)/06_数据库设计/database.sql contracts/database.sql

up:
	docker compose up -d

down:
	docker compose down

db-init:
	docker compose exec -T mysql mysql -uhappy_up -phappy_up happy_up < contracts/database.sql || true

api-dev:
	cd apps/api && python3.11 -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

api-seed:
	cd apps/api && python3.11 -m app.db.seed

api-migrate-stamp:
	cd apps/api && python3.11 -m alembic stamp head

api-test:
	cd apps/api && python3.11 -m pytest -q

api-worker:
	cd apps/api && python3.11 -m app.worker

web-dev:
	cd apps/web && npm run dev
