PY := .venv/bin/python
BACKEND := backend
FRONTEND := frontend

.PHONY: install dev-backend dev-frontend test test-backend test-frontend lint fmt build up down deploy

install:
	python3 -m venv .venv
	$(PY) -m pip install -r $(BACKEND)/requirements-dev.txt
	cd $(FRONTEND) && npm install

dev-backend:
	cd $(BACKEND) && ../$(PY) -m uvicorn app.main:app --reload --port 8000

dev-frontend:
	cd $(FRONTEND) && npm run dev

test: test-backend test-frontend

test-backend:
	cd $(BACKEND) && ../$(PY) -m pytest

test-frontend:
	cd $(FRONTEND) && npm test

lint:
	cd $(BACKEND) && ../.venv/bin/ruff check .
	cd $(BACKEND) && ../.venv/bin/ruff format --check .

fmt:
	cd $(BACKEND) && ../.venv/bin/ruff format .
	cd $(BACKEND) && ../.venv/bin/ruff check --fix .

build:
	cd $(FRONTEND) && npm run build

up:
	docker compose -f docker-compose.local.yml up --build

down:
	docker compose -f docker-compose.local.yml down

# Production stack (requires the shared docker_default network + Traefik).
deploy:
	docker compose up -d --build
