# Makefile for Adano Project

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

# Default target
.PHONY: all
all: help

# Create virtual environment and install dependencies
.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)

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

# Run tests (assuming you have tests set up)
.PHONY: test
test:
	@echo "Running tests..."
	# Add your test command here, e.g., pytest
	pytest

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

# Help message
.PHONY: help
help:
	@echo "Makefile targets:"
	@echo "  install   - Create virtual environment and install dependencies"
	@echo "  run     - Run the FastAPI server"
	@echo "  test    - Run tests"
	@echo "  clean   - Remove virtual environment and cache files"
