# STUPA PDF API Makefile # Convenient commands for development and deployment .PHONY: help help: ## Show this help message @echo 'Usage: make [target]' @echo '' @echo 'Targets:' @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) .PHONY: install install: ## Initial setup - create .env and install dependencies @echo "Setting up STUPA PDF API..." @chmod +x scripts/*.sh @./scripts/create-env.sh @echo "Setup complete! Run 'make start' to begin." .PHONY: start start: ## Start all services @docker compose up -d @echo "Services starting..." @echo "Frontend: http://localhost:3000" @echo "API: http://localhost:8000" @echo "API Docs: http://localhost:8000/docs" @echo "Database UI: http://localhost:8080" .PHONY: stop stop: ## Stop all services @docker compose down .PHONY: restart restart: ## Restart all services @docker compose restart .PHONY: status status: ## Show service status @docker compose ps .PHONY: logs logs: ## Show logs for all services @docker compose logs -f .PHONY: logs-api logs-api: ## Show API logs @docker compose logs -f api .PHONY: logs-frontend logs-frontend: ## Show frontend logs @docker compose logs -f frontend .PHONY: logs-db logs-db: ## Show database logs @docker compose logs -f db .PHONY: build build: ## Build all services @docker compose build .PHONY: build-api build-api: ## Build API service @docker compose build api .PHONY: build-frontend build-frontend: ## Build frontend service @docker compose build frontend .PHONY: shell-api shell-api: ## Open shell in API container @docker compose exec api /bin/bash .PHONY: shell-frontend shell-frontend: ## Open shell in frontend container @docker compose exec frontend /bin/sh .PHONY: shell-db shell-db: ## Open MySQL client @docker compose exec db mysql -u root -p$${MYSQL_ROOT_PASSWORD} $${MYSQL_DB} .PHONY: migrate migrate: ## Run database migrations @echo "Running database migrations..." @./scripts/dev.sh migrate .PHONY: test test: ## Run all tests @echo "Running tests..." @./scripts/dev.sh test .PHONY: lint lint: ## Run linters @echo "Running linters..." @./scripts/dev.sh lint .PHONY: format format: ## Format code @echo "Formatting code..." @./scripts/dev.sh format .PHONY: clean clean: ## Clean up temporary files and caches @echo "Cleaning up..." @find backend -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true @find backend -type f -name "*.pyc" -delete 2>/dev/null || true @docker system prune -f .PHONY: reset reset: ## Reset everything (WARNING: deletes all data!) @echo "WARNING: This will delete all data!" @read -p "Are you sure? Type 'yes' to continue: " confirm && \ if [ "$$confirm" = "yes" ]; then \ docker compose down -v; \ docker compose down --rmi local; \ echo "Reset complete!"; \ else \ echo "Aborted."; \ fi .PHONY: backup backup: ## Create database backup @mkdir -p backups @docker compose exec -T db mysqldump -u root -p$${MYSQL_ROOT_PASSWORD} $${MYSQL_DB} > backups/backup-$$(date +%Y%m%d-%H%M%S).sql @echo "Backup created in backups/" .PHONY: dev dev: ## Start in development mode with hot reload @docker compose -f docker-compose.yml -f docker-compose.watch.yml up .PHONY: prod prod: ## Start in production mode @docker compose up -d .PHONY: update update: ## Update dependencies @echo "Updating backend dependencies..." @cd backend && pip-compile --upgrade requirements.in -o requirements.txt @echo "Updating frontend dependencies..." @cd frontend && npm update .PHONY: docs docs: ## Open documentation in browser @echo "Opening documentation..." @python -m webbrowser "file://$$(pwd)/docs/README.md" || open docs/README.md || xdg-open docs/README.md .PHONY: api-docs api-docs: ## Open API documentation in browser @echo "Opening API documentation..." @python -m webbrowser "http://localhost:8000/docs" || open "http://localhost:8000/docs" || xdg-open "http://localhost:8000/docs" .PHONY: check-env check-env: ## Check if .env file exists @if [ ! -f .env ]; then \ echo "ERROR: .env file not found!"; \ echo "Run 'make install' to create one."; \ exit 1; \ else \ echo ".env file exists ✓"; \ fi .PHONY: validate validate: check-env ## Validate configuration @echo "Validating configuration..." @docker compose config > /dev/null @echo "Configuration is valid ✓" .PHONY: ps ps: ## Show running containers @docker ps --filter "label=com.docker.compose.project=stupa-pdf-api" .PHONY: stats stats: ## Show container resource usage @docker stats --no-stream $$(docker compose ps -q) .PHONY: version version: ## Show version information @echo "STUPA PDF API Version Information:" @echo "Backend: Python 3.11 with FastAPI" @echo "Frontend: React 18 with TypeScript" @echo "Database: MySQL 8.0" @grep -m1 version frontend/package.json || echo "Frontend version not found" @docker --version @docker compose version