# Portfolio Platform — developer commands.
.PHONY: help install test lint type arch cov run worker scheduler compose docker clean

help:
	@echo "install   Install the package with dev extras"
	@echo "test      Run the full test suite"
	@echo "cov       Run tests with the 95% coverage gate"
	@echo "lint      Ruff lint"
	@echo "type      mypy strict type-check"
	@echo "arch      import-linter architecture contracts"
	@echo "run       Serve the API (uvicorn)"
	@echo "worker    Run the event-consumer worker"
	@echo "scheduler Run one monitoring sweep"
	@echo "compose   Bring up the full stack (postgres/redis/kafka + api/worker/scheduler)"
	@echo "docker    Build the production image"

install:
	pip install -e ".[agents,messaging,observability,dev]"

test:
	PYTHONPATH=src pytest

cov:
	PYTHONPATH=src pytest --cov=portfolio_platform --cov-report=term-missing --cov-fail-under=95

lint:
	ruff check src tests

type:
	mypy src/portfolio_platform

arch:
	lint-imports

run:
	PYTHONPATH=src uvicorn portfolio_platform.apps.api.main:create_app --factory --host 0.0.0.0 --port 8000

worker:
	PYTHONPATH=src python -m portfolio_platform.apps.worker.run

scheduler:
	PYTHONPATH=src python -m portfolio_platform.apps.scheduler.run

compose:
	docker compose up --build

docker:
	docker build -t portfolio-platform:latest .

clean:
	find . -type d -name __pycache__ -prune -exec rm -rf {} + ; rm -rf .pytest_cache .coverage
