.PHONY: help init build up down restart logs clean dev-backend dev-frontend dev stop-dev install-backend install-frontend test # Default target .DEFAULT_GOAL := help # Docker compose file location DOCKER_COMPOSE := docker-compose -f app/deploy/docker-compose.yml # Colors for output RED := \033[0;31m GREEN := \033[0;32m YELLOW := \033[1;33m BLUE := \033[0;34m NC := \033[0m # No Color help: ## Show this help message @echo "$(BLUE)╔════════════════════════════════════════════════╗$(NC)" @echo "$(BLUE)║ Prompt Oase - Available Commands ║$(NC)" @echo "$(BLUE)╚════════════════════════════════════════════════╝$(NC)" @echo "" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}' @echo "" # ============================================================================= # Docker Commands # ============================================================================= init: ## Initialize the project (build and start containers) @echo "$(BLUE)╔════════════════════════════════════════════════╗$(NC)" @echo "$(BLUE)║ Initializing Prompt Oase... ║$(NC)" @echo "$(BLUE)╚════════════════════════════════════════════════╝$(NC)" @$(MAKE) build @$(MAKE) up @echo "" @echo "$(GREEN)✓ Project initialized successfully!$(NC)" @echo "" @echo "$(YELLOW)Frontend: http://localhost:3000$(NC)" @echo "$(YELLOW)Backend: http://localhost:8000$(NC)" @echo "$(YELLOW)API Docs: http://localhost:8000/docs$(NC)" @echo "" build: ## Build Docker images @echo "$(BLUE)Building Docker images...$(NC)" @cd app/deploy && docker-compose build @echo "$(GREEN)✓ Images built successfully!$(NC)" up: ## Start all containers @echo "$(BLUE)Starting containers...$(NC)" @cd app/deploy && docker-compose up -d @echo "$(GREEN)✓ Containers started!$(NC)" down: ## Stop all containers @echo "$(BLUE)Stopping containers...$(NC)" @cd app/deploy && docker-compose down @echo "$(GREEN)✓ Containers stopped!$(NC)" restart: ## Restart all containers @echo "$(BLUE)Restarting containers...$(NC)" @$(MAKE) down @$(MAKE) up @echo "$(GREEN)✓ Containers restarted!$(NC)" logs: ## Show logs from all containers @cd app/deploy && docker-compose logs -f logs-backend: ## Show backend logs @cd app/deploy && docker-compose logs -f backend logs-frontend: ## Show frontend logs @cd app/deploy && docker-compose logs -f frontend clean: ## Stop containers and remove volumes @echo "$(RED)Cleaning up containers and volumes...$(NC)" @cd app/deploy && docker-compose down -v @echo "$(GREEN)✓ Cleanup complete!$(NC)" clean-all: clean ## Remove containers, volumes, and images @echo "$(RED)Removing all Docker images...$(NC)" @cd app/deploy && docker-compose down -v --rmi all @echo "$(GREEN)✓ Complete cleanup done!$(NC)" rebuild: down build up ## Rebuild and restart containers # ============================================================================= # Development Commands (Local without Docker) # ============================================================================= install-backend: ## Install backend dependencies @echo "$(BLUE)Installing backend dependencies...$(NC)" @cd app/backend && python -m venv .venv && .venv/bin/pip install -r requirements.txt @echo "$(GREEN)✓ Backend dependencies installed!$(NC)" install-frontend: ## Install frontend dependencies @echo "$(BLUE)Installing frontend dependencies...$(NC)" @cd app/frontend && npm install @echo "$(GREEN)✓ Frontend dependencies installed!$(NC)" install: install-backend install-frontend ## Install all dependencies dev-backend: ## Run backend in development mode (local) @echo "$(BLUE)Starting backend development server...$(NC)" @cd app/backend && .venv/bin/uvicorn main:app --reload --host 0.0.0.0 --port 8000 dev-frontend: ## Run frontend in development mode (local) @echo "$(BLUE)Starting frontend development server...$(NC)" @cd app/frontend && npm run dev dev: ## Run both backend and frontend in development mode (requires tmux) @echo "$(BLUE)Starting development servers...$(NC)" @if ! command -v tmux &> /dev/null; then \ echo "$(RED)Error: tmux is not installed. Install it or run 'make dev-backend' and 'make dev-frontend' in separate terminals.$(NC)"; \ exit 1; \ fi @tmux new-session -d -s prompt-oase 'cd app/backend && .venv/bin/uvicorn main:app --reload --host 0.0.0.0 --port 8000' @tmux split-window -h -t prompt-oase 'cd app/frontend && npm run dev' @tmux attach -t prompt-oase stop-dev: ## Stop development tmux session @tmux kill-session -t prompt-oase 2>/dev/null || echo "$(YELLOW)No dev session running$(NC)" # ============================================================================= # Database Commands # ============================================================================= db-reset: ## Reset the database (delete and recreate) @echo "$(RED)Resetting database...$(NC)" @rm -f data/prompt-tool.db @echo "$(GREEN)✓ Database reset! It will be recreated on next startup.$(NC)" db-backup: ## Backup the database @echo "$(BLUE)Backing up database...$(NC)" @mkdir -p backups @if [ -f "data/prompt-tool.db" ]; then \ cp data/prompt-tool.db backups/prompt-tool-$(shell date +%Y%m%d_%H%M%S).db; \ echo "$(GREEN)✓ Database backed up!$(NC)"; \ else \ echo "$(YELLOW)⚠ Database file not found$(NC)"; \ fi db-shell: ## Open SQLite shell for database @if [ -f "data/prompt-tool.db" ]; then \ sqlite3 data/prompt-tool.db; \ else \ echo "$(RED)Database file not found$(NC)"; \ fi # ============================================================================= # Container Management # ============================================================================= shell-backend: ## Open a shell in the backend container @cd app/deploy && docker-compose exec backend /bin/bash shell-frontend: ## Open a shell in the frontend container @cd app/deploy && docker-compose exec frontend /bin/sh ps: ## Show running containers @cd app/deploy && docker-compose ps stats: ## Show container resource usage @docker stats prompt-tool-backend prompt-tool-frontend # ============================================================================= # Build & Test Commands # ============================================================================= test-backend: ## Run backend tests @echo "$(BLUE)Running backend tests...$(NC)" @cd app/backend && .venv/bin/pytest test-frontend: ## Run frontend tests @echo "$(BLUE)Running frontend tests...$(NC)" @cd app/frontend && npm test test: test-backend test-frontend ## Run all tests lint-backend: ## Lint backend code @echo "$(BLUE)Linting backend code...$(NC)" @cd app/backend && .venv/bin/flake8 . || true lint-frontend: ## Lint frontend code @echo "$(BLUE)Linting frontend code...$(NC)" @cd app/frontend && npm run lint || true lint: lint-backend lint-frontend ## Lint all code format-backend: ## Format backend code @echo "$(BLUE)Formatting backend code...$(NC)" @cd app/backend && .venv/bin/black . || true format-frontend: ## Format frontend code @echo "$(BLUE)Formatting frontend code...$(NC)" @cd app/frontend && npm run format || true format: format-backend format-frontend ## Format all code # ============================================================================= # Info & Status Commands # ============================================================================= info: ## Show project information @echo "$(BLUE)╔════════════════════════════════════════════════╗$(NC)" @echo "$(BLUE)║ Prompt Oase - Project Info ║$(NC)" @echo "$(BLUE)╚════════════════════════════════════════════════╝$(NC)" @echo "" @echo "$(YELLOW)URLs:$(NC)" @echo " Frontend: http://localhost:3000" @echo " Backend: http://localhost:8000" @echo " API Docs: http://localhost:8000/docs" @echo " Redoc: http://localhost:8000/redoc" @echo "" @echo "$(BLUE)Directory Structure:$(NC)" @echo " app/backend/ - FastAPI backend" @echo " app/frontend/ - Vue.js frontend" @echo " app/deploy/ - Docker configuration" @echo " data/ - Database and exports" @echo "" @echo "$(BLUE)Quick Start:$(NC)" @echo " make init - Initialize and start project" @echo " make dev - Run in development mode (no Docker)" @echo " make logs - View container logs" @echo " make help - Show all commands" @echo "" status: ## Show current project status @echo "$(BLUE)╔════════════════════════════════════════════════╗$(NC)" @echo "$(BLUE)║ Project Status ║$(NC)" @echo "$(BLUE)╚════════════════════════════════════════════════╝$(NC)" @echo "" @echo "$(YELLOW)Docker Containers:$(NC)" @cd app/deploy && docker-compose ps 2>/dev/null || echo " $(YELLOW)⚠ No containers running$(NC)" @echo "" @echo "$(YELLOW)Database:$(NC)" @if [ -f "data/prompt-tool.db" ]; then \ SIZE=$$(du -h data/prompt-tool.db | cut -f1); \ echo " $(GREEN)✓ Database exists ($$SIZE)$(NC)"; \ else \ echo " $(YELLOW)⚠ Database not found$(NC)"; \ fi @echo "" @echo "$(YELLOW)Data Directories:$(NC)" @if [ -d "data" ]; then echo " $(GREEN)✓ data/$(NC)"; else echo " $(RED)✗ data/$(NC)"; fi @if [ -d "data/exports" ]; then echo " $(GREEN)✓ data/exports/$(NC)"; else echo " $(YELLOW)⚠ data/exports/$(NC)"; fi @if [ -d "data/templates" ]; then echo " $(GREEN)✓ data/templates/$(NC)"; else echo " $(YELLOW)⚠ data/templates/$(NC)"; fi @if [ -d "data/variables" ]; then echo " $(GREEN)✓ data/variables/$(NC)"; else echo " $(YELLOW)⚠ data/variables/$(NC)"; fi @echo "" # ============================================================================= # Utility Commands # ============================================================================= setup-dirs: ## Create necessary directories @echo "$(BLUE)Creating project directories...$(NC)" @mkdir -p data/exports data/templates data/variables backups @echo "$(GREEN)✓ Directories created!$(NC)" clean-exports: ## Clean old export files @echo "$(BLUE)Cleaning export files...$(NC)" @find data/exports -type f -mtime +30 -delete 2>/dev/null || true @echo "$(GREEN)✓ Old exports cleaned!$(NC)" update: ## Update dependencies @echo "$(BLUE)Updating dependencies...$(NC)" @cd app/backend && .venv/bin/pip install --upgrade -r requirements.txt @cd app/frontend && npm update @echo "$(GREEN)✓ Dependencies updated!$(NC)" version: ## Show version information @echo "$(BLUE)Version Information:$(NC)" @echo " Python: $$(cd app/backend && .venv/bin/python --version 2>&1)" @echo " Node: $$(node --version 2>/dev/null || echo 'Not installed')" @echo " Docker: $$(docker --version 2>/dev/null || echo 'Not installed')" # ============================================================================= # Shortcuts # ============================================================================= start: up ## Alias for 'up' stop: down ## Alias for 'down' r: restart ## Alias for 'restart' l: logs ## Alias for 'logs' s: status ## Alias for 'status' i: info ## Alias for 'info'