diff --git a/.dockerignore b/.dockerignore index 6084487..02ecb73 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,4 @@ node_modules dist *.log -local-development +development \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 859daa2..afcf565 100644 --- a/.prettierignore +++ b/.prettierignore @@ -28,5 +28,5 @@ Dockerfile* Thumbs.db -local-development/ +development/ tsconfig.json diff --git a/local-development/.gitignore b/development/.gitignore similarity index 100% rename from local-development/.gitignore rename to development/.gitignore diff --git a/local-development/ambar-config.yaml b/development/ambar-config.yaml similarity index 100% rename from local-development/ambar-config.yaml rename to development/ambar-config.yaml diff --git a/local-development/build-files/frontend-database-explorer/Dockerfile b/development/build-files/frontend-database-explorer/Dockerfile similarity index 100% rename from local-development/build-files/frontend-database-explorer/Dockerfile rename to development/build-files/frontend-database-explorer/Dockerfile diff --git a/local-development/build-files/frontend-database-explorer/package-lock.json b/development/build-files/frontend-database-explorer/package-lock.json similarity index 100% rename from local-development/build-files/frontend-database-explorer/package-lock.json rename to development/build-files/frontend-database-explorer/package-lock.json diff --git a/local-development/build-files/frontend-database-explorer/package.json b/development/build-files/frontend-database-explorer/package.json similarity index 100% rename from local-development/build-files/frontend-database-explorer/package.json rename to development/build-files/frontend-database-explorer/package.json diff --git a/local-development/build-files/frontend-database-explorer/prisma-mongodb/schema.prisma b/development/build-files/frontend-database-explorer/prisma-mongodb/schema.prisma similarity index 100% rename from local-development/build-files/frontend-database-explorer/prisma-mongodb/schema.prisma rename to development/build-files/frontend-database-explorer/prisma-mongodb/schema.prisma diff --git a/local-development/build-files/frontend-database-explorer/prisma-postgres/schema.prisma b/development/build-files/frontend-database-explorer/prisma-postgres/schema.prisma similarity index 100% rename from local-development/build-files/frontend-database-explorer/prisma-postgres/schema.prisma rename to development/build-files/frontend-database-explorer/prisma-postgres/schema.prisma diff --git a/local-development/build-files/mongo/mongo.key b/development/build-files/mongo/mongo.key similarity index 100% rename from local-development/build-files/mongo/mongo.key rename to development/build-files/mongo/mongo.key diff --git a/local-development/docker-compose.yml b/development/docker-compose.yml similarity index 100% rename from local-development/docker-compose.yml rename to development/docker-compose.yml diff --git a/development/scripts/erase.sh b/development/scripts/erase.sh new file mode 100755 index 0000000..1497e15 --- /dev/null +++ b/development/scripts/erase.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "Stopping services and erasing data..." +docker compose down + +echo "Going into root mode to delete docker volumes" +sudo echo "Root mode: OK" +sudo rm -Rf data/* + +echo "" +echo "=======================================================================" +echo "|| Data erased successfully! ||" +echo "=======================================================================" +echo "|| Run 'start.sh' to restart the services. ||" +echo "=======================================================================" diff --git a/development/scripts/shutdown.sh b/development/scripts/shutdown.sh new file mode 100755 index 0000000..7a57820 --- /dev/null +++ b/development/scripts/shutdown.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +PROJECT_ROOT=$(cd "${SCRIPT_DIR}/../../" && pwd) + +cd "${SCRIPT_DIR}/../" + +docker compose down \ No newline at end of file diff --git a/local-development/docker-scripts/mac/dev_start.sh b/development/scripts/start.sh similarity index 92% rename from local-development/docker-scripts/mac/dev_start.sh rename to development/scripts/start.sh index 0859a38..0e8289a 100755 --- a/local-development/docker-scripts/mac/dev_start.sh +++ b/development/scripts/start.sh @@ -1,7 +1,10 @@ #!/bin/bash set -e -cd ../../ +SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +PROJECT_ROOT=$(cd "${SCRIPT_DIR}/../../" && pwd) + +cd "${SCRIPT_DIR}/../" docker compose down docker compose up -d --build --force-recreate diff --git a/local-development/docker-scripts/linux/dev_demo.sh b/development/scripts/test.sh similarity index 100% rename from local-development/docker-scripts/linux/dev_demo.sh rename to development/scripts/test.sh diff --git a/local-development/docker-scripts/linux/dev_shutdown.sh b/local-development/docker-scripts/linux/dev_shutdown.sh deleted file mode 100755 index 7b9cdcf..0000000 --- a/local-development/docker-scripts/linux/dev_shutdown.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -docker compose down \ No newline at end of file diff --git a/local-development/docker-scripts/linux/dev_start.sh b/local-development/docker-scripts/linux/dev_start.sh deleted file mode 100755 index 3fcdb59..0000000 --- a/local-development/docker-scripts/linux/dev_start.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -docker compose down -docker compose up -d --build --force-recreate - -all_services_fully_healthy() { - ! docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8083 to view the email server. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8084 to view the storage server. ||" -echo "=======================================================================" \ No newline at end of file diff --git a/local-development/docker-scripts/linux/dev_start_with_data_deletion.sh b/local-development/docker-scripts/linux/dev_start_with_data_deletion.sh deleted file mode 100755 index 027dda0..0000000 --- a/local-development/docker-scripts/linux/dev_start_with_data_deletion.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -echo "Going into root mode to delete some docker volumes" -sudo echo "Root mode: OK" -docker compose down -sudo rm -Rf data/* -docker compose up -d --build --force-recreate - - - -all_services_fully_healthy() { - ! docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/docker-scripts/mac/dev_demo.sh b/local-development/docker-scripts/mac/dev_demo.sh deleted file mode 100755 index ecf5daf..0000000 --- a/local-development/docker-scripts/mac/dev_demo.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -set -e - -# Colors for output -GREEN='\033[0;32m' -BLUE='\033[0;34m' -RED='\033[0;31m' -NC='\033[0m' # No Color -YELLOW='\033[1;33m' - -# Arrays for random name generation -FIRST_NAMES=("James" "Mary" "John" "Patricia" "Robert" "Jennifer" "Michael" "Linda" "William" "Elizabeth" - "David" "Barbara" "Richard" "Susan" "Joseph" "Jessica" "Thomas" "Sarah" "Charles" "Karen" - "Emma" "Olivia" "Ava" "Isabella" "Sophia" "Mia" "Charlotte" "Amelia" "Harper" "Evelyn") - -LAST_NAMES=("Smith" "Johnson" "Williams" "Brown" "Jones" "Garcia" "Miller" "Davis" "Rodriguez" "Martinez" - "Hernandez" "Lopez" "Gonzalez" "Wilson" "Anderson" "Thomas" "Taylor" "Moore" "Jackson" "Martin" - "Lee" "Perez" "Thompson" "White" "Harris" "Sanchez" "Clark" "Ramirez" "Lewis" "Robinson") - -# Function to get random name from array -get_random_name() { - local array=("$@") - local index=$((RANDOM % ${#array[@]})) - echo "${array[$index]}" -} - -# Function to display progress -show_progress() { - local duration=$1 - local bar_width=40 - local sleep_interval=$(echo "scale=4; $duration / $bar_width" | bc) - local progress=0 - - echo -n "[" - while [ $progress -lt $bar_width ]; do - echo -n "=" - progress=$((progress + 1)) - sleep $sleep_interval - done - echo -n "]" - echo -} - -# Function to make a POST request with a session token -make_post_request() { - local endpoint=$1 - local data=$2 - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "X-With-Session-Token: test-session" \ - -d "$data" \ - "http://localhost:8080$endpoint" -} - -# Function to submit an application -submit_application() { - local first_name=$1 - local last_name=$2 - local cuisine=$3 - local experience=$4 - local books=$5 - - local data="{ - \"firstName\": \"$first_name\", - \"lastName\": \"$last_name\", - \"favoriteCuisine\": \"$cuisine\", - \"yearsOfProfessionalExperience\": $experience, - \"numberOfCookingBooksRead\": $books - }" - - echo -e "${BLUE}Submitting application for $first_name $last_name...${NC}" - echo -e "Profile:" - echo -e " - Cuisine: $cuisine" - echo -e " - Professional Experience: $experience years" - echo -e " - Cooking Books Read: $books" - echo -e "Expected outcome: $([ $experience == 0 ] && [ $books -gt 0 ] && echo "${GREEN}Should be APPROVED${NC}" || echo "${RED}Should be REJECTED${NC}")" - make_post_request "/api/v1/cooking-club/membership/command/submit-application" "$data" - echo -} - -# Function to get members by cuisine -get_members() { - echo -e "${BLUE}Fetching current members by cuisine...${NC}" - curl -s -X POST \ - -H "Content-Type: application/json" \ - "http://localhost:8080/api/v1/cooking-club/membership/query/members-by-cuisine" -} - -# Main test script -echo -e "${GREEN}Starting Cooking Club Application Demo${NC}" -echo "==================================================" -echo -e "${YELLOW}Application Rules:${NC}" -echo "1. Approval Criteria:" -echo " - Must have 0 years of professional experience" -echo " - Must have read at least 1 cooking book" -echo "2. All other combinations will be rejected" -echo "==================================================" - -# Test 1: Should be approved (0 years experience, 3 books read) -echo -e "\n${YELLOW}Test 1: Testing 'Enthusiastic Beginner' Profile${NC}" -echo "This profile represents someone new to professional cooking (0 years)" -echo "but who has studied through books (3 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Italian" 0 3 -show_progress 1 - -# Test 2: Should not be approved (2 years experience, 5 books read) -echo -e "\n${YELLOW}Test 2: Testing 'Experienced Professional' Profile${NC}" -echo "This profile represents someone with professional experience (2 years)" -echo "and theoretical knowledge (5 books read). Despite the knowledge," -echo "professional experience disqualifies them." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "French" 2 5 -show_progress 1 - -# Test 3: Should be approved (0 years experience, 1 book read) -echo -e "\n${YELLOW}Test 3: Testing 'Minimal Qualifying' Profile${NC}" -echo "This profile represents someone meeting the minimum requirements:" -echo "no professional experience and has read exactly 1 book." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Japanese" 0 1 -show_progress 1 - -# Test 4: Should not be approved (0 years experience, 0 books read) -echo -e "\n${YELLOW}Test 4: Testing 'Complete Beginner' Profile${NC}" -echo "This profile represents someone with no professional experience" -echo "but also no theoretical knowledge (0 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Mexican" 0 0 -show_progress 1 - -# Final Test: Display current members -echo -e "\n${YELLOW}Outcome:${NC}" -echo "Current members grouped by their preferred cuisine." -echo "Only approved applications should appear in these results." -sleep 1 -get_members -echo " " -echo " " - -echo -e "\n${GREEN}Demo Completed${NC}" -echo "==================================================" \ No newline at end of file diff --git a/local-development/docker-scripts/mac/dev_shutdown.sh b/local-development/docker-scripts/mac/dev_shutdown.sh deleted file mode 100755 index 7b9cdcf..0000000 --- a/local-development/docker-scripts/mac/dev_shutdown.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -docker compose down \ No newline at end of file diff --git a/local-development/docker-scripts/mac/dev_start_with_data_deletion.sh b/local-development/docker-scripts/mac/dev_start_with_data_deletion.sh deleted file mode 100755 index abbd7ce..0000000 --- a/local-development/docker-scripts/mac/dev_start_with_data_deletion.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -echo "Going into root mode to delete some docker volumes" -sudo echo "Root mode: OK" -docker compose down -sudo rm -Rf data/* -docker compose up -d --build --force-recreate - - - -all_services_fully_healthy() { - ! docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/docker-scripts/windows/dev_demo.ps1 b/local-development/docker-scripts/windows/dev_demo.ps1 deleted file mode 100644 index 67f4df0..0000000 --- a/local-development/docker-scripts/windows/dev_demo.ps1 +++ /dev/null @@ -1,157 +0,0 @@ -$ErrorActionPreference = 'Stop' - -# Function for colored output -function Write-Colored { - param( - [string]$Text, - [string]$Color - ) - switch($Color) { - "GREEN" { Write-Host $Text -ForegroundColor Green } - "BLUE" { Write-Host $Text -ForegroundColor Blue } - "RED" { Write-Host $Text -ForegroundColor Red } - "YELLOW" { Write-Host $Text -ForegroundColor Yellow } - default { Write-Host $Text } - } -} - -# Arrays for random name generation -$FIRST_NAMES = @("James", "Mary", "John", "Patricia", "Robert", "Jennifer", "Michael", "Linda", "William", "Elizabeth", - "David", "Barbara", "Richard", "Susan", "Joseph", "Jessica", "Thomas", "Sarah", "Charles", "Karen", - "Emma", "Olivia", "Ava", "Isabella", "Sophia", "Mia", "Charlotte", "Amelia", "Harper", "Evelyn") - -$LAST_NAMES = @("Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis", "Rodriguez", "Martinez", - "Hernandez", "Lopez", "Gonzalez", "Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin", - "Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark", "Ramirez", "Lewis", "Robinson") - -# Function to get random name from array -function Get-RandomName { - param([string[]]$names) - $index = Get-Random -Minimum 0 -Maximum $names.Count - return $names[$index] -} - -# Function to display progress -function Show-Progress { - param([int]$duration) - $barWidth = 40 - $sleepInterval = $duration / $barWidth - $progress = 0 - - Write-Host -NoNewline "[" - while ($progress -lt $barWidth) { - Write-Host -NoNewline "=" - $progress++ - Start-Sleep -Milliseconds ($sleepInterval * 1000) - } - Write-Host -NoNewline "]" - Write-Host "" -} - -# Function to make a POST request with a session token -function Invoke-PostRequest { - param( - [string]$endpoint, - [string]$data - ) - $headers = @{ - "Content-Type" = "application/json" - "X-With-Session-Token" = "test-session" - } - return Invoke-RestMethod -Uri "http://localhost:8080$endpoint" -Method Post -Headers $headers -Body $data -} - -# Function to submit an application -function Submit-Application { - param( - [string]$firstName, - [string]$lastName, - [string]$cuisine, - [int]$experience, - [int]$books - ) - - $data = @{ - firstName = $firstName - lastName = $lastName - favoriteCuisine = $cuisine - yearsOfProfessionalExperience = $experience - numberOfCookingBooksRead = $books - } | ConvertTo-Json - - Write-Colored "Submitting application for $firstName $lastName..." "BLUE" - Write-Host "Profile:" - Write-Host " - Cuisine: $cuisine" - Write-Host " - Professional Experience: $experience years" - Write-Host " - Cooking Books Read: $books" - - $expectedOutcome = if ($experience -eq 0 -and $books -gt 0) { "Should be APPROVED" } else { "Should be REJECTED" } - Write-Colored "Expected outcome: $expectedOutcome" $(if ($experience -eq 0 -and $books -gt 0) { "GREEN" } else { "RED" }) - - Invoke-PostRequest -endpoint "/api/v1/cooking-club/membership/command/submit-application" -data $data - Write-Host "" -} - -# Function to get members by cuisine -function Get-Members { - Write-Colored "Fetching current members by cuisine..." "BLUE" - $response = Invoke-RestMethod -Uri "http://localhost:8080/api/v1/cooking-club/membership/query/members-by-cuisine" -Method Post -ContentType "application/json" - return $response -} - -# Main test script -Write-Colored "Starting Cooking Club Application Demo" "GREEN" -Write-Host "==================================================" -Write-Colored "Application Rules:" "YELLOW" -Write-Host "1. Approval Criteria:" -Write-Host " - Must have 0 years of professional experience" -Write-Host " - Must have read at least 1 cooking book" -Write-Host "2. All other combinations will be rejected" -Write-Host "==================================================" - -# Test 1: Should be approved (0 years experience, 3 books read) -Write-Host "" -Write-Colored "Test 1: Testing 'Enthusiastic Beginner' Profile" "YELLOW" -Write-Host "This profile represents someone new to professional cooking (0 years)" -Write-Host "but who has studied through books (3 books read)." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Italian" -experience 0 -books 3 -Show-Progress -duration 1 - -# Test 2: Should not be approved (2 years experience, 5 books read) -Write-Host "" -Write-Colored "Test 2: Testing 'Experienced Professional' Profile" "YELLOW" -Write-Host "This profile represents someone with professional experience (2 years)" -Write-Host "and theoretical knowledge (5 books read). Despite the knowledge," -Write-Host "professional experience disqualifies them." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "French" -experience 2 -books 5 -Show-Progress -duration 1 - -# Test 3: Should be approved (0 years experience, 1 book read) -Write-Host "" -Write-Colored "Test 3: Testing 'Minimal Qualifying' Profile" "YELLOW" -Write-Host "This profile represents someone meeting the minimum requirements:" -Write-Host "no professional experience and has read exactly 1 book." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Japanese" -experience 0 -books 1 -Show-Progress -duration 1 - -# Test 4: Should not be approved (0 years experience, 0 books read) -Write-Host "" -Write-Colored "Test 4: Testing 'Complete Beginner' Profile" "YELLOW" -Write-Host "This profile represents someone with no professional experience" -Write-Host "but also no theoretical knowledge (0 books read)." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Mexican" -experience 0 -books 0 -Show-Progress -duration 1 - -# Final Test: Display current members -Write-Host "" -Write-Colored "Outcome:" "YELLOW" -Write-Host "Current members grouped by their preferred cuisine." -Write-Host "Only approved applications should appear in these results." -Start-Sleep -Seconds 1 -Get-Members - -Write-Host "" -Write-Host "" -Write-Host "" -Write-Colored "Demo Completed" "GREEN" -Write-Host "==================================================" \ No newline at end of file diff --git a/local-development/docker-scripts/windows/dev_shutdown.ps1 b/local-development/docker-scripts/windows/dev_shutdown.ps1 deleted file mode 100644 index c50057f..0000000 --- a/local-development/docker-scripts/windows/dev_shutdown.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - docker compose down -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/local-development/docker-scripts/windows/dev_start.ps1 b/local-development/docker-scripts/windows/dev_start.ps1 deleted file mode 100644 index 92c0aff..0000000 --- a/local-development/docker-scripts/windows/dev_start.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - - docker compose down - docker compose up -d --build --force-recreate - - function Test-AllServicesHealthy { - $services = docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - return !($services -match "(unhealthy|starting)") - } - - while (!(Test-AllServicesHealthy)) { - Write-Host "Waiting for all services to be healthy..." - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - Write-Host "" - Start-Sleep -Seconds 5 - } - - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - - Write-Host "" - Write-Host "=======================================================================" - Write-Host "|| All services are healthy! ||" - Write-Host "=======================================================================" - Write-Host "" - - Write-Host "=======================================================================" - Write-Host "|| You can now run the dev_demo.ps1 script! ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8080 to hit your backend. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8081 to view your event store. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8082 to view your projection store. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8083 to view the email server. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8084 to view the storage server. ||" - Write-Host "=======================================================================" - -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/local-development/docker-scripts/windows/dev_start_with_data_deletion.ps1 b/local-development/docker-scripts/windows/dev_start_with_data_deletion.ps1 deleted file mode 100644 index 9502b73..0000000 --- a/local-development/docker-scripts/windows/dev_start_with_data_deletion.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - - Write-Host "Stopping existing services..." - docker compose down - - Write-Host "Cleaning up data directory..." - if (Test-Path "data") { - Get-ChildItem -Path "data" -Recurse | Remove-Item -Force -Recurse - } - - Write-Host "Starting services..." - docker compose up -d --build --force-recreate - - function Test-AllServicesHealthy { - $services = docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - return !($services -match "(unhealthy|starting)") - } - - while (!(Test-AllServicesHealthy)) { - Write-Host "Waiting for all services to be healthy..." - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - Write-Host "" - Start-Sleep -Seconds 5 - } - - docker compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - - Write-Host "" - Write-Host "=======================================================================" - Write-Host "|| All services are healthy! ||" - Write-Host "=======================================================================" - Write-Host "" - - Write-Host "=======================================================================" - Write-Host "|| You can now run the dev_demo.ps1 script! ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8080 to hit your backend. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8081 to view your event store. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8082 to view your projection store. ||" - Write-Host "=======================================================================" -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/local-development/podman-scripts/linux/dev_demo.sh b/local-development/podman-scripts/linux/dev_demo.sh deleted file mode 100755 index ecf5daf..0000000 --- a/local-development/podman-scripts/linux/dev_demo.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -set -e - -# Colors for output -GREEN='\033[0;32m' -BLUE='\033[0;34m' -RED='\033[0;31m' -NC='\033[0m' # No Color -YELLOW='\033[1;33m' - -# Arrays for random name generation -FIRST_NAMES=("James" "Mary" "John" "Patricia" "Robert" "Jennifer" "Michael" "Linda" "William" "Elizabeth" - "David" "Barbara" "Richard" "Susan" "Joseph" "Jessica" "Thomas" "Sarah" "Charles" "Karen" - "Emma" "Olivia" "Ava" "Isabella" "Sophia" "Mia" "Charlotte" "Amelia" "Harper" "Evelyn") - -LAST_NAMES=("Smith" "Johnson" "Williams" "Brown" "Jones" "Garcia" "Miller" "Davis" "Rodriguez" "Martinez" - "Hernandez" "Lopez" "Gonzalez" "Wilson" "Anderson" "Thomas" "Taylor" "Moore" "Jackson" "Martin" - "Lee" "Perez" "Thompson" "White" "Harris" "Sanchez" "Clark" "Ramirez" "Lewis" "Robinson") - -# Function to get random name from array -get_random_name() { - local array=("$@") - local index=$((RANDOM % ${#array[@]})) - echo "${array[$index]}" -} - -# Function to display progress -show_progress() { - local duration=$1 - local bar_width=40 - local sleep_interval=$(echo "scale=4; $duration / $bar_width" | bc) - local progress=0 - - echo -n "[" - while [ $progress -lt $bar_width ]; do - echo -n "=" - progress=$((progress + 1)) - sleep $sleep_interval - done - echo -n "]" - echo -} - -# Function to make a POST request with a session token -make_post_request() { - local endpoint=$1 - local data=$2 - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "X-With-Session-Token: test-session" \ - -d "$data" \ - "http://localhost:8080$endpoint" -} - -# Function to submit an application -submit_application() { - local first_name=$1 - local last_name=$2 - local cuisine=$3 - local experience=$4 - local books=$5 - - local data="{ - \"firstName\": \"$first_name\", - \"lastName\": \"$last_name\", - \"favoriteCuisine\": \"$cuisine\", - \"yearsOfProfessionalExperience\": $experience, - \"numberOfCookingBooksRead\": $books - }" - - echo -e "${BLUE}Submitting application for $first_name $last_name...${NC}" - echo -e "Profile:" - echo -e " - Cuisine: $cuisine" - echo -e " - Professional Experience: $experience years" - echo -e " - Cooking Books Read: $books" - echo -e "Expected outcome: $([ $experience == 0 ] && [ $books -gt 0 ] && echo "${GREEN}Should be APPROVED${NC}" || echo "${RED}Should be REJECTED${NC}")" - make_post_request "/api/v1/cooking-club/membership/command/submit-application" "$data" - echo -} - -# Function to get members by cuisine -get_members() { - echo -e "${BLUE}Fetching current members by cuisine...${NC}" - curl -s -X POST \ - -H "Content-Type: application/json" \ - "http://localhost:8080/api/v1/cooking-club/membership/query/members-by-cuisine" -} - -# Main test script -echo -e "${GREEN}Starting Cooking Club Application Demo${NC}" -echo "==================================================" -echo -e "${YELLOW}Application Rules:${NC}" -echo "1. Approval Criteria:" -echo " - Must have 0 years of professional experience" -echo " - Must have read at least 1 cooking book" -echo "2. All other combinations will be rejected" -echo "==================================================" - -# Test 1: Should be approved (0 years experience, 3 books read) -echo -e "\n${YELLOW}Test 1: Testing 'Enthusiastic Beginner' Profile${NC}" -echo "This profile represents someone new to professional cooking (0 years)" -echo "but who has studied through books (3 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Italian" 0 3 -show_progress 1 - -# Test 2: Should not be approved (2 years experience, 5 books read) -echo -e "\n${YELLOW}Test 2: Testing 'Experienced Professional' Profile${NC}" -echo "This profile represents someone with professional experience (2 years)" -echo "and theoretical knowledge (5 books read). Despite the knowledge," -echo "professional experience disqualifies them." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "French" 2 5 -show_progress 1 - -# Test 3: Should be approved (0 years experience, 1 book read) -echo -e "\n${YELLOW}Test 3: Testing 'Minimal Qualifying' Profile${NC}" -echo "This profile represents someone meeting the minimum requirements:" -echo "no professional experience and has read exactly 1 book." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Japanese" 0 1 -show_progress 1 - -# Test 4: Should not be approved (0 years experience, 0 books read) -echo -e "\n${YELLOW}Test 4: Testing 'Complete Beginner' Profile${NC}" -echo "This profile represents someone with no professional experience" -echo "but also no theoretical knowledge (0 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Mexican" 0 0 -show_progress 1 - -# Final Test: Display current members -echo -e "\n${YELLOW}Outcome:${NC}" -echo "Current members grouped by their preferred cuisine." -echo "Only approved applications should appear in these results." -sleep 1 -get_members -echo " " -echo " " - -echo -e "\n${GREEN}Demo Completed${NC}" -echo "==================================================" \ No newline at end of file diff --git a/local-development/podman-scripts/linux/dev_shutdown.sh b/local-development/podman-scripts/linux/dev_shutdown.sh deleted file mode 100755 index 532e29e..0000000 --- a/local-development/podman-scripts/linux/dev_shutdown.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -podman compose down \ No newline at end of file diff --git a/local-development/podman-scripts/linux/dev_start.sh b/local-development/podman-scripts/linux/dev_start.sh deleted file mode 100755 index ad44c8c..0000000 --- a/local-development/podman-scripts/linux/dev_start.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ -mkdir -p data/event-sourcing-event-bus data/event-sourcing-event-store/pg-data data/event-sourcing-projection-store/db-data data/event-sourcing-projection-store/db-config -podman compose down -podman compose up -d --build --force-recreate - -all_services_fully_healthy() { - ! podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/podman-scripts/linux/dev_start_with_data_deletion.sh b/local-development/podman-scripts/linux/dev_start_with_data_deletion.sh deleted file mode 100755 index 29e7637..0000000 --- a/local-development/podman-scripts/linux/dev_start_with_data_deletion.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -echo "Going into root mode to delete some podman volumes" -sudo echo "Root mode: OK" -podman compose down -sudo rm -Rf data/* -mkdir -p data/event-sourcing-event-bus data/event-sourcing-event-store/pg-data data/event-sourcing-projection-store/db-data data/event-sourcing-projection-store/db-config -podman compose up -d --build --force-recreate - - - -all_services_fully_healthy() { - ! podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/podman-scripts/mac/dev_demo.sh b/local-development/podman-scripts/mac/dev_demo.sh deleted file mode 100755 index ecf5daf..0000000 --- a/local-development/podman-scripts/mac/dev_demo.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -set -e - -# Colors for output -GREEN='\033[0;32m' -BLUE='\033[0;34m' -RED='\033[0;31m' -NC='\033[0m' # No Color -YELLOW='\033[1;33m' - -# Arrays for random name generation -FIRST_NAMES=("James" "Mary" "John" "Patricia" "Robert" "Jennifer" "Michael" "Linda" "William" "Elizabeth" - "David" "Barbara" "Richard" "Susan" "Joseph" "Jessica" "Thomas" "Sarah" "Charles" "Karen" - "Emma" "Olivia" "Ava" "Isabella" "Sophia" "Mia" "Charlotte" "Amelia" "Harper" "Evelyn") - -LAST_NAMES=("Smith" "Johnson" "Williams" "Brown" "Jones" "Garcia" "Miller" "Davis" "Rodriguez" "Martinez" - "Hernandez" "Lopez" "Gonzalez" "Wilson" "Anderson" "Thomas" "Taylor" "Moore" "Jackson" "Martin" - "Lee" "Perez" "Thompson" "White" "Harris" "Sanchez" "Clark" "Ramirez" "Lewis" "Robinson") - -# Function to get random name from array -get_random_name() { - local array=("$@") - local index=$((RANDOM % ${#array[@]})) - echo "${array[$index]}" -} - -# Function to display progress -show_progress() { - local duration=$1 - local bar_width=40 - local sleep_interval=$(echo "scale=4; $duration / $bar_width" | bc) - local progress=0 - - echo -n "[" - while [ $progress -lt $bar_width ]; do - echo -n "=" - progress=$((progress + 1)) - sleep $sleep_interval - done - echo -n "]" - echo -} - -# Function to make a POST request with a session token -make_post_request() { - local endpoint=$1 - local data=$2 - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "X-With-Session-Token: test-session" \ - -d "$data" \ - "http://localhost:8080$endpoint" -} - -# Function to submit an application -submit_application() { - local first_name=$1 - local last_name=$2 - local cuisine=$3 - local experience=$4 - local books=$5 - - local data="{ - \"firstName\": \"$first_name\", - \"lastName\": \"$last_name\", - \"favoriteCuisine\": \"$cuisine\", - \"yearsOfProfessionalExperience\": $experience, - \"numberOfCookingBooksRead\": $books - }" - - echo -e "${BLUE}Submitting application for $first_name $last_name...${NC}" - echo -e "Profile:" - echo -e " - Cuisine: $cuisine" - echo -e " - Professional Experience: $experience years" - echo -e " - Cooking Books Read: $books" - echo -e "Expected outcome: $([ $experience == 0 ] && [ $books -gt 0 ] && echo "${GREEN}Should be APPROVED${NC}" || echo "${RED}Should be REJECTED${NC}")" - make_post_request "/api/v1/cooking-club/membership/command/submit-application" "$data" - echo -} - -# Function to get members by cuisine -get_members() { - echo -e "${BLUE}Fetching current members by cuisine...${NC}" - curl -s -X POST \ - -H "Content-Type: application/json" \ - "http://localhost:8080/api/v1/cooking-club/membership/query/members-by-cuisine" -} - -# Main test script -echo -e "${GREEN}Starting Cooking Club Application Demo${NC}" -echo "==================================================" -echo -e "${YELLOW}Application Rules:${NC}" -echo "1. Approval Criteria:" -echo " - Must have 0 years of professional experience" -echo " - Must have read at least 1 cooking book" -echo "2. All other combinations will be rejected" -echo "==================================================" - -# Test 1: Should be approved (0 years experience, 3 books read) -echo -e "\n${YELLOW}Test 1: Testing 'Enthusiastic Beginner' Profile${NC}" -echo "This profile represents someone new to professional cooking (0 years)" -echo "but who has studied through books (3 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Italian" 0 3 -show_progress 1 - -# Test 2: Should not be approved (2 years experience, 5 books read) -echo -e "\n${YELLOW}Test 2: Testing 'Experienced Professional' Profile${NC}" -echo "This profile represents someone with professional experience (2 years)" -echo "and theoretical knowledge (5 books read). Despite the knowledge," -echo "professional experience disqualifies them." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "French" 2 5 -show_progress 1 - -# Test 3: Should be approved (0 years experience, 1 book read) -echo -e "\n${YELLOW}Test 3: Testing 'Minimal Qualifying' Profile${NC}" -echo "This profile represents someone meeting the minimum requirements:" -echo "no professional experience and has read exactly 1 book." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Japanese" 0 1 -show_progress 1 - -# Test 4: Should not be approved (0 years experience, 0 books read) -echo -e "\n${YELLOW}Test 4: Testing 'Complete Beginner' Profile${NC}" -echo "This profile represents someone with no professional experience" -echo "but also no theoretical knowledge (0 books read)." -submit_application "$(get_random_name "${FIRST_NAMES[@]}")" "$(get_random_name "${LAST_NAMES[@]}")" "Mexican" 0 0 -show_progress 1 - -# Final Test: Display current members -echo -e "\n${YELLOW}Outcome:${NC}" -echo "Current members grouped by their preferred cuisine." -echo "Only approved applications should appear in these results." -sleep 1 -get_members -echo " " -echo " " - -echo -e "\n${GREEN}Demo Completed${NC}" -echo "==================================================" \ No newline at end of file diff --git a/local-development/podman-scripts/mac/dev_shutdown.sh b/local-development/podman-scripts/mac/dev_shutdown.sh deleted file mode 100755 index 532e29e..0000000 --- a/local-development/podman-scripts/mac/dev_shutdown.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -podman compose down \ No newline at end of file diff --git a/local-development/podman-scripts/mac/dev_start.sh b/local-development/podman-scripts/mac/dev_start.sh deleted file mode 100755 index 3670547..0000000 --- a/local-development/podman-scripts/mac/dev_start.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -podman compose down -mkdir -p data/event-sourcing-event-bus data/event-sourcing-event-store/pg-data data/event-sourcing-projection-store/db-data data/event-sourcing-projection-store/db-config -podman compose up -d --build --force-recreate - -all_services_fully_healthy() { - ! podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/podman-scripts/mac/dev_start_with_data_deletion.sh b/local-development/podman-scripts/mac/dev_start_with_data_deletion.sh deleted file mode 100755 index 29e7637..0000000 --- a/local-development/podman-scripts/mac/dev_start_with_data_deletion.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -e - -cd ../../ - -echo "Going into root mode to delete some podman volumes" -sudo echo "Root mode: OK" -podman compose down -sudo rm -Rf data/* -mkdir -p data/event-sourcing-event-bus data/event-sourcing-event-store/pg-data data/event-sourcing-projection-store/db-data data/event-sourcing-projection-store/db-config -podman compose up -d --build --force-recreate - - - -all_services_fully_healthy() { - ! podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" | grep -q -E "(unhealthy|starting)" -} - -while ! all_services_fully_healthy; do - echo "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - echo "" - sleep 5 -done - -podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - -echo "" -echo "=======================================================================" -echo "|| All services are healthy! ||" -echo "=======================================================================" -echo "" - -echo "=======================================================================" -echo "|| You can now run the dev_demo.sh script! ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8080 to hit your backend. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8081 to view your event store. ||" -echo "=======================================================================" -echo "|| You can navigate to localhost:8082 to view your projection store. ||" -echo "=======================================================================" diff --git a/local-development/podman-scripts/windows/dev_demo.ps1 b/local-development/podman-scripts/windows/dev_demo.ps1 deleted file mode 100644 index 67f4df0..0000000 --- a/local-development/podman-scripts/windows/dev_demo.ps1 +++ /dev/null @@ -1,157 +0,0 @@ -$ErrorActionPreference = 'Stop' - -# Function for colored output -function Write-Colored { - param( - [string]$Text, - [string]$Color - ) - switch($Color) { - "GREEN" { Write-Host $Text -ForegroundColor Green } - "BLUE" { Write-Host $Text -ForegroundColor Blue } - "RED" { Write-Host $Text -ForegroundColor Red } - "YELLOW" { Write-Host $Text -ForegroundColor Yellow } - default { Write-Host $Text } - } -} - -# Arrays for random name generation -$FIRST_NAMES = @("James", "Mary", "John", "Patricia", "Robert", "Jennifer", "Michael", "Linda", "William", "Elizabeth", - "David", "Barbara", "Richard", "Susan", "Joseph", "Jessica", "Thomas", "Sarah", "Charles", "Karen", - "Emma", "Olivia", "Ava", "Isabella", "Sophia", "Mia", "Charlotte", "Amelia", "Harper", "Evelyn") - -$LAST_NAMES = @("Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Davis", "Rodriguez", "Martinez", - "Hernandez", "Lopez", "Gonzalez", "Wilson", "Anderson", "Thomas", "Taylor", "Moore", "Jackson", "Martin", - "Lee", "Perez", "Thompson", "White", "Harris", "Sanchez", "Clark", "Ramirez", "Lewis", "Robinson") - -# Function to get random name from array -function Get-RandomName { - param([string[]]$names) - $index = Get-Random -Minimum 0 -Maximum $names.Count - return $names[$index] -} - -# Function to display progress -function Show-Progress { - param([int]$duration) - $barWidth = 40 - $sleepInterval = $duration / $barWidth - $progress = 0 - - Write-Host -NoNewline "[" - while ($progress -lt $barWidth) { - Write-Host -NoNewline "=" - $progress++ - Start-Sleep -Milliseconds ($sleepInterval * 1000) - } - Write-Host -NoNewline "]" - Write-Host "" -} - -# Function to make a POST request with a session token -function Invoke-PostRequest { - param( - [string]$endpoint, - [string]$data - ) - $headers = @{ - "Content-Type" = "application/json" - "X-With-Session-Token" = "test-session" - } - return Invoke-RestMethod -Uri "http://localhost:8080$endpoint" -Method Post -Headers $headers -Body $data -} - -# Function to submit an application -function Submit-Application { - param( - [string]$firstName, - [string]$lastName, - [string]$cuisine, - [int]$experience, - [int]$books - ) - - $data = @{ - firstName = $firstName - lastName = $lastName - favoriteCuisine = $cuisine - yearsOfProfessionalExperience = $experience - numberOfCookingBooksRead = $books - } | ConvertTo-Json - - Write-Colored "Submitting application for $firstName $lastName..." "BLUE" - Write-Host "Profile:" - Write-Host " - Cuisine: $cuisine" - Write-Host " - Professional Experience: $experience years" - Write-Host " - Cooking Books Read: $books" - - $expectedOutcome = if ($experience -eq 0 -and $books -gt 0) { "Should be APPROVED" } else { "Should be REJECTED" } - Write-Colored "Expected outcome: $expectedOutcome" $(if ($experience -eq 0 -and $books -gt 0) { "GREEN" } else { "RED" }) - - Invoke-PostRequest -endpoint "/api/v1/cooking-club/membership/command/submit-application" -data $data - Write-Host "" -} - -# Function to get members by cuisine -function Get-Members { - Write-Colored "Fetching current members by cuisine..." "BLUE" - $response = Invoke-RestMethod -Uri "http://localhost:8080/api/v1/cooking-club/membership/query/members-by-cuisine" -Method Post -ContentType "application/json" - return $response -} - -# Main test script -Write-Colored "Starting Cooking Club Application Demo" "GREEN" -Write-Host "==================================================" -Write-Colored "Application Rules:" "YELLOW" -Write-Host "1. Approval Criteria:" -Write-Host " - Must have 0 years of professional experience" -Write-Host " - Must have read at least 1 cooking book" -Write-Host "2. All other combinations will be rejected" -Write-Host "==================================================" - -# Test 1: Should be approved (0 years experience, 3 books read) -Write-Host "" -Write-Colored "Test 1: Testing 'Enthusiastic Beginner' Profile" "YELLOW" -Write-Host "This profile represents someone new to professional cooking (0 years)" -Write-Host "but who has studied through books (3 books read)." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Italian" -experience 0 -books 3 -Show-Progress -duration 1 - -# Test 2: Should not be approved (2 years experience, 5 books read) -Write-Host "" -Write-Colored "Test 2: Testing 'Experienced Professional' Profile" "YELLOW" -Write-Host "This profile represents someone with professional experience (2 years)" -Write-Host "and theoretical knowledge (5 books read). Despite the knowledge," -Write-Host "professional experience disqualifies them." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "French" -experience 2 -books 5 -Show-Progress -duration 1 - -# Test 3: Should be approved (0 years experience, 1 book read) -Write-Host "" -Write-Colored "Test 3: Testing 'Minimal Qualifying' Profile" "YELLOW" -Write-Host "This profile represents someone meeting the minimum requirements:" -Write-Host "no professional experience and has read exactly 1 book." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Japanese" -experience 0 -books 1 -Show-Progress -duration 1 - -# Test 4: Should not be approved (0 years experience, 0 books read) -Write-Host "" -Write-Colored "Test 4: Testing 'Complete Beginner' Profile" "YELLOW" -Write-Host "This profile represents someone with no professional experience" -Write-Host "but also no theoretical knowledge (0 books read)." -Submit-Application -firstName (Get-RandomName $FIRST_NAMES) -lastName (Get-RandomName $LAST_NAMES) -cuisine "Mexican" -experience 0 -books 0 -Show-Progress -duration 1 - -# Final Test: Display current members -Write-Host "" -Write-Colored "Outcome:" "YELLOW" -Write-Host "Current members grouped by their preferred cuisine." -Write-Host "Only approved applications should appear in these results." -Start-Sleep -Seconds 1 -Get-Members - -Write-Host "" -Write-Host "" -Write-Host "" -Write-Colored "Demo Completed" "GREEN" -Write-Host "==================================================" \ No newline at end of file diff --git a/local-development/podman-scripts/windows/dev_shutdown.ps1 b/local-development/podman-scripts/windows/dev_shutdown.ps1 deleted file mode 100644 index 74463e5..0000000 --- a/local-development/podman-scripts/windows/dev_shutdown.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - podman compose down -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/local-development/podman-scripts/windows/dev_start.ps1 b/local-development/podman-scripts/windows/dev_start.ps1 deleted file mode 100644 index f25737c..0000000 --- a/local-development/podman-scripts/windows/dev_start.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - - podman compose down - - $dataDirs = @( - 'data/event-sourcing-event-bus', - 'data/event-sourcing-event-store/pg-data', - 'data/event-sourcing-projection-store/db-data', - 'data/event-sourcing-projection-store/db-config' - ) - - foreach ($dir in $dataDirs) { - New-Item -ItemType Directory -Force -Path $dir - $acl = Get-Acl $dir - $acl.SetAccessRuleProtection($true, $false) - $ownerRule = New-Object System.Security.AccessControl.FileSystemAccessRule( - [System.Security.Principal.WindowsIdentity]::GetCurrent().Name, - "FullControl", - "ContainerInherit,ObjectInherit", - "None", - "Allow" - ) - $acl.AddAccessRule($ownerRule) - $readExecuteRule = New-Object System.Security.AccessControl.FileSystemAccessRule( - "Everyone", - "ReadAndExecute", - "ContainerInherit,ObjectInherit", - "None", - "Allow" - ) - $acl.AddAccessRule($readExecuteRule) - Set-Acl $dir $acl - } - - podman compose up -d --build --force-recreate - - function Test-AllServicesHealthy { - $services = podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - return !($services -match "(unhealthy|starting)") - } - - while (!(Test-AllServicesHealthy)) { - Write-Host "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - Write-Host "" - Start-Sleep -Seconds 5 - } - - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - - Write-Host "" - Write-Host "=======================================================================" - Write-Host "|| All services are healthy! ||" - Write-Host "=======================================================================" - Write-Host "" - - Write-Host "=======================================================================" - Write-Host "|| You can now run the dev_demo.ps1 script! ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8080 to hit your backend. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8081 to view your event store. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8082 to view your projection store. ||" - Write-Host "=======================================================================" - -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/local-development/podman-scripts/windows/dev_start_with_data_deletion.ps1 b/local-development/podman-scripts/windows/dev_start_with_data_deletion.ps1 deleted file mode 100644 index 95152d7..0000000 --- a/local-development/podman-scripts/windows/dev_start_with_data_deletion.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -$ErrorActionPreference = 'Stop' -$originalLocation = Get-Location - -try { - Set-Location -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) - - Write-Host "Stopping existing services..." - podman compose down - - Write-Host "Cleaning up data directory..." - if (Test-Path "data") { - Get-ChildItem -Path "data" -Recurse | Remove-Item -Force -Recurse - } - - $dataDirs = @( - 'data/event-sourcing-event-bus', - 'data/event-sourcing-event-store/pg-data', - 'data/event-sourcing-projection-store/db-data', - 'data/event-sourcing-projection-store/db-config' - ) - - foreach ($dir in $dataDirs) { - New-Item -ItemType Directory -Force -Path $dir - $acl = Get-Acl $dir - $acl.SetAccessRuleProtection($true, $false) - $ownerRule = New-Object System.Security.AccessControl.FileSystemAccessRule( - [System.Security.Principal.WindowsIdentity]::GetCurrent().Name, - "FullControl", - "ContainerInherit,ObjectInherit", - "None", - "Allow" - ) - $acl.AddAccessRule($ownerRule) - $readExecuteRule = New-Object System.Security.AccessControl.FileSystemAccessRule( - "Everyone", - "ReadAndExecute", - "ContainerInherit,ObjectInherit", - "None", - "Allow" - ) - $acl.AddAccessRule($readExecuteRule) - Set-Acl $dir $acl - } - - Write-Host "Starting services..." - podman compose up -d --build --force-recreate - - function Test-AllServicesHealthy { - $services = podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - return !($services -match "(unhealthy|starting)") - } - - while (!(Test-AllServicesHealthy)) { - Write-Host "Waiting for all services to be healthy..." - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - Write-Host "" - Start-Sleep -Seconds 5 - } - - podman compose ps --format "table {{.ID}}\t{{.Name}}\t{{.Status}}" - - Write-Host "" - Write-Host "=======================================================================" - Write-Host "|| All services are healthy! ||" - Write-Host "=======================================================================" - Write-Host "" - - Write-Host "=======================================================================" - Write-Host "|| You can now run the dev_demo.ps1 script! ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8080 to hit your backend. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8081 to view your event store. ||" - Write-Host "=======================================================================" - Write-Host "|| You can navigate to localhost:8082 to view your projection store. ||" - Write-Host "=======================================================================" -} finally { - Set-Location -Path $originalLocation -} \ No newline at end of file diff --git a/utils.sh b/utils.sh new file mode 100755 index 0000000..ea6143a --- /dev/null +++ b/utils.sh @@ -0,0 +1,216 @@ +#!/usr/bin/env bash +set -euo pipefail + +PROJECT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd) +DEVELOPMENT_DIR="${PROJECT_ROOT}/development" +BASE_COMPOSE_FILE="${DEVELOPMENT_DIR}/docker-compose.yml" + +INFRA_SERVICES=( + event-sourcing-event-store + event-sourcing-projection-store + event-sourcing-email-server + event-sourcing-file-storage + event-sourcing-event-bus +) + +usage() { +cat <<'EOF' + Usage: ./utils.sh + + Commands: + run Start infrastructure containers and run the backend locally + infra-up Start only the supporting infrastructure containers + infra-down Stop and remove the supporting infrastructure containers + infra-status Show status for the supporting infrastructure containers + help Display this help message +EOF +} + +require_command() { + local cmd="$1" + if ! command -v "$cmd" >/dev/null 2>&1; then + echo "Error: required command '$cmd' not found in PATH." >&2 + exit 1 + fi +} + +init_compose_command() { + if docker compose version >/dev/null 2>&1; then + DOCKER_COMPOSE=(docker compose) + elif command -v docker-compose >/dev/null 2>&1; then + DOCKER_COMPOSE=(docker-compose) + else + echo "Error: docker compose is required." >&2 + exit 1 + fi +} + +compose_cmd() { + local files=( -f "${BASE_COMPOSE_FILE}" ) + "${DOCKER_COMPOSE[@]}" --project-directory "${DEVELOPMENT_DIR}" "${files[@]}" "$@" +} + +make_local_compose_override() { + require_command npx + + local tmp_override + tmp_override=$(mktemp 2>/dev/null || mktemp -t docker-compose.local.override) + + local override_json + override_json='{ + "services": { + "event-sourcing-event-store": { + "ports": [ "5432:5432" ] + }, + "event-sourcing-projection-store": { + "ports": [ "27017:27017" ] + }, + "event-sourcing-email-server": { + "ports": [ "1025:1025" ] + }, + "event-sourcing-event-bus": { + "depends_on": { + "event-sourcing-event-store": { "condition": "service_healthy" } + } + } + } + }' + + if ! echo "${override_json}" | npx yaml >"${tmp_override}" 2>/dev/null; then + echo "Error: Failed to generate docker compose override via YAML CLI." >&2 + return 1 + fi + + echo "${tmp_override}" +} + +wait_for_container() { + local container="$1" + local retries=30 + + while (( retries > 0 )); do + local status + if ! status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$container" 2>/dev/null); then + sleep 1 + ((retries--)) + continue + fi + + if [[ "$status" == "healthy" ]]; then + echo "${container} is healthy" + return 0 + elif [[ "$status" == "running" ]]; then + echo "${container} is running" + return 0 + elif [[ "$status" == "exited" ]]; then + echo "Error: ${container} has exited" >&2 + exit 1 + fi + + echo "Waiting for ${container} (status: ${status})..." + sleep 2 + ((retries--)) + done + + echo "Error: Timed out waiting for ${container} to start properly." >&2 + exit 1 +} + +wait_for_infra() { + echo "Checking container status..." + for container in "${INFRA_SERVICES[@]}"; do + wait_for_container "$container" + done + echo "" + echo "All infrastructure containers are running successfully!" +} + +start_infra() { + local local_override + local_override=$(make_local_compose_override) + + trap '[[ -n "${local_override}" && -f "${local_override}" ]] && rm -f "${local_override}"' EXIT + + compose_cmd up -d --no-deps "${INFRA_SERVICES[@]}" + wait_for_infra +} + +stop_infra() { + compose_cmd stop "${INFRA_SERVICES[@]}" >/dev/null 2>&1 || true + compose_cmd rm -f "${INFRA_SERVICES[@]}" >/dev/null 2>&1 || true +} + +infra_status() { + compose_cmd ps --format "table {{.Name}}\t{{.Status}}" +} + +run_backend() { + echo "Starting backend with local environment..." + (cd "${PROJECT_ROOT}" && npm run watch) +} + +command_run() { + start_infra + run_backend +} + +command_infra_up() { + start_infra +} + +command_infra_down() { + echo "Stopping infrastructure..." + + local local_override + local_override=$(make_local_compose_override) + trap '[[ -n "${local_override}" && -f "${local_override}" ]] && rm -f "${local_override}"' EXIT + + stop_infra + echo "Infrastructure stopped." +} + +command_infra_status() { + local local_override + local_override=$(make_local_compose_override) + trap '[[ -n "${local_override}" && -f "${local_override}" ]] && rm -f "${local_override}"' EXIT + + infra_status +} + +main() { + if [[ $# -eq 0 ]]; then + usage + exit 0 + fi + + require_command docker + init_compose_command + + local command="${1:-help}" + shift || true + + case "$command" in + run) + command_run "$@" + ;; + infra-up) + command_infra_up "$@" + ;; + infra-down) + command_infra_down "$@" + ;; + infra-status) + command_infra_status "$@" + ;; + help|--help|-h) + usage + ;; + *) + echo "Unknown command: $command" >&2 + usage + exit 1 + ;; + esac +} + +main "$@"