PROJECT_ROOT := $(shell pwd) .PHONY: install run stop stop-dev stop-prod infra api frontend celery clean dev prod check-env build-dev build-prod open-browser test ENV_DIRS := . flowsint-api flowsint-core flowsint-app open-browser: @echo "โณ Waiting for frontend to be ready..." @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done' @echo "๐ŸŒ Opening browser..." @open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "โœ… Flowsint ready at http://localhost:5173" dev: @echo "๐Ÿš€ Starting Flowsint in DEVELOPMENT mode..." $(MAKE) check-env docker compose -f docker-compose.dev.yml up --build -d $(MAKE) open-browser docker compose -f docker-compose.dev.yml logs -f prod: @echo "๐Ÿš€ Starting Flowsint in PRODUCTION mode..." $(MAKE) check-env docker compose -f docker-compose.prod.yml up --build -d $(MAKE) open-browser build-dev: @echo "๐Ÿ”จ Building development images..." docker compose -f docker-compose.dev.yml build build-prod: @echo "๐Ÿ”จ Building production images..." docker compose -f docker-compose.prod.yml build check-env: @echo "๐Ÿ”Ž Checking .env files..." @for dir in $(ENV_DIRS); do \ env_file="$$dir/.env"; \ env_example="$(PROJECT_ROOT)/.env.example"; \ if [ -f "$$env_file" ]; then \ echo "โœ… Using existing .env in $$dir"; \ else \ echo "โš ๏ธ .env missing in $$dir, copying from .env.example"; \ cp "$$env_example" "$$env_file"; \ fi; \ done test: @echo "๐Ÿ”Ž Running tests..." cd $(PROJECT_ROOT)/flowsint-types && poetry run pytest cd $(PROJECT_ROOT)/flowsint-core && poetry run pytest cd $(PROJECT_ROOT)/flowsint-enrichers && poetry run pytest install: @echo "๐Ÿš€ Installing Flowsint project modules..." @if ! command -v poetry >/dev/null 2>&1; then \ echo "โš ๏ธ Poetry is not installed. Please install it:"; \ echo "pipx install poetry"; \ echo "or"; \ echo "curl -sSL https://install.python-poetry.org | python3 -"; \ exit 1; \ fi poetry config virtualenvs.in-project true --local docker compose up -d postgres redis neo4j poetry install cd $(PROJECT_ROOT)/flowsint-core && poetry install cd $(PROJECT_ROOT)/flowsint-enrichers && poetry install cd $(PROJECT_ROOT)/flowsint-api && poetry install && poetry run alembic upgrade head @echo "โœ… All modules installed successfully!" infra: docker compose up -d api: cd $(PROJECT_ROOT)/flowsint-api && poetry run uvicorn app.main:app --host 0.0.0.0 --port 5001 --reload frontend: @echo "๐Ÿš€ Starting frontend and opening browser..." @docker compose up -d flowsint-app @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done; open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "โœ… Frontend ready at http://localhost:5173"' frontend_prod: cd $(PROJECT_ROOT)/flowsint-app && npm run build celery: cd $(PROJECT_ROOT)/flowsint-core && poetry run celery -A flowsint_core.core.celery worker --loglevel=info --pool=solo run: @echo "๐Ÿš€ Starting all services..." docker compose up -d @echo "โณ Waiting for frontend to be ready..." @bash -c 'until curl -s http://localhost:5173 > /dev/null 2>&1; do sleep 1; done' @echo "๐ŸŒ Opening browser..." @open http://localhost:5173 2>/dev/null || xdg-open http://localhost:5173 2>/dev/null || echo "โœ… All services ready! Flowsint at http://localhost:5173" $(MAKE) -j2 api celery stop: @echo "๐Ÿ›‘ Stopping all services..." -docker compose -f docker-compose.dev.yml down -docker compose -f docker-compose.prod.yml down -docker compose down stop-dev: @echo "๐Ÿ›‘ Stopping development services..." docker compose -f docker-compose.dev.yml down stop-prod: @echo "๐Ÿ›‘ Stopping production services..." docker compose -f docker-compose.prod.yml down clean: @echo "โš ๏ธ WARNING: This will remove ALL Docker containers, images, volumes, and virtual environments." @echo "โš ๏ธ ALL DATA in databases and volumes will be permanently deleted!" @echo "" @read -p "Are you sure you want to continue? [y/N]: " confirm; \ if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \ echo "โŒ Cleanup cancelled."; \ exit 1; \ fi @echo "๐Ÿงน Removing containers, images, volumes and venvs..." -docker compose -f docker-compose.dev.yml down -v --rmi all --remove-orphans -docker compose -f docker-compose.prod.yml down -v --rmi all --remove-orphans -docker compose down -v --rmi all --remove-orphans rm -rf $(PROJECT_ROOT)/flowsint-app/node_modules rm -rf $(PROJECT_ROOT)/flowsint-core/.venv rm -rf $(PROJECT_ROOT)/flowsint-enrichers/.venv rm -rf $(PROJECT_ROOT)/flowsint-api/.venv @echo "โœ… Cleanup complete!"