#!/bin/bash echo "==============================================" echo "Hexagonal Architecture Verification Script" echo "==============================================" echo "" ERRORS=0 # Test 1: No imports from adapters in core echo "✓ Test 1: Checking for adapter imports in core..." if grep -r "from.*adapters" src/core/ 2>/dev/null; then echo "❌ FAIL: Core imports from adapters" ERRORS=$((ERRORS + 1)) else echo "✅ PASS: No adapter imports in core" fi echo "" # Test 2: No external library imports in core echo "✓ Test 2: Checking for external library imports in core..." if grep -rE "import (PyPDF2|docx|fastapi|uvicorn)" src/core/ 2>/dev/null; then echo "❌ FAIL: Core imports external libraries" ERRORS=$((ERRORS + 1)) else echo "✅ PASS: Core is pure (no external libraries)" fi echo "" # Test 3: No base.py files in adapters echo "✓ Test 3: Checking for base.py files in adapters..." if find src/adapters -name "base.py" 2>/dev/null | grep -q .; then echo "❌ FAIL: Found base.py files in adapters" find src/adapters -name "base.py" ERRORS=$((ERRORS + 1)) else echo "✅ PASS: No base.py files in adapters" fi echo "" # Test 4: All port interfaces exist in core/ports echo "✓ Test 4: Checking port interfaces..." REQUIRED_PORTS=( "src/core/ports/incoming/text_processor.py" "src/core/ports/outgoing/extractor.py" "src/core/ports/outgoing/extractor_factory.py" "src/core/ports/outgoing/chunker.py" "src/core/ports/outgoing/chunking_context.py" "src/core/ports/outgoing/repository.py" ) for port in "${REQUIRED_PORTS[@]}"; do if [ -f "$port" ]; then echo " ✓ Found: $port" else echo " ❌ Missing: $port" ERRORS=$((ERRORS + 1)) fi done echo "" # Test 5: All concrete adapters exist echo "✓ Test 5: Checking adapter implementations..." REQUIRED_ADAPTERS=( "src/adapters/outgoing/extractors/pdf_extractor.py" "src/adapters/outgoing/extractors/docx_extractor.py" "src/adapters/outgoing/extractors/txt_extractor.py" "src/adapters/outgoing/extractors/factory.py" "src/adapters/outgoing/chunkers/fixed_size_chunker.py" "src/adapters/outgoing/chunkers/paragraph_chunker.py" "src/adapters/outgoing/chunkers/context.py" "src/adapters/outgoing/persistence/in_memory_repository.py" ) for adapter in "${REQUIRED_ADAPTERS[@]}"; do if [ -f "$adapter" ]; then echo " ✓ Found: $adapter" else echo " ❌ Missing: $adapter" ERRORS=$((ERRORS + 1)) fi done echo "" # Final result echo "==============================================" if [ $ERRORS -eq 0 ]; then echo "✅ ALL TESTS PASSED" echo "Architecture is HEXAGONAL COMPLIANT! 🎉" echo "==============================================" exit 0 else echo "❌ $ERRORS TEST(S) FAILED" echo "Architecture needs corrections!" echo "==============================================" exit 1 fi