apicentric 0.7.0

Toolkit for building, recording, and sharing mock APIs
Documentation
#   ___  ______ _____ _____ _____ _   _ _____ ______ _____ _____ 
#  / _ \ | ___ \_   _/  __ \  ___| \ | |_   _|| ___ \_   _/  __ \
# / /_\ \| |_/ / | | | /  \/ |__ |  \| | | |  | |_/ / | | | /  \/
# |  _  ||  __/  | | | |   |  __|| . ` | | |  |    /  | | | |    
# | | | || |    _| |_| \__/\ |___| |\  | | |  | |\ \ _| |_| \__/\
# \_| |_/\_|    \___/ \____\____/\_| \_/ \_/  \_| \_|\___/ \____/
#                                                                
# High-performance API Simulator & Digital Twin Framework

.PHONY: all help build build-backend build-frontend run dev test lint format clean docker-build package doctor demo install

# Variables
BINARY=target/debug/apicentric
RELEASE_BINARY=target/release/apicentric
SERVICES_DIR=examples
DB_PATH=data/apicentric.db

# Default target
all: build

help:
	@printf '                                                                \n'
	@printf '  \033[1;36m___  ______ _____ _____ _____ _   _ _____ ______ _____ _____ \033[0m\n'
	@printf '  \033[1;36m/ _ \\ | ___ \\_   _/  __ \\  ___| \\ | |_   _|| ___ \\_   _/  __ \\\\ \033[0m\n'
	@printf '  \033[1;36m/ /_\\ \\| |_/ / | | | /  \\/ |__ |  \\| | | |  | |_/ / | | | /  \\/\033[0m\n'
	@printf '  \033[1;36m|  _  ||  __/  | | | |   |  __|| . ` | | |  |    /  | | | |    \033[0m\n'
	@printf '  \033[1;36m| | | || |    _| |_| \\__/\\ |___| |\\  | | |  | |\\ \\ _| |_| \\__/\033[0m\n'
	@printf '  \033[1;36m\\_| |_/\\_|    \\___/ \\____\\____/\\_| \\_/ \\_/  \\_| \\_|\\___/ \\____/\033[0m\n'
	@printf '                                                                \n'
	@printf '  \033[1;33mโšก Core Commands:\033[0m\n'
	@printf '    \033[1;32mmake build\033[0m          - ๐Ÿ—๏ธ  Build complete project (Backend & Frontend)\n'
	@printf '    \033[1;32mmake run\033[0m            - ๐Ÿƒ Start simulator with examples\n'
	@printf '    \033[1;32mmake dev\033[0m            - ๐Ÿš€ Hot-reload development environment\n'
	@printf '    \033[1;32mmake wizard\033[0m         - ๐Ÿง™ Interactive project management wizard\n'
	@printf '  \n'
	@printf '  \033[1;33m๐ŸŽฎ Interfaces:\033[0m\n'
	@printf '    \033[1;32mmake tui\033[0m            - ๐Ÿ–ฅ๏ธ  Launch Terminal User Interface\n'
	@printf '    \033[1;32mmake gui\033[0m            - ๐ŸŽจ Launch Desktop GUI Administration\n'
	@printf '  \n'
	@printf '  \033[1;33m๐Ÿ”ฌ Simulation & Testing:\033[0m\n'
	@printf '    \033[1;32mmake twin\033[0m           - ๐Ÿค– Run IoT Digital Twin simulator\n'
	@printf '    \033[1;32mmake contract\033[0m       - ๐Ÿ“ Execute contract-driven API tests\n'
	@printf '    \033[1;32mmake cloud\033[0m          - โ˜๏ธ  Start server in cloud-ready mode\n'
	@printf '  \n'
	@printf '  \033[1;33m๐Ÿ› ๏ธ  Development & QA:\033[0m\n'
	@printf '    \033[1;32mmake test\033[0m           - ๐Ÿงช Run full test suite\n'
	@printf '    \033[1;32mmake lint\033[0m           - ๐Ÿงน Static analysis & linting\n'
	@printf '    \033[1;32mmake format\033[0m         - ๐ŸŽจ Auto-format all source code\n'
	@printf '    \033[1;32mmake doctor\033[0m         - ๐Ÿฉบ Run project diagnostics\n'
	@printf '  \n'
	@printf '  \033[1;33m๐Ÿ“ฆ Distribution:\033[0m\n'
	@printf '    \033[1;32mmake package\033[0m        - ๐Ÿ“ฆ Create production tarball\n'
	@printf '    \033[1;32mmake docker-build\033[0m   - ๐Ÿณ Build release Docker image\n'
	@printf '    \033[1;32mmake demo\033[0m           - ๐ŸŽฌ Run visual demonstration\n'
	@printf '  \n'
	@printf '  \033[1;33m๐Ÿงน Utility:\033[0m\n'
	@printf '    \033[1;32mmake clean\033[0m          - ๐Ÿ—‘๏ธ  Deep clean build artifacts\n'
	@printf '    \033[1;32mmake install\033[0m        - ๐Ÿ“ฅ Bootstrap dependencies\n'
	@printf '  \n'
install:
	@echo "๐Ÿ“ฆ Installing dependencies..."
	cargo fetch
	cd webui && npm install

build: build-backend build-frontend

build-backend:
	@echo "๐Ÿฆ€ Building backend (debug)..."
	cargo build --features full

build-frontend:
	@echo "๐Ÿ“ฆ Building frontend..."
	cd webui && npm run build

run: build-backend
	@echo "๐Ÿƒ Starting simulator..."
	mkdir -p data
	$(BINARY) --db-path $(DB_PATH) simulator start --services-dir $(SERVICES_DIR)

dev:
	@echo "๐Ÿš€ Starting development environment..."
	# This runs both in parallel, might need adjustment for local workflow
	(cargo watch -x run & cd webui && npm run dev)

test:
	@echo "๐Ÿงช Running tests..."
	cargo test
	# Run scripts/test_mcp.sh if it exists
	@[ -f scripts/test_mcp.sh ] && ./scripts/test_mcp.sh || echo "No MCP tests found"

lint:
	@echo "๐Ÿงน Linting..."
	cargo clippy -- -D warnings
	cd webui && npm run lint

format:
	@echo "๐ŸŽจ Formatting..."
	cargo fmt
	cd webui && npm run format

clean:
	@echo "๐Ÿงน Cleaning up..."
	cargo clean
	rm -rf webui/.next
	rm -rf logs/*
	rm -rf demo_output

doctor: build-backend
	@$(BINARY) doctor

demo: build-backend
	@echo "๐ŸŽฌ Running demo..."
	./scripts/demo_all.sh

package:
	@echo "๐Ÿ“ฆ Packaging for production..."
	./scripts/build-production.sh

tui: build-backend
	@echo "๐Ÿ–ฅ๏ธ  Launching TUI..."
	$(BINARY) tui

gui: build-backend
	@echo "๐ŸŽจ Launching GUI..."
	$(BINARY) gui

twin: build-backend
	@echo "๐Ÿค– Starting IoT Digital Twin..."
	$(BINARY) twin run --device examples/iot/smarthome/thermostat-nest.yaml

contract: build-backend
	@echo "๐Ÿ“ Running contract tests..."
	$(BINARY) simulator test --path examples/iot/smarthome/thermostat-nest.yaml --url http://localhost:9005

cloud: build-backend
	@echo "โ˜๏ธ  Starting cloud mode..."
	$(BINARY) cloud --port 8080

wizard:
	@chmod +x scripts/wizard.sh
	@./scripts/wizard.sh

docker-build:
	@echo "๐Ÿณ Building Docker images..."
	docker build -t apicentric:latest .