.PHONY: help install install-dev install-prod clean test test-cov lint format check-types run run-dev run-prod docker-build docker-run

help: ## Show this help message
	@echo "AI Feedback FastAPI Service - Development Commands"
	@echo "=================================================="
	@echo ""
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install: ## Install production dependencies
	uv sync --no-dev

install-dev: ## Install development dependencies
	uv sync

install-prod: ## Install production dependencies only
	uv sync --no-dev

clean: ## Clean up generated files
	rm -rf .pytest_cache/
	rm -rf htmlcov/
	rm -rf .coverage
	rm -rf .mypy_cache/
	rm -rf dist/
	rm -rf build/
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete

test: ## Run tests
	uv run pytest

test-unit: ## Run unit tests only
	uv run pytest -m "not integration and not slow"

test-integration: ## Run integration tests only
	uv run pytest -m "integration"

test-fast: ## Run fast tests (exclude slow tests)
	uv run pytest -m "not slow"

test-cov: ## Run tests with coverage
	uv run pytest --cov=app --cov-report=html --cov-report=term-missing

test-watch: ## Run tests in watch mode
	uv run pytest-watch -- -v

lint: ## Run linting checks
	uv run ruff check app/ tests/ --fix
	uv run ruff format --check app/ tests/ 

format: ## Format code
	uv run ruff check --fix app/ tests/
	uv run ruff format app/ tests/

check-types: ## Run type checking
	uv run mypy app/

run: ## Run the application
	uv run uvicorn app.main:app --host 0.0.0.0 --port 9001

run-dev: ## Run the application in development mode
	uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 9001

run-prod: ## Run the application in production mode
	uv run gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:9001

docker-build: ## Build Docker image
	docker build -t ai-feedback-fastapi .

docker-run: ## Run Docker container
	docker compose up

setup: install-dev ## Setup development environment
	uv run pre-commit install

update: ## Update dependencies
	uv lock --upgrade
	uv sync

check: lint check-types test ## Run all checks
