VENV_DIR := .venv
ACTIVATE := source $(VENV_DIR)/bin/activate
PYTHON := $(VENV_DIR)/bin/python
REQUIREMENTS := requirements.txt

.PHONY: all
all: help

.PHONY: install
install:
	@echo "Setting up virtual environment..."
	@test -d $(VENV_DIR) || python3 -m venv $(VENV_DIR)
	@echo "Installing dependencies..."
	$(PYTHON) -m pip install --upgrade pip
	$(PYTHON) -m pip install -r $(REQUIREMENTS)

.PHONY: run
serve:
	@echo "Running the server..."
	$(PYTHON) -m uvicorn main:app

.PHONY: test
test:
	@echo "Running tests..."
	$(PYTHON) -m pytest

.PHONY: clean
clean:
	@echo "Cleaning up..."
	rm -rf $(VENV_DIR)
	find . -type d -name "__pycache__" -exec rm -rf {} +

.PHONY: help
help:
	@echo "Makefile targets:"
	@echo "  install   - Create virtual environment and install dependencies"
	@echo "  serve   - Run server"
	@echo "  test    - Run tests"
	@echo "  clean   - Remove virtual environment and cache files"
