docs: Update README and FINAL_STATUS for quick start setup and project readiness
Some checks failed
Security Scan / Dependency Vulnerability Scan (push) Failing after 2s
Security Scan / OWASP ZAP Scan (push) Failing after 4s

- Added quick start instructions in README.md for first-time setup, including commands for complete setup, verification, and service start.
- Revised FINAL_STATUS.md to reflect the project's infrastructure completion and readiness for execution, detailing scripts created and documentation status.
This commit is contained in:
defiQUG
2025-11-06 21:31:55 -08:00
parent 3dc8592b83
commit b118b2be9c
23 changed files with 3068 additions and 90 deletions

99
scripts/run-migrations.sh Normal file
View File

@@ -0,0 +1,99 @@
#!/bin/bash
# Run Database Migrations Script
echo -e "\n========================================"
echo -e " DATABASE MIGRATIONS"
echo -e "========================================\n"
# Check if we're in the right directory
if [ ! -d "orchestrator" ]; then
echo -e "\033[0;31m❌ Error: Must run from project root\033[0m"
echo -e " Current directory: $(pwd)"
exit 1
fi
# Check if .env exists
if [ ! -f "orchestrator/.env" ]; then
echo -e "\033[0;33m⚠ orchestrator/.env not found\033[0m"
echo -e " Creating from example..."
if [ -f "orchestrator/src/config/env.example" ]; then
cp orchestrator/src/config/env.example orchestrator/.env
echo -e " ✅ Created orchestrator/.env"
echo -e " \033[0;33m⚠ Please update DATABASE_URL in orchestrator/.env\033[0m"
else
echo -e " \033[0;31m❌ env.example not found\033[0m"
exit 1
fi
fi
# Check DATABASE_URL
if ! grep -q "DATABASE_URL=" orchestrator/.env 2>/dev/null; then
echo -e "\033[0;33m⚠ DATABASE_URL not set in orchestrator/.env\033[0m"
echo -e " Adding default DATABASE_URL..."
echo "" >> orchestrator/.env
echo "DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comboflow" >> orchestrator/.env
echo "RUN_MIGRATIONS=true" >> orchestrator/.env
echo -e " ✅ Added default DATABASE_URL"
fi
# Check if database is accessible
echo -e "\n🔍 Checking database connection..."
DATABASE_URL=$(grep "^DATABASE_URL=" orchestrator/.env | cut -d '=' -f2- | tr -d '"' | tr -d "'")
if [ -z "$DATABASE_URL" ]; then
echo -e "\033[0;31m❌ DATABASE_URL is empty\033[0m"
exit 1
fi
# Extract connection details for testing
if [[ $DATABASE_URL =~ postgresql://([^:]+):([^@]+)@([^:]+):([^/]+)/(.+) ]]; then
DB_USER="${BASH_REMATCH[1]}"
DB_PASS="${BASH_REMATCH[2]}"
DB_HOST="${BASH_REMATCH[3]}"
DB_PORT="${BASH_REMATCH[4]}"
DB_NAME="${BASH_REMATCH[5]}"
echo -e " Host: $DB_HOST"
echo -e " Port: $DB_PORT"
echo -e " Database: $DB_NAME"
# Test connection with psql if available
if command -v psql &> /dev/null; then
if PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT 1;" > /dev/null 2>&1; then
echo -e " \033[0;32m✅ Database connection successful\033[0m"
else
echo -e " \033[0;33m⚠ Could not connect to database\033[0m"
echo -e " Make sure PostgreSQL is running and accessible"
fi
else
echo -e " \033[0;33m⚠ psql not found, skipping connection test\033[0m"
fi
else
echo -e " \033[0;33m⚠ Could not parse DATABASE_URL\033[0m"
fi
# Run migrations
echo -e "\n🔄 Running database migrations..."
cd orchestrator || exit 1
if [ ! -d "node_modules" ]; then
echo -e "\033[0;33m⚠ node_modules not found. Installing dependencies...\033[0m"
npm install
fi
npm run migrate
if [ $? -eq 0 ]; then
echo -e "\n\033[0;32m✅ Migrations completed successfully\033[0m"
else
echo -e "\n\033[0;31m❌ Migrations failed\033[0m"
exit 1
fi
cd ..
echo -e "\n📝 Next steps:"
echo -e " 1. Verify health endpoint: http://localhost:8080/health"
echo -e " 2. Check database tables: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';"
echo ""

182
scripts/setup-complete.sh Normal file
View File

@@ -0,0 +1,182 @@
#!/bin/bash
# Complete Setup Script
# Sets up the entire development environment
echo -e "\n========================================"
echo -e " COMPLETE DEVELOPMENT SETUP"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
ERRORS=0
# Check prerequisites
echo -e "${CYAN}Checking prerequisites...${NC}\n"
# Check Node.js
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version)
echo -e "${GREEN}✅ Node.js: $NODE_VERSION${NC}"
else
echo -e "${RED}❌ Node.js not found${NC}"
echo -e " Install: curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt install -y nodejs"
((ERRORS++))
fi
# Check npm
if command -v npm &> /dev/null; then
NPM_VERSION=$(npm --version)
echo -e "${GREEN}✅ npm: $NPM_VERSION${NC}"
else
echo -e "${RED}❌ npm not found${NC}"
((ERRORS++))
fi
# Check Docker
if command -v docker &> /dev/null; then
DOCKER_VERSION=$(docker --version | cut -d' ' -f3 | tr -d ',')
echo -e "${GREEN}✅ Docker: $DOCKER_VERSION${NC}"
else
echo -e "${YELLOW}⚠️ Docker not found (optional for database)${NC}"
fi
# Check required tools
for tool in jq bc netcat-openbsd; do
if command -v $tool &> /dev/null 2>&1 || dpkg -l | grep -q "^ii.*$tool"; then
echo -e "${GREEN}$tool available${NC}"
else
echo -e "${YELLOW}⚠️ $tool not found (will install)${NC}"
fi
done
if [ $ERRORS -gt 0 ]; then
echo -e "\n${RED}❌ Prerequisites check failed. Please install missing tools.${NC}"
exit 1
fi
# Install missing tools
echo -e "\n${CYAN}Installing missing tools...${NC}"
sudo apt update -qq
sudo apt install -y jq bc netcat-openbsd postgresql-client > /dev/null 2>&1
# Setup environment files
echo -e "\n${CYAN}Setting up environment files...${NC}"
# Webapp .env.local
if [ ! -f "webapp/.env.local" ]; then
cat > webapp/.env.local << EOF
NEXT_PUBLIC_ORCH_URL=http://localhost:8080
NEXTAUTH_SECRET=dev-secret-change-in-production-min-32-chars-$(date +%s)
EOF
echo -e "${GREEN}✅ Created webapp/.env.local${NC}"
else
echo -e "${GREEN}✅ webapp/.env.local exists${NC}"
fi
# Orchestrator .env
if [ ! -f "orchestrator/.env" ]; then
if [ -f "orchestrator/src/config/env.example" ]; then
cp orchestrator/src/config/env.example orchestrator/.env
# Update with defaults
sed -i 's|DATABASE_URL=.*|DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comboflow|' orchestrator/.env
sed -i 's|SESSION_SECRET=.*|SESSION_SECRET=dev-secret-change-in-production-min-32-chars-'$(date +%s)'|' orchestrator/.env
sed -i 's|RUN_MIGRATIONS=.*|RUN_MIGRATIONS=true|' orchestrator/.env
echo -e "${GREEN}✅ Created orchestrator/.env${NC}"
else
cat > orchestrator/.env << EOF
NODE_ENV=development
PORT=8080
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comboflow
REDIS_URL=redis://localhost:6379
SESSION_SECRET=dev-secret-change-in-production-min-32-chars-$(date +%s)
RUN_MIGRATIONS=true
LOG_LEVEL=info
EOF
echo -e "${GREEN}✅ Created orchestrator/.env${NC}"
fi
else
echo -e "${GREEN}✅ orchestrator/.env exists${NC}"
fi
# Install dependencies
echo -e "\n${CYAN}Installing dependencies...${NC}"
# Webapp
if [ ! -d "webapp/node_modules" ]; then
echo -e "Installing webapp dependencies..."
cd webapp && npm install && cd ..
echo -e "${GREEN}✅ Webapp dependencies installed${NC}"
else
echo -e "${GREEN}✅ Webapp dependencies already installed${NC}"
fi
# Orchestrator
if [ ! -d "orchestrator/node_modules" ]; then
echo -e "Installing orchestrator dependencies..."
cd orchestrator && npm install && cd ..
echo -e "${GREEN}✅ Orchestrator dependencies installed${NC}"
else
echo -e "${GREEN}✅ Orchestrator dependencies already installed${NC}"
fi
# Contracts
if [ ! -d "contracts/node_modules" ]; then
echo -e "Installing contracts dependencies..."
cd contracts && npm install && cd ..
echo -e "${GREEN}✅ Contracts dependencies installed${NC}"
else
echo -e "${GREEN}✅ Contracts dependencies already installed${NC}"
fi
# Setup database (optional)
echo -e "\n${CYAN}Database setup...${NC}"
if command -v docker &> /dev/null; then
echo -e "Setting up PostgreSQL with Docker..."
./scripts/setup-database.sh
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Database setup complete${NC}"
# Run migrations
echo -e "\nRunning database migrations..."
./scripts/run-migrations.sh
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Migrations complete${NC}"
else
echo -e "${YELLOW}⚠️ Migrations failed (database may not be ready yet)${NC}"
fi
else
echo -e "${YELLOW}⚠️ Database setup skipped or failed${NC}"
fi
else
echo -e "${YELLOW}⚠️ Docker not available, skipping database setup${NC}"
echo -e " You can set up PostgreSQL manually or use Azure Database"
fi
# Summary
echo -e "\n========================================"
echo -e " SETUP COMPLETE"
echo -e "========================================\n"
echo -e "${GREEN}✅ Development environment ready!${NC}\n"
echo -e "${CYAN}Next steps:${NC}"
echo -e " 1. Start all services:"
echo -e " ${CYAN}./scripts/start-all.sh${NC}"
echo -e ""
echo -e " 2. Check service status:"
echo -e " ${CYAN}./scripts/check-status.sh${NC}"
echo -e ""
echo -e " 3. Test endpoints:"
echo -e " ${CYAN}./scripts/test-curl.sh${NC}"
echo -e ""
echo -e " 4. Access services:"
echo -e " ${CYAN}Webapp: http://localhost:3000${NC}"
echo -e " ${CYAN}Orchestrator: http://localhost:8080${NC}"
echo -e " ${CYAN}Health: http://localhost:8080/health${NC}"
echo ""

103
scripts/test-database.sh Normal file
View File

@@ -0,0 +1,103 @@
#!/bin/bash
# Test Database Connection and Queries
echo -e "\n========================================"
echo -e " DATABASE CONNECTION TEST"
echo -e "========================================\n"
# Check if .env exists
if [ ! -f "orchestrator/.env" ]; then
echo -e "\033[0;31m❌ orchestrator/.env not found\033[0m"
exit 1
fi
# Get DATABASE_URL
DATABASE_URL=$(grep "^DATABASE_URL=" orchestrator/.env | cut -d '=' -f2- | tr -d '"' | tr -d "'")
if [ -z "$DATABASE_URL" ]; then
echo -e "\033[0;31m❌ DATABASE_URL not set\033[0m"
exit 1
fi
# Extract connection details
if [[ $DATABASE_URL =~ postgresql://([^:]+):([^@]+)@([^:]+):([^/]+)/(.+) ]]; then
DB_USER="${BASH_REMATCH[1]}"
DB_PASS="${BASH_REMATCH[2]}"
DB_HOST="${BASH_REMATCH[3]}"
DB_PORT="${BASH_REMATCH[4]}"
DB_NAME="${BASH_REMATCH[5]}"
else
echo -e "\033[0;31m❌ Could not parse DATABASE_URL\033[0m"
exit 1
fi
# Check if psql is available
if ! command -v psql &> /dev/null; then
echo -e "\033[0;33m⚠ psql not found. Install PostgreSQL client to run tests.\033[0m"
echo -e " Ubuntu: sudo apt install postgresql-client"
exit 1
fi
echo -e "Testing connection to: $DB_HOST:$DB_PORT/$DB_NAME\n"
# Test 1: Basic connection
echo -e "1. Testing basic connection..."
if PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT version();" > /dev/null 2>&1; then
echo -e " \033[0;32m✅ Connection successful\033[0m"
else
echo -e " \033[0;31m❌ Connection failed\033[0m"
exit 1
fi
# Test 2: Check tables exist
echo -e "\n2. Checking database tables..."
TABLES=$(PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -t -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public';" 2>/dev/null | tr -d ' ')
if [ -n "$TABLES" ] && [ "$TABLES" -gt 0 ]; then
echo -e " \033[0;32m✅ Found $TABLES table(s)\033[0m"
# List tables
echo -e "\n Tables:"
PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name;" 2>/dev/null | grep -v "^$" | grep -v "table_name" | grep -v "---" | sed 's/^/ - /'
else
echo -e " \033[0;33m⚠ No tables found. Run migrations first.\033[0m"
fi
# Test 3: Test queries on each table
if [ -n "$TABLES" ] && [ "$TABLES" -gt 0 ]; then
echo -e "\n3. Testing queries on tables..."
TABLES_LIST=$(PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -t -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';" 2>/dev/null | tr -d ' ')
for table in $TABLES_LIST; do
if [ -n "$table" ]; then
COUNT=$(PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -t -c "SELECT COUNT(*) FROM $table;" 2>/dev/null | tr -d ' ')
if [ $? -eq 0 ]; then
echo -e " \033[0;32m✅ $table: $COUNT row(s)\033[0m"
else
echo -e " \033[0;33m⚠ $table: Query failed\033[0m"
fi
fi
done
fi
# Test 4: Test health endpoint (if orchestrator is running)
echo -e "\n4. Testing orchestrator health endpoint..."
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
HEALTH=$(curl -s http://localhost:8080/health)
if echo "$HEALTH" | grep -q "healthy\|status"; then
echo -e " \033[0;32m✅ Health endpoint responding\033[0m"
if command -v jq &> /dev/null; then
DB_STATUS=$(echo "$HEALTH" | jq -r '.checks.database // "unknown"' 2>/dev/null)
echo -e " Database status: $DB_STATUS"
fi
else
echo -e " \033[0;33m⚠ Health endpoint returned unexpected response\033[0m"
fi
else
echo -e " \033[0;33m⚠ Orchestrator not running or not accessible\033[0m"
fi
echo -e "\n\033[0;32m✅ Database tests completed\033[0m"
echo ""

180
scripts/test-e2e-flow.sh Normal file
View File

@@ -0,0 +1,180 @@
#!/bin/bash
# End-to-End Flow Test Script
# Tests: create plan → sign → execute → view receipt
echo -e "\n========================================"
echo -e " END-TO-END FLOW TEST"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Check if orchestrator is running
echo -e "1. Checking orchestrator service..."
if ! curl -s http://localhost:8080/health > /dev/null 2>&1; then
echo -e " ${RED}❌ Orchestrator not running${NC}"
echo -e " Start it with: cd orchestrator && npm run dev"
exit 1
fi
echo -e " ${GREEN}✅ Orchestrator is running${NC}"
# Check if webapp is running
echo -e "\n2. Checking webapp service..."
if ! curl -s http://localhost:3000 > /dev/null 2>&1; then
echo -e " ${YELLOW}⚠️ Webapp not running (optional for API tests)${NC}"
else
echo -e " ${GREEN}✅ Webapp is running${NC}"
fi
# Test 1: Create a plan
echo -e "\n3. Creating a test plan..."
PLAN_DATA='{
"creator": "test-user-123",
"steps": [
{
"type": "borrow",
"adapter": "aave",
"params": {
"asset": "USDC",
"amount": "1000"
}
},
{
"type": "swap",
"adapter": "uniswap",
"params": {
"tokenIn": "USDC",
"tokenOut": "ETH",
"amountIn": "1000"
}
}
],
"maxRecursion": 3,
"maxLtv": 0.6
}'
CREATE_RESPONSE=$(curl -s -X POST http://localhost:8080/api/plans \
-H "Content-Type: application/json" \
-d "$PLAN_DATA" \
-w "\n%{http_code}")
HTTP_CODE=$(echo "$CREATE_RESPONSE" | tail -n1)
BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Plan created successfully${NC}"
# Extract plan_id
if command -v jq &> /dev/null; then
PLAN_ID=$(echo "$BODY" | jq -r '.plan_id // .id // empty' 2>/dev/null)
if [ -n "$PLAN_ID" ] && [ "$PLAN_ID" != "null" ]; then
echo -e " Plan ID: $PLAN_ID"
else
echo -e " ${YELLOW}⚠️ Could not extract plan_id from response${NC}"
PLAN_ID=""
fi
else
echo -e " ${YELLOW}⚠️ jq not installed, cannot extract plan_id${NC}"
PLAN_ID=""
fi
else
echo -e " ${RED}❌ Failed to create plan (HTTP $HTTP_CODE)${NC}"
echo -e " Response: $BODY"
exit 1
fi
# Test 2: Get the plan
if [ -n "$PLAN_ID" ]; then
echo -e "\n4. Retrieving plan..."
GET_RESPONSE=$(curl -s -w "\n%{http_code}" http://localhost:8080/api/plans/$PLAN_ID)
GET_HTTP_CODE=$(echo "$GET_RESPONSE" | tail -n1)
if [ "$GET_HTTP_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Plan retrieved successfully${NC}"
else
echo -e " ${YELLOW}⚠️ Could not retrieve plan (HTTP $GET_HTTP_CODE)${NC}"
fi
fi
# Test 3: Add signature (mock)
if [ -n "$PLAN_ID" ]; then
echo -e "\n5. Adding signature to plan..."
SIGNATURE_DATA='{
"signature": "0x1234567890abcdef",
"messageHash": "0xabcdef1234567890",
"signerAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}'
SIGN_RESPONSE=$(curl -s -X POST http://localhost:8080/api/plans/$PLAN_ID/signature \
-H "Content-Type: application/json" \
-d "$SIGNATURE_DATA" \
-w "\n%{http_code}")
SIGN_HTTP_CODE=$(echo "$SIGN_RESPONSE" | tail -n1)
if [ "$SIGN_HTTP_CODE" = "200" ] || [ "$SIGN_HTTP_CODE" = "201" ]; then
echo -e " ${GREEN}✅ Signature added successfully${NC}"
else
echo -e " ${YELLOW}⚠️ Could not add signature (HTTP $SIGN_HTTP_CODE)${NC}"
fi
fi
# Test 4: Validate plan
if [ -n "$PLAN_ID" ]; then
echo -e "\n6. Validating plan..."
VALIDATE_RESPONSE=$(curl -s -X POST http://localhost:8080/api/plans/$PLAN_ID/validate \
-w "\n%{http_code}")
VALIDATE_HTTP_CODE=$(echo "$VALIDATE_RESPONSE" | tail -n1)
if [ "$VALIDATE_HTTP_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Plan validation successful${NC}"
if command -v jq &> /dev/null; then
VALID=$(echo "$VALIDATE_RESPONSE" | sed '$d' | jq -r '.valid // false' 2>/dev/null)
if [ "$VALID" = "true" ]; then
echo -e " Plan is valid: ${GREEN}${NC}"
else
echo -e " Plan validation: ${YELLOW}⚠️${NC}"
fi
fi
else
echo -e " ${YELLOW}⚠️ Could not validate plan (HTTP $VALIDATE_HTTP_CODE)${NC}"
fi
fi
# Test 5: Check execution endpoint (if available)
echo -e "\n7. Testing execution endpoint..."
EXEC_RESPONSE=$(curl -s -X POST http://localhost:8080/api/execution/execute \
-H "Content-Type: application/json" \
-d "{\"plan_id\": \"$PLAN_ID\"}" \
-w "\n%{http_code}" 2>/dev/null)
if [ $? -eq 0 ]; then
EXEC_HTTP_CODE=$(echo "$EXEC_RESPONSE" | tail -n1)
if [ "$EXEC_HTTP_CODE" = "200" ] || [ "$EXEC_HTTP_CODE" = "202" ]; then
echo -e " ${GREEN}✅ Execution endpoint accessible${NC}"
else
echo -e " ${YELLOW}⚠️ Execution endpoint returned HTTP $EXEC_HTTP_CODE${NC}"
fi
else
echo -e " ${YELLOW}⚠️ Execution endpoint not available or requires authentication${NC}"
fi
# Summary
echo -e "\n========================================"
echo -e " TEST SUMMARY"
echo -e "========================================\n"
echo -e "${GREEN}✅ Basic flow test completed${NC}"
if [ -n "$PLAN_ID" ]; then
echo -e " Test plan ID: $PLAN_ID"
echo -e " View plan: http://localhost:8080/api/plans/$PLAN_ID"
fi
echo -e "\n📝 Next steps:"
echo -e " 1. Test full execution flow via webapp UI"
echo -e " 2. Verify receipt generation"
echo -e " 3. Check audit logs"
echo ""

View File

@@ -0,0 +1,164 @@
#!/bin/bash
# Test Webapp-Orchestrator Communication
# Verifies that the webapp can communicate with the orchestrator
echo -e "\n========================================"
echo -e " WEBAPP-ORCHESTRATOR COMMUNICATION TEST"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
PASSED=0
FAILED=0
# Get orchestrator URL
if [ -f "webapp/.env.local" ]; then
ORCH_URL=$(grep "NEXT_PUBLIC_ORCH_URL" webapp/.env.local | cut -d'=' -f2 | tr -d '"' | tr -d "'" | tr -d ' ')
else
ORCH_URL="http://localhost:8080"
fi
echo -e "${CYAN}Orchestrator URL: $ORCH_URL${NC}\n"
# Test 1: Orchestrator health
echo -e "1. Testing orchestrator health endpoint..."
if curl -s "$ORCH_URL/health" > /dev/null 2>&1; then
HEALTH=$(curl -s "$ORCH_URL/health" --max-time 5)
if echo "$HEALTH" | grep -q "healthy\|status"; then
echo -e " ${GREEN}✅ Orchestrator health endpoint accessible${NC}"
if command -v jq &> /dev/null; then
STATUS=$(echo "$HEALTH" | jq -r '.status // "unknown"' 2>/dev/null)
DB_STATUS=$(echo "$HEALTH" | jq -r '.checks.database // "unknown"' 2>/dev/null)
echo -e " Status: $STATUS"
echo -e " Database: $DB_STATUS"
fi
((PASSED++))
else
echo -e " ${RED}❌ Health endpoint returned unexpected response${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ Orchestrator not accessible${NC}"
echo -e " Make sure orchestrator is running: cd orchestrator && npm run dev"
((FAILED++))
fi
# Test 2: CORS headers
echo -e "\n2. Testing CORS headers..."
CORS_HEADERS=$(curl -s -I "$ORCH_URL/health" --max-time 5 | grep -i "access-control")
if [ -n "$CORS_HEADERS" ]; then
echo -e " ${GREEN}✅ CORS headers present${NC}"
echo "$CORS_HEADERS" | sed 's/^/ /'
((PASSED++))
else
echo -e " ${YELLOW}⚠️ CORS headers not found (may cause webapp issues)${NC}"
fi
# Test 3: API endpoints
echo -e "\n3. Testing API endpoints..."
# Test compliance status endpoint
echo -e " Testing /api/compliance/status..."
COMPLIANCE_RESPONSE=$(curl -s -w "\n%{http_code}" "$ORCH_URL/api/compliance/status" --max-time 5 2>&1)
COMPLIANCE_CODE=$(echo "$COMPLIANCE_RESPONSE" | tail -n1)
if [ "$COMPLIANCE_CODE" = "200" ] || [ "$COMPLIANCE_CODE" = "404" ]; then
echo -e " ${GREEN}✅ Compliance endpoint accessible (HTTP $COMPLIANCE_CODE)${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Compliance endpoint returned HTTP $COMPLIANCE_CODE${NC}"
fi
# Test plans endpoint (GET)
echo -e " Testing GET /api/plans..."
PLANS_RESPONSE=$(curl -s -w "\n%{http_code}" "$ORCH_URL/api/plans" --max-time 5 2>&1)
PLANS_CODE=$(echo "$PLANS_RESPONSE" | tail -n1)
if [ "$PLANS_CODE" = "200" ] || [ "$PLANS_CODE" = "404" ] || [ "$PLANS_CODE" = "405" ]; then
echo -e " ${GREEN}✅ Plans endpoint accessible (HTTP $PLANS_CODE)${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Plans endpoint returned HTTP $PLANS_CODE${NC}"
fi
# Test 4: Create plan (POST)
echo -e "\n4. Testing plan creation..."
TEST_PLAN='{
"creator": "test-user",
"steps": [
{
"type": "borrow",
"adapter": "aave",
"params": {
"asset": "USDC",
"amount": "1000"
}
}
],
"maxRecursion": 3,
"maxLtv": 0.6
}'
CREATE_RESPONSE=$(curl -s -X POST "$ORCH_URL/api/plans" \
-H "Content-Type: application/json" \
-d "$TEST_PLAN" \
-w "\n%{http_code}" \
--max-time 10 2>&1)
CREATE_CODE=$(echo "$CREATE_RESPONSE" | tail -n1)
CREATE_BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
if [ "$CREATE_CODE" = "201" ] || [ "$CREATE_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Plan creation successful (HTTP $CREATE_CODE)${NC}"
if command -v jq &> /dev/null && [ -n "$CREATE_BODY" ]; then
PLAN_ID=$(echo "$CREATE_BODY" | jq -r '.plan_id // .id // empty' 2>/dev/null)
if [ -n "$PLAN_ID" ] && [ "$PLAN_ID" != "null" ]; then
echo -e " Plan ID: $PLAN_ID"
fi
fi
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Plan creation returned HTTP $CREATE_CODE${NC}"
if [ -n "$CREATE_BODY" ]; then
echo -e " Response: $(echo "$CREATE_BODY" | head -3)"
fi
fi
# Test 5: Webapp can reach orchestrator
echo -e "\n5. Testing webapp-orchestrator connectivity..."
if nc -z localhost 3000 2>/dev/null; then
echo -e " ${GREEN}✅ Webapp is running${NC}"
# Test if webapp can make requests to orchestrator
# This is a proxy test - we check if the webapp's API routes work
WEBAPP_API=$(curl -s http://localhost:3000/api/health 2>/dev/null || echo "")
if [ -n "$WEBAPP_API" ]; then
echo -e " ${GREEN}✅ Webapp API routes accessible${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Webapp API routes may not be configured${NC}"
fi
else
echo -e " ${YELLOW}⚠️ Webapp not running${NC}"
echo -e " Start with: cd webapp && npm run dev"
fi
# Summary
echo -e "\n========================================"
echo -e " TEST SUMMARY"
echo -e "========================================\n"
echo -e "${GREEN}✅ Passed: $PASSED${NC}"
echo -e "${RED}❌ Failed: $FAILED${NC}"
if [ $FAILED -eq 0 ]; then
echo -e "\n${GREEN}✅ Webapp-orchestrator communication verified!${NC}\n"
exit 0
else
echo -e "\n${RED}❌ Some communication tests failed.${NC}\n"
exit 1
fi

194
scripts/validate-setup.sh Normal file
View File

@@ -0,0 +1,194 @@
#!/bin/bash
# Validate Complete Setup
# Checks that everything is configured correctly
echo -e "\n========================================"
echo -e " SETUP VALIDATION"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
PASSED=0
FAILED=0
WARNINGS=0
# Check 1: Environment files
echo -e "${CYAN}1. Environment Files${NC}"
if [ -f "webapp/.env.local" ]; then
echo -e " ${GREEN}✅ webapp/.env.local exists${NC}"
if grep -q "NEXT_PUBLIC_ORCH_URL" webapp/.env.local; then
echo -e " ${GREEN}✅ NEXT_PUBLIC_ORCH_URL configured${NC}"
((PASSED++))
else
echo -e " ${RED}❌ NEXT_PUBLIC_ORCH_URL missing${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ webapp/.env.local missing${NC}"
((FAILED++))
fi
if [ -f "orchestrator/.env" ]; then
echo -e " ${GREEN}✅ orchestrator/.env exists${NC}"
if grep -q "DATABASE_URL" orchestrator/.env; then
echo -e " ${GREEN}✅ DATABASE_URL configured${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ DATABASE_URL not set${NC}"
((WARNINGS++))
fi
if grep -q "SESSION_SECRET" orchestrator/.env; then
SECRET_LEN=$(grep "SESSION_SECRET" orchestrator/.env | cut -d'=' -f2 | tr -d '"' | wc -c)
if [ $SECRET_LEN -ge 32 ]; then
echo -e " ${GREEN}✅ SESSION_SECRET configured (length: $SECRET_LEN)${NC}"
((PASSED++))
else
echo -e " ${RED}❌ SESSION_SECRET too short (min 32 chars)${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ SESSION_SECRET missing${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ orchestrator/.env missing${NC}"
((FAILED++))
fi
# Check 2: Dependencies
echo -e "\n${CYAN}2. Dependencies${NC}"
if [ -d "webapp/node_modules" ]; then
echo -e " ${GREEN}✅ Webapp dependencies installed${NC}"
((PASSED++))
else
echo -e " ${RED}❌ Webapp dependencies missing${NC}"
((FAILED++))
fi
if [ -d "orchestrator/node_modules" ]; then
echo -e " ${GREEN}✅ Orchestrator dependencies installed${NC}"
((PASSED++))
else
echo -e " ${RED}❌ Orchestrator dependencies missing${NC}"
((FAILED++))
fi
if [ -d "contracts/node_modules" ]; then
echo -e " ${GREEN}✅ Contracts dependencies installed${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Contracts dependencies missing (optional)${NC}"
((WARNINGS++))
fi
# Check 3: Database
echo -e "\n${CYAN}3. Database${NC}"
if command -v docker &> /dev/null; then
if docker ps --filter "name=combo-postgres" --format "{{.Names}}" | grep -q "combo-postgres"; then
echo -e " ${GREEN}✅ PostgreSQL container running${NC}"
((PASSED++))
# Test connection
if nc -z localhost 5432 2>/dev/null; then
echo -e " ${GREEN}✅ PostgreSQL accessible on port 5432${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ PostgreSQL not accessible on port 5432${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ PostgreSQL container not running${NC}"
echo -e " Run: ./scripts/setup-database.sh"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Docker not available${NC}"
((WARNINGS++))
fi
# Check 4: Services
echo -e "\n${CYAN}4. Services${NC}"
if nc -z localhost 3000 2>/dev/null; then
echo -e " ${GREEN}✅ Webapp running on port 3000${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Webapp not running on port 3000${NC}"
((WARNINGS++))
fi
if nc -z localhost 8080 2>/dev/null; then
echo -e " ${GREEN}✅ Orchestrator running on port 8080${NC}"
((PASSED++))
# Test health endpoint
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
HEALTH=$(curl -s http://localhost:8080/health)
if echo "$HEALTH" | grep -q "healthy\|status"; then
echo -e " ${GREEN}✅ Health endpoint responding${NC}"
if command -v jq &> /dev/null; then
DB_STATUS=$(echo "$HEALTH" | jq -r '.checks.database // "unknown"' 2>/dev/null)
if [ "$DB_STATUS" = "up" ]; then
echo -e " ${GREEN}✅ Database connected${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Database status: $DB_STATUS${NC}"
((WARNINGS++))
fi
fi
else
echo -e " ${YELLOW}⚠️ Health endpoint returned unexpected response${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Health endpoint not accessible${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Orchestrator not running on port 8080${NC}"
((WARNINGS++))
fi
# Check 5: Scripts
echo -e "\n${CYAN}5. Scripts${NC}"
SCRIPTS=("start-all.sh" "check-status.sh" "setup-database.sh" "run-migrations.sh" "test-curl.sh")
for script in "${SCRIPTS[@]}"; do
if [ -f "scripts/$script" ] && [ -x "scripts/$script" ]; then
echo -e " ${GREEN}✅ scripts/$script (executable)${NC}"
((PASSED++))
elif [ -f "scripts/$script" ]; then
echo -e " ${YELLOW}⚠️ scripts/$script (not executable)${NC}"
echo -e " Run: chmod +x scripts/$script"
((WARNINGS++))
else
echo -e " ${RED}❌ scripts/$script missing${NC}"
((FAILED++))
fi
done
# Summary
echo -e "\n========================================"
echo -e " VALIDATION SUMMARY"
echo -e "========================================\n"
echo -e "${GREEN}✅ Passed: $PASSED${NC}"
echo -e "${YELLOW}⚠️ Warnings: $WARNINGS${NC}"
echo -e "${RED}❌ Failed: $FAILED${NC}"
if [ $FAILED -eq 0 ]; then
if [ $WARNINGS -eq 0 ]; then
echo -e "\n${GREEN}✅ Setup is complete and valid!${NC}\n"
exit 0
else
echo -e "\n${YELLOW}⚠️ Setup is mostly complete, but has some warnings.${NC}\n"
exit 0
fi
else
echo -e "\n${RED}❌ Setup has errors. Please fix them before continuing.${NC}\n"
exit 1
fi

112
scripts/verify-all.sh Normal file
View File

@@ -0,0 +1,112 @@
#!/bin/bash
# Master Verification Script
# Runs all verification and testing scripts in sequence
echo -e "\n========================================"
echo -e " COMPREHENSIVE SYSTEM VERIFICATION"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
TOTAL_TESTS=0
PASSED_TESTS=0
FAILED_TESTS=0
# Function to run a test script
run_test() {
local script_name=$1
local description=$2
echo -e "\n${CYAN}Running: $description${NC}"
echo -e "${CYAN}Script: $script_name${NC}"
echo -e "----------------------------------------"
if [ -f "scripts/$script_name" ] && [ -x "scripts/$script_name" ]; then
((TOTAL_TESTS++))
if ./scripts/$script_name; then
echo -e "${GREEN}$description: PASSED${NC}"
((PASSED_TESTS++))
return 0
else
echo -e "${RED}$description: FAILED${NC}"
((FAILED_TESTS++))
return 1
fi
else
echo -e "${YELLOW}⚠️ Script not found or not executable: $script_name${NC}"
return 2
fi
}
# Phase 1: Setup Validation
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} PHASE 1: SETUP VALIDATION${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}"
run_test "validate-setup.sh" "Complete Setup Validation"
# Phase 2: Database Verification
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} PHASE 2: DATABASE VERIFICATION${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}"
run_test "test-database.sh" "Database Connection Test"
# Phase 3: Service Verification
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} PHASE 3: SERVICE VERIFICATION${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}"
# Check if services are running first
if nc -z localhost 8080 2>/dev/null && nc -z localhost 3000 2>/dev/null; then
run_test "check-status.sh" "Service Status Check"
run_test "verify-services.sh" "Service Verification"
run_test "test-curl.sh" "API Endpoint Testing"
else
echo -e "${YELLOW}⚠️ Services not running. Start services first:${NC}"
echo -e " ${CYAN}./scripts/start-all.sh${NC}"
echo -e "${YELLOW} Skipping service tests...${NC}"
fi
# Phase 4: Frontend Verification
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} PHASE 4: FRONTEND VERIFICATION${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}"
run_test "verify-frontend.sh" "Frontend Verification"
# Phase 5: Integration Testing
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} PHASE 5: INTEGRATION TESTING${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}"
if nc -z localhost 8080 2>/dev/null && nc -z localhost 3000 2>/dev/null; then
run_test "test-webapp-orchestrator.sh" "Webapp-Orchestrator Communication"
run_test "test-e2e-flow.sh" "End-to-End Flow Test"
else
echo -e "${YELLOW}⚠️ Services not running. Skipping integration tests...${NC}"
fi
# Final Summary
echo -e "\n${CYAN}════════════════════════════════════${NC}"
echo -e "${CYAN} VERIFICATION SUMMARY${NC}"
echo -e "${CYAN}════════════════════════════════════${NC}\n"
echo -e "Total Tests Run: $TOTAL_TESTS"
echo -e "${GREEN}✅ Passed: $PASSED_TESTS${NC}"
echo -e "${RED}❌ Failed: $FAILED_TESTS${NC}"
if [ $FAILED_TESTS -eq 0 ]; then
echo -e "\n${GREEN}✅ All verification tests passed!${NC}\n"
exit 0
else
echo -e "\n${RED}❌ Some verification tests failed.${NC}"
echo -e "${YELLOW} Review the output above for details.${NC}\n"
exit 1
fi

172
scripts/verify-frontend.sh Normal file
View File

@@ -0,0 +1,172 @@
#!/bin/bash
# Frontend Verification Script
# Verifies Next.js compilation and frontend functionality
echo -e "\n========================================"
echo -e " FRONTEND VERIFICATION"
echo -e "========================================\n"
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
PASSED=0
FAILED=0
WARNINGS=0
# Check 1: Environment file
echo -e "${CYAN}1. Environment Configuration${NC}"
if [ -f "webapp/.env.local" ]; then
echo -e " ${GREEN}✅ webapp/.env.local exists${NC}"
if grep -q "NEXT_PUBLIC_ORCH_URL" webapp/.env.local; then
ORCH_URL=$(grep "NEXT_PUBLIC_ORCH_URL" webapp/.env.local | cut -d'=' -f2 | tr -d '"' | tr -d "'")
echo -e " ${GREEN}✅ NEXT_PUBLIC_ORCH_URL: $ORCH_URL${NC}"
((PASSED++))
else
echo -e " ${RED}❌ NEXT_PUBLIC_ORCH_URL missing${NC}"
((FAILED++))
fi
else
echo -e " ${RED}❌ webapp/.env.local missing${NC}"
((FAILED++))
fi
# Check 2: Dependencies
echo -e "\n${CYAN}2. Dependencies${NC}"
if [ -d "webapp/node_modules" ]; then
echo -e " ${GREEN}✅ Dependencies installed${NC}"
((PASSED++))
else
echo -e " ${RED}❌ Dependencies missing${NC}"
echo -e " Run: cd webapp && npm install"
((FAILED++))
fi
# Check 3: TypeScript compilation
echo -e "\n${CYAN}3. TypeScript Compilation${NC}"
cd webapp || exit 1
if [ -f "tsconfig.json" ]; then
echo -e " Checking TypeScript configuration..."
if npx tsc --noEmit --skipLibCheck 2>&1 | head -20; then
echo -e " ${GREEN}✅ TypeScript compilation successful${NC}"
((PASSED++))
else
TSC_ERROR=$(npx tsc --noEmit --skipLibCheck 2>&1 | grep -i "error" | head -5)
if [ -n "$TSC_ERROR" ]; then
echo -e " ${RED}❌ TypeScript errors found:${NC}"
echo "$TSC_ERROR" | sed 's/^/ /'
((FAILED++))
else
echo -e " ${YELLOW}⚠️ TypeScript check completed with warnings${NC}"
((WARNINGS++))
fi
fi
else
echo -e " ${YELLOW}⚠️ tsconfig.json not found${NC}"
((WARNINGS++))
fi
# Check 4: Next.js build (dry run)
echo -e "\n${CYAN}4. Next.js Build Check${NC}"
if [ -f "next.config.ts" ] || [ -f "next.config.js" ]; then
echo -e " Running Next.js build check (this may take a minute)..."
if timeout 120 npm run build > /tmp/nextjs-build.log 2>&1; then
echo -e " ${GREEN}✅ Next.js build successful${NC}"
((PASSED++))
else
BUILD_ERROR=$(tail -20 /tmp/nextjs-build.log | grep -i "error\|failed" | head -5)
if [ -n "$BUILD_ERROR" ]; then
echo -e " ${RED}❌ Next.js build failed:${NC}"
echo "$BUILD_ERROR" | sed 's/^/ /'
((FAILED++))
else
echo -e " ${YELLOW}⚠️ Build check timed out or had warnings${NC}"
echo -e " Check /tmp/nextjs-build.log for details"
((WARNINGS++))
fi
fi
else
echo -e " ${YELLOW}⚠️ Next.js config not found${NC}"
((WARNINGS++))
fi
cd ..
# Check 5: Webapp service
echo -e "\n${CYAN}5. Webapp Service${NC}"
if nc -z localhost 3000 2>/dev/null; then
echo -e " ${GREEN}✅ Webapp running on port 3000${NC}"
((PASSED++))
# Test HTTP response
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 --max-time 5 2>&1)
if [ "$HTTP_CODE" = "200" ]; then
echo -e " ${GREEN}✅ Webapp responding with HTTP 200${NC}"
((PASSED++))
# Check content
CONTENT=$(curl -s http://localhost:3000 --max-time 5 | head -100)
if echo "$CONTENT" | grep -q "html\|<!DOCTYPE\|<html"; then
echo -e " ${GREEN}✅ Webapp serving HTML content${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Webapp response may not be HTML${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Webapp returned HTTP $HTTP_CODE${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Webapp not running on port 3000${NC}"
echo -e " Start with: cd webapp && npm run dev"
((WARNINGS++))
fi
# Check 6: API connectivity
echo -e "\n${CYAN}6. Orchestrator API Connectivity${NC}"
if [ -f "webapp/.env.local" ]; then
ORCH_URL=$(grep "NEXT_PUBLIC_ORCH_URL" webapp/.env.local | cut -d'=' -f2 | tr -d '"' | tr -d "'" | tr -d ' ')
if [ -n "$ORCH_URL" ]; then
if curl -s "$ORCH_URL/health" > /dev/null 2>&1; then
HEALTH=$(curl -s "$ORCH_URL/health" --max-time 5)
if echo "$HEALTH" | grep -q "healthy\|status"; then
echo -e " ${GREEN}✅ Orchestrator health endpoint accessible${NC}"
((PASSED++))
else
echo -e " ${YELLOW}⚠️ Orchestrator health endpoint returned unexpected response${NC}"
((WARNINGS++))
fi
else
echo -e " ${YELLOW}⚠️ Orchestrator not accessible at $ORCH_URL${NC}"
((WARNINGS++))
fi
fi
fi
# Summary
echo -e "\n========================================"
echo -e " VERIFICATION SUMMARY"
echo -e "========================================\n"
echo -e "${GREEN}✅ Passed: $PASSED${NC}"
echo -e "${YELLOW}⚠️ Warnings: $WARNINGS${NC}"
echo -e "${RED}❌ Failed: $FAILED${NC}"
if [ $FAILED -eq 0 ]; then
if [ $WARNINGS -eq 0 ]; then
echo -e "\n${GREEN}✅ Frontend verification passed!${NC}\n"
exit 0
else
echo -e "\n${YELLOW}⚠️ Frontend verification passed with warnings.${NC}\n"
exit 0
fi
else
echo -e "\n${RED}❌ Frontend verification failed. Please fix errors.${NC}\n"
exit 1
fi