.PHONY: help install dev prod test lint format clean docker-build docker-up docker-down

help:
	@echo "LLM Monitor - Makefile Commands"
	@echo "================================"
	@echo "make install       - Installa le dipendenze"
	@echo "make dev          - Avvia in modalità sviluppo"
	@echo "make prod         - Avvia in modalità produzione"
	@echo "make test         - Esegui i test"
	@echo "make lint         - Linting e type checking"
	@echo "make format       - Formatta il codice"
	@echo "make clean        - Pulisce cache e file temporanei"
	@echo "make docker-build - Build dell'immagine Docker"
	@echo "make docker-up    - Avvia i container con Docker Compose"
	@echo "make docker-down  - Ferma i container con Docker Compose"

install:
	python3 -m venv venv
	. venv/bin/activate && pip install -r requirements.txt -r requirements-dev.txt

dev:
	. venv/bin/activate && uvicorn main:app --reload --host 0.0.0.0 --port 8000

prod:
	. venv/bin/activate && uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4

test:
	. venv/bin/activate && pytest tests/ -v --cov=app

lint:
	. venv/bin/activate && flake8 app/ tests/ main.py && mypy app/

format:
	. venv/bin/activate && black app/ tests/ main.py && isort app/ tests/ main.py

clean:
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete
	rm -rf .pytest_cache .mypy_cache .coverage htmlcov dist build *.egg-info

docker-build:
	docker build -t llm-monitor:latest .

docker-up:
	docker compose up -d

docker-down:
	docker compose down

docker-logs:
	docker compose logs -f llm-monitor

docker-shell:
	docker compose exec llm-monitor /bin/bash
