# LetzShop API Makefile (Windows Compatible) .PHONY: install install-dev install-docs install-all dev test test-coverage lint format check docker-build docker-up docker-down clean help # ============================================================================= # INSTALLATION & SETUP # ============================================================================= install: pip install -r requirements.txt install-dev: install pip install -r requirements-dev.txt install-test: pip install -r tests/requirements-test.txt install-docs: pip install -r requirements-docs.txt install-all: install install-dev install-test install-docs setup: install-all migrate-up @echo Development environment setup complete! @echo Run 'make dev' to start development server # ============================================================================= # DEVELOPMENT SERVERS # ============================================================================= dev: uvicorn main:app --reload --host 0.0.0.0 --port 8000 dev-with-docs: @echo Starting API and documentation servers... @start /B uvicorn main:app --reload --host 0.0.0.0 --port 8000 @timeout /t 3 >nul @mkdocs serve --dev-addr=0.0.0.0:8001 dev-full: dev-with-docs @echo Development environment ready! @echo API server: http://localhost:8000 @echo API docs: http://localhost:8000/docs @echo Documentation: http://localhost:8001 # ============================================================================= # DATABASE MIGRATIONS # ============================================================================= migrate-create: @if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create message="your_description") else (alembic revision --autogenerate -m "$(message)") migrate-create-manual: @if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create-manual message="your_description") else (alembic revision -m "$(message)") migrate-up: @echo Running database migrations... alembic upgrade head @echo Migrations completed successfully migrate-down: @echo Rolling back last migration... alembic downgrade -1 @echo Rollback completed migrate-status: @echo Current migration status: alembic current @echo. @echo Migration history: alembic history --verbose backup-db: @echo Creating database backup... @python scripts/backup_database.py # ============================================================================= # TESTING # ============================================================================= test: pytest tests/ -v test-unit: pytest tests/ -v -m unit test-integration: pytest tests/ -v -m integration test-coverage: pytest tests/ --cov=app --cov=models --cov=utils --cov=middleware --cov-report=html --cov-report=term-missing test-fast: pytest tests/ -v -m "not slow" test-auth: pytest tests/test_auth.py -v test-products: pytest tests/test_products.py -v test-stock: pytest tests/test_stock.py -v # ============================================================================= # CODE QUALITY # ============================================================================= format: @echo Running black... black . --exclude venv @echo Running isort... isort . --skip venv lint: @echo Running linting... flake8 . --max-line-length=120 --extend-ignore=E203,W503,I201,I100 --exclude=venv,__pycache__,.git mypy . --ignore-missing-imports --exclude venv # Combined format and lint check: format lint # Combined test with coverage and linting ci: format lint test-coverage # Quality assurance workflow qa: format lint test-coverage docs-check @echo Quality assurance checks completed! # ============================================================================= # DOCUMENTATION # ============================================================================= docs-serve: @echo Starting documentation server... mkdocs serve --dev-addr=0.0.0.0:8001 docs-build: @echo Building documentation... mkdocs build --clean --strict docs-deploy: @echo Deploying documentation... mkdocs gh-deploy --clean docs-clean: @if exist site rmdir /s /q site @echo Documentation build files cleaned! docs-check: @echo Checking documentation for issues... mkdocs build --strict --verbose # ============================================================================= # DOCKER # ============================================================================= docker-build: docker-compose build docker-up: docker-compose up -d docker-down: docker-compose down docker-restart: docker-down docker-up # ============================================================================= # DEPLOYMENT # ============================================================================= deploy-staging: migrate-up docker-compose -f docker-compose.staging.yml up -d deploy-prod: migrate-up docker-compose -f docker-compose.prod.yml up -d # ============================================================================= # UTILITIES # ============================================================================= clean: @if exist htmlcov rmdir /s /q htmlcov @if exist .pytest_cache rmdir /s /q .pytest_cache @if exist .coverage del .coverage @if exist .mypy_cache rmdir /s /q .mypy_cache @for /d /r . %%d in (__pycache__) do @if exist "%%d" rmdir /s /q "%%d" @del /s /q *.pyc 2>nul || echo No .pyc files found verify-setup: @echo Running setup verification... @python scripts/verify_setup.py # ============================================================================= # HELP # ============================================================================= help: @echo LetzShop API Development Commands @echo. @echo === SETUP === @echo install - Install production dependencies @echo install-test - Install test dependencies only @echo install-dev - Install development dependencies @echo install-all - Install all dependencies @echo setup - Complete development setup @echo. @echo === DEVELOPMENT === @echo dev - Start API development server @echo dev-full - Start API and documentation servers @echo. @echo === DATABASE === @echo migrate-create message="msg" - Create new migration @echo migrate-up - Apply pending migrations @echo migrate-down - Rollback last migration @echo migrate-status - Show migration status @echo backup-db - Backup database @echo. @echo === TESTING === @echo test - Run all tests @echo test-coverage - Run tests with coverage @echo test-fast - Run fast tests only @echo. @echo === CODE QUALITY === @echo format - Format code (black + isort) @echo lint - Run linting (flake8 + mypy) @echo check - Format + lint @echo ci - Full CI pipeline @echo qa - Quality assurance (format, lint, test, docs check) @echo. @echo === DOCUMENTATION === @echo docs-serve - Start documentation server @echo docs-build - Build documentation @echo. @echo === DOCKER === @echo docker-build - Build Docker containers @echo docker-up - Start Docker containers @echo docker-down - Stop Docker containers @echo docker-restart - Restart Docker containers @echo. @echo === DEPLOYMENT === @echo deploy-staging - Deploy to staging environment @echo deploy-prod - Deploy to production environment @echo. @echo === UTILITIES === @echo clean - Clean build artifacts @echo verify-setup - Verify project setup @echo. @echo === DAILY WORKFLOW === @echo make dev # Start development @echo make migrate-create message="feature" # Create migration @echo make migrate-up # Apply migration @echo make test # Run tests help-db: @echo === DATABASE COMMANDS === @echo migrate-create message="description" - Create auto-generated migration @echo migrate-create-manual message="desc" - Create empty migration template @echo migrate-up - Apply all pending migrations @echo migrate-down - Rollback last migration @echo migrate-status - Show current status and history @echo backup-db - Create database backup @echo. @echo TYPICAL WORKFLOW: @echo 1. Edit your SQLAlchemy models @echo 2. make migrate-create message="add_new_feature" @echo 3. Review the generated migration file @echo 4. make migrate-up