From 315128714afc621ccd84961668a0e6a32d1cb424 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:11:29 -0300 Subject: [PATCH 01/12] renamed local-development to development --- {local-development => development}/.gitignore | 0 .../ambar-config.yaml | 0 .../frontend-database-explorer/Dockerfile | 0 .../package-lock.json | 0 .../frontend-database-explorer/package.json | 0 .../prisma-mongodb/schema.prisma | 0 .../prisma-postgres/schema.prisma | 0 .../build-files/mongo/mongo.key | 0 .../docker-compose.yml | 0 .../docker-scripts/linux/dev_demo.sh | 138 --------------- .../docker-scripts/linux/dev_shutdown.sh | 6 - .../docker-scripts/linux/dev_start.sh | 40 ----- .../linux/dev_start_with_data_deletion.sh | 41 ----- .../docker-scripts/mac/dev_demo.sh | 138 --------------- .../docker-scripts/mac/dev_shutdown.sh | 6 - .../docker-scripts/mac/dev_start.sh | 40 ----- .../mac/dev_start_with_data_deletion.sh | 41 ----- .../docker-scripts/windows/dev_demo.ps1 | 157 ------------------ .../docker-scripts/windows/dev_shutdown.ps1 | 9 - .../docker-scripts/windows/dev_start.ps1 | 46 ----- .../windows/dev_start_with_data_deletion.ps1 | 49 ------ .../podman-scripts/linux/dev_demo.sh | 138 --------------- .../podman-scripts/linux/dev_shutdown.sh | 6 - .../podman-scripts/linux/dev_start.sh | 36 ---- .../linux/dev_start_with_data_deletion.sh | 42 ----- .../podman-scripts/mac/dev_demo.sh | 138 --------------- .../podman-scripts/mac/dev_shutdown.sh | 6 - .../podman-scripts/mac/dev_start.sh | 37 ----- .../mac/dev_start_with_data_deletion.sh | 42 ----- .../podman-scripts/windows/dev_demo.ps1 | 157 ------------------ .../podman-scripts/windows/dev_shutdown.ps1 | 9 - .../podman-scripts/windows/dev_start.ps1 | 73 -------- .../windows/dev_start_with_data_deletion.ps1 | 79 --------- 33 files changed, 1474 deletions(-) rename {local-development => development}/.gitignore (100%) rename {local-development => development}/ambar-config.yaml (100%) rename {local-development => development}/build-files/frontend-database-explorer/Dockerfile (100%) rename {local-development => development}/build-files/frontend-database-explorer/package-lock.json (100%) rename {local-development => development}/build-files/frontend-database-explorer/package.json (100%) rename {local-development => development}/build-files/frontend-database-explorer/prisma-mongodb/schema.prisma (100%) rename {local-development => development}/build-files/frontend-database-explorer/prisma-postgres/schema.prisma (100%) rename {local-development => development}/build-files/mongo/mongo.key (100%) rename {local-development => development}/docker-compose.yml (100%) delete mode 100755 local-development/docker-scripts/linux/dev_demo.sh delete mode 100755 local-development/docker-scripts/linux/dev_shutdown.sh delete mode 100755 local-development/docker-scripts/linux/dev_start.sh delete mode 100755 local-development/docker-scripts/linux/dev_start_with_data_deletion.sh delete mode 100755 local-development/docker-scripts/mac/dev_demo.sh delete mode 100755 local-development/docker-scripts/mac/dev_shutdown.sh delete mode 100755 local-development/docker-scripts/mac/dev_start.sh delete mode 100755 local-development/docker-scripts/mac/dev_start_with_data_deletion.sh delete mode 100644 local-development/docker-scripts/windows/dev_demo.ps1 delete mode 100644 local-development/docker-scripts/windows/dev_shutdown.ps1 delete mode 100644 local-development/docker-scripts/windows/dev_start.ps1 delete mode 100644 local-development/docker-scripts/windows/dev_start_with_data_deletion.ps1 delete mode 100755 local-development/podman-scripts/linux/dev_demo.sh delete mode 100755 local-development/podman-scripts/linux/dev_shutdown.sh delete mode 100755 local-development/podman-scripts/linux/dev_start.sh delete mode 100755 local-development/podman-scripts/linux/dev_start_with_data_deletion.sh delete mode 100755 local-development/podman-scripts/mac/dev_demo.sh delete mode 100755 local-development/podman-scripts/mac/dev_shutdown.sh delete mode 100755 local-development/podman-scripts/mac/dev_start.sh delete mode 100755 local-development/podman-scripts/mac/dev_start_with_data_deletion.sh delete mode 100644 local-development/podman-scripts/windows/dev_demo.ps1 delete mode 100644 local-development/podman-scripts/windows/dev_shutdown.ps1 delete mode 100644 local-development/podman-scripts/windows/dev_start.ps1 delete mode 100644 local-development/podman-scripts/windows/dev_start_with_data_deletion.ps1 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/local-development/docker-scripts/linux/dev_demo.sh b/local-development/docker-scripts/linux/dev_demo.sh deleted file mode 100755 index ecf5daf..0000000 --- a/local-development/docker-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/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.sh b/local-development/docker-scripts/mac/dev_start.sh deleted file mode 100755 index 0859a38..0000000 --- a/local-development/docker-scripts/mac/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 "=======================================================================" 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 From d9d519d8afc7a932fd6e277d5dcb124c5f495d1e Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:11:49 -0300 Subject: [PATCH 02/12] update ignore patterns for renamed development directory --- .dockerignore | 2 +- .prettierignore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 99af17e10c0aba18efc63cd01841c0401ceea49d Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:12:08 -0300 Subject: [PATCH 03/12] add erase script to stop services and clear development data --- development/scripts/erase.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 development/scripts/erase.sh 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 "=======================================================================" From b2464b66a3a51b2d04ed6bd39365108dbcb0da12 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:12:16 -0300 Subject: [PATCH 04/12] add shutdown script for development docker compose --- development/scripts/shutdown.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 development/scripts/shutdown.sh 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 From dfe9a8f2744acc16e4032e04f02d2a6a8701e0bb Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:12:27 -0300 Subject: [PATCH 05/12] add startup script for development environment with docker compose and health checks --- development/scripts/start.sh | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 development/scripts/start.sh diff --git a/development/scripts/start.sh b/development/scripts/start.sh new file mode 100755 index 0000000..0e8289a --- /dev/null +++ b/development/scripts/start.sh @@ -0,0 +1,43 @@ +#!/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 +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 "=======================================================================" From 1ba28fb8d965cedb30c6cf17b08e20bca9e455be Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Thu, 25 Sep 2025 16:12:35 -0300 Subject: [PATCH 06/12] add demo script for testing cooking club application approval --- development/scripts/test.sh | 138 ++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 development/scripts/test.sh diff --git a/development/scripts/test.sh b/development/scripts/test.sh new file mode 100755 index 0000000..ecf5daf --- /dev/null +++ b/development/scripts/test.sh @@ -0,0 +1,138 @@ +#!/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 From 82f25670f5862c5e87f0d73c393e5e7d91dbf9ea Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 12:23:49 -0300 Subject: [PATCH 07/12] add yaml dev dependency --- package-lock.json | 16 +++++++++++++++- package.json | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 11c8d06..90f2517 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,8 @@ "prettier": "^3.0.0", "tsconfig-paths": "^4.2.0", "tsx": "^4.20.5", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "yaml": "^2.6.1" } }, "node_modules/@aws-crypto/sha256-browser": { @@ -4736,6 +4737,19 @@ "node": ">=0.4" } }, + "node_modules/yaml": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + } + }, "node_modules/zod": { "version": "3.24.1", "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz", diff --git a/package.json b/package.json index 8ef9749..80d2629 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "prettier": "^3.0.0", "tsconfig-paths": "^4.2.0", "tsx": "^4.20.5", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "yaml": "^2.6.1" } } From 387a829ed1f7ae9d2acbb2a89efe17cf644aa124 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 12:24:09 -0300 Subject: [PATCH 08/12] updated postgres initialization with error handling, add direct mongodb connection, and fix top-level async execution --- src/app/postgresEventStore.ts | 15 +++++++++++---- src/di/container.ts | 2 +- src/index.ts | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/app/postgresEventStore.ts b/src/app/postgresEventStore.ts index 6d42f1f..a71ef8c 100644 --- a/src/app/postgresEventStore.ts +++ b/src/app/postgresEventStore.ts @@ -173,10 +173,17 @@ async function initialize({ replicationUserPass: string; replicationPublication: string; }): Promise { - function run(description: string, query: string) { - log.info(description); - log.info(query); - return transaction.query(query); + async function run(description: string, query: string): Promise { + try { + log.info(description); + log.info(query); + await transaction.query(query); + } catch (error) { + log.warn( + 'Caught exception when executing SQL statement.', + error as Error, + ); + } } await run( diff --git a/src/di/container.ts b/src/di/container.ts index e8f90b2..eef160b 100644 --- a/src/di/container.ts +++ b/src/di/container.ts @@ -53,7 +53,7 @@ function registerEnvironmentVariables() { `mongodb://${env.MONGODB_PROJECTION_DATABASE_USERNAME}:${env.MONGODB_PROJECTION_DATABASE_PASSWORD}@` + `${env.MONGODB_PROJECTION_HOST}:${env.MONGODB_PROJECTION_PORT}/` + `${env.MONGODB_PROJECTION_DATABASE_NAME}` + - '?serverSelectionTimeoutMS=10000&connectTimeoutMS=10000&authSource=admin'; + '?serverSelectionTimeoutMS=10000&connectTimeoutMS=10000&authSource=admin&directConnection=true'; const mongoDatabaseName = env.MONGODB_PROJECTION_DATABASE_NAME; container.register('mongoConnectionString', { useValue: mongoConnectionString, diff --git a/src/index.ts b/src/index.ts index 5397ce9..bbc5932 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,4 +91,4 @@ async function main() { }); } -await main(); +(async () => { await main() })(); From 5c5d481c8e4e785c43b3970e05237c60d48c7689 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 12:24:17 -0300 Subject: [PATCH 09/12] add utils.sh script to manage local development infrastructure and backend startup --- utils.sh | 330 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100755 utils.sh diff --git a/utils.sh b/utils.sh new file mode 100755 index 0000000..c276d52 --- /dev/null +++ b/utils.sh @@ -0,0 +1,330 @@ +#!/usr/bin/env bash +set -euo pipefail + +PROJECT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd) +DEV_DIR="${PROJECT_ROOT}/development" + +BASE_COMPOSE_FILE="${DEV_DIR}/docker-compose.yml" +OVERRIDE_COMPOSE_FILE="" # set when running locally + +INFRA_SERVICES=( + event-sourcing-backend-proxy + 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 [options] + + Options: + -q, --quiet Suppress verbose output from docker and services + -v, --verbose Enable verbose output (default) + --log-level Set backend log level (error|warn|info|debug, default: info) + + 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}" ) + if [[ -n "${OVERRIDE_COMPOSE_FILE}" && -f "${OVERRIDE_COMPOSE_FILE}" ]]; then + files+=( -f "${OVERRIDE_COMPOSE_FILE}" ) + fi + "${DOCKER_COMPOSE[@]}" --project-directory "${DEV_DIR}" "${files[@]}" "$@" +} + +load_docker_compose_env() { + # Load environment variables from docker-compose.yml + local compose_file="development/docker-compose.yml" + + if [[ ! -f "${compose_file}" ]]; then + echo "Error: Docker compose file not found at ${compose_file}" >&2 + return 1 + fi + + # Check if required tools are available + if ! command -v npx >/dev/null 2>&1; then + echo "Error: npx not found. Please ensure Node.js is installed." >&2 + return 1 + fi + + if ! command -v jq >/dev/null 2>&1; then + echo "Error: jq not found. Please install jq for JSON processing." >&2 + return 1 + fi + + # Extract environment variables from docker-compose.yml + local env_vars + env_vars=$(npx yaml --json < "${compose_file}" 2>/dev/null | \ + jq -r '.[0].services."event-sourcing-backend".environment | to_entries[] | "\(.key)=\(.value)"' 2>/dev/null) + + if [[ $? -ne 0 || -z "$env_vars" ]]; then + echo "Error: Failed to parse docker-compose.yml or extract environment variables." >&2 + return 1 + fi + + # Process and export each environment variable + while IFS= read -r line || [[ -n "$line" ]]; do + # Skip empty lines + [[ -z "$line" ]] && continue + + # Parse KEY=VALUE format + if [[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then + local key="${BASH_REMATCH[1]}" + local value="${BASH_REMATCH[2]}" + + # Remove surrounding quotes if present + if [[ "$value" =~ ^[\"\'](.*)[\"\']$ ]]; then + value="${BASH_REMATCH[1]}" + fi + + export "$key"="$value" + fi + done <<< "$env_vars" +} + +set_backend_env() { + export NODE_ENV="${NODE_ENV:-development}" + + export AMBAR_HTTP_USERNAME="${AMBAR_HTTP_USERNAME:-username}" + export AMBAR_HTTP_PASSWORD="${AMBAR_HTTP_PASSWORD:-password}" + + export EVENT_STORE_HOST="${EVENT_STORE_HOST:-localhost}" + export EVENT_STORE_PORT="${EVENT_STORE_PORT:-5432}" + export EVENT_STORE_DATABASE_NAME="${EVENT_STORE_DATABASE_NAME:-my_es_database}" + export EVENT_STORE_USER="${EVENT_STORE_USER:-my_es_username}" + export EVENT_STORE_PASSWORD="${EVENT_STORE_PASSWORD:-my_es_password}" + export EVENT_STORE_CREATE_TABLE_WITH_NAME="${EVENT_STORE_CREATE_TABLE_WITH_NAME:-event_store}" + export EVENT_STORE_CREATE_REPLICATION_USER_WITH_USERNAME="${EVENT_STORE_CREATE_REPLICATION_USER_WITH_USERNAME:-replication_username}" + export EVENT_STORE_CREATE_REPLICATION_USER_WITH_PASSWORD="${EVENT_STORE_CREATE_REPLICATION_USER_WITH_PASSWORD:-replication_password}" + export EVENT_STORE_CREATE_REPLICATION_PUBLICATION="${EVENT_STORE_CREATE_REPLICATION_PUBLICATION:-replication_publication}" + + export MONGODB_PROJECTION_DATABASE_USERNAME="${MONGODB_PROJECTION_DATABASE_USERNAME:-my_mongo_username}" + export MONGODB_PROJECTION_DATABASE_PASSWORD="${MONGODB_PROJECTION_DATABASE_PASSWORD:-my_mongo_password}" + export MONGODB_PROJECTION_HOST="${MONGODB_PROJECTION_HOST:-localhost}" + export MONGODB_PROJECTION_PORT="${MONGODB_PROJECTION_PORT:-27017}" + export MONGODB_PROJECTION_DATABASE_NAME="${MONGODB_PROJECTION_DATABASE_NAME:-projections}" + + export SMTP_HOST="${SMTP_HOST:-localhost}" + export SMTP_PORT="${SMTP_PORT:-1025}" + export SMTP_USERNAME="${SMTP_USERNAME:-smtp_username}" + export SMTP_PASSWORD="${SMTP_PASSWORD:-smtp_password}" + export SMTP_FROM_EMAIL="${SMTP_FROM_EMAIL:-no-reply@example.localdevelopment}" + + export S3_ENDPOINT_URL="${S3_ENDPOINT_URL:-http://localhost:7999}" + export S3_ACCESS_KEY="${S3_ACCESS_KEY:-user}" + export S3_SECRET_KEY="${S3_SECRET_KEY:-password}" + export S3_BUCKET_NAME="${S3_BUCKET_NAME:-administrator-files}" + export S3_REGION="${S3_REGION:-us-east-1}" +} + +# Build a temporary compose override that: +# - Publishes DB ports for local connections +# - Adds host alias inside event-bus +# - Adds a backend proxy container to forward to host backend +make_local_compose_override() { + local tmp_override + # Create a unique temporary file in a cross-platform way + tmp_override=$(mktemp 2>/dev/null || mktemp -t docker-compose.local.override) + cat >"${tmp_override}" < 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 + # For containers without health checks, running is sufficient + 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) + OVERRIDE_COMPOSE_FILE="${local_override}" + + # Cleanup temporary override on exit + trap '[[ -n "${OVERRIDE_COMPOSE_FILE}" && -f "${OVERRIDE_COMPOSE_FILE}" ]] && rm -f "${OVERRIDE_COMPOSE_FILE}"' EXIT + + # Start only the infra services, ignoring backend deps + 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 "Loading environment variables from docker-compose.yml..." + load_docker_compose_env + + # Override database hosts for local development + export EVENT_STORE_HOST="localhost" + export MONGODB_PROJECTION_HOST="localhost" + export SMTP_HOST="localhost" + export S3_ENDPOINT_URL="http://localhost:7999" + + set_backend_env + echo "Starting backend with local environment..." + (cd "${PROJECT_ROOT}" && npm run start) +} + +command_run() { + start_infra + echo "Infrastructure is ready." + echo "Press Ctrl+C to stop the backend. Infrastructure containers will keep running." + run_backend +} + +command_infra_up() { + start_infra +} + +command_infra_down() { + # Ensure override exists so compose knows about the proxy service + local local_override + local_override=$(make_local_compose_override) + OVERRIDE_COMPOSE_FILE="${local_override}" + trap '[[ -n "${OVERRIDE_COMPOSE_FILE}" && -f "${OVERRIDE_COMPOSE_FILE}" ]] && rm -f "${OVERRIDE_COMPOSE_FILE}"' EXIT + + stop_infra + echo "Infrastructure stopped." +} + +command_infra_status() { + # Ensure override exists so compose is aware of all services + local local_override + local_override=$(make_local_compose_override) + OVERRIDE_COMPOSE_FILE="${local_override}" + trap '[[ -n "${OVERRIDE_COMPOSE_FILE}" && -f "${OVERRIDE_COMPOSE_FILE}" ]] && rm -f "${OVERRIDE_COMPOSE_FILE}"' EXIT + + infra_status +} + +main() { + 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 "$@" From 08649c83341ddb1dbbf77da7e592e8b918b12e3c Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 14:38:26 -0300 Subject: [PATCH 10/12] refactor sql initialization to propagate errors, remove directconnection from mongodb uri, and use top-level await --- src/app/postgresEventStore.ts | 15 ++++----------- src/di/container.ts | 2 +- src/index.ts | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/app/postgresEventStore.ts b/src/app/postgresEventStore.ts index a71ef8c..6d42f1f 100644 --- a/src/app/postgresEventStore.ts +++ b/src/app/postgresEventStore.ts @@ -173,17 +173,10 @@ async function initialize({ replicationUserPass: string; replicationPublication: string; }): Promise { - async function run(description: string, query: string): Promise { - try { - log.info(description); - log.info(query); - await transaction.query(query); - } catch (error) { - log.warn( - 'Caught exception when executing SQL statement.', - error as Error, - ); - } + function run(description: string, query: string) { + log.info(description); + log.info(query); + return transaction.query(query); } await run( diff --git a/src/di/container.ts b/src/di/container.ts index eef160b..e8f90b2 100644 --- a/src/di/container.ts +++ b/src/di/container.ts @@ -53,7 +53,7 @@ function registerEnvironmentVariables() { `mongodb://${env.MONGODB_PROJECTION_DATABASE_USERNAME}:${env.MONGODB_PROJECTION_DATABASE_PASSWORD}@` + `${env.MONGODB_PROJECTION_HOST}:${env.MONGODB_PROJECTION_PORT}/` + `${env.MONGODB_PROJECTION_DATABASE_NAME}` + - '?serverSelectionTimeoutMS=10000&connectTimeoutMS=10000&authSource=admin&directConnection=true'; + '?serverSelectionTimeoutMS=10000&connectTimeoutMS=10000&authSource=admin'; const mongoDatabaseName = env.MONGODB_PROJECTION_DATABASE_NAME; container.register('mongoConnectionString', { useValue: mongoConnectionString, diff --git a/src/index.ts b/src/index.ts index bbc5932..5397ce9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,4 +91,4 @@ async function main() { }); } -(async () => { await main() })(); +await main(); From 4afb7947d38e7998aa8121e5a512583941a09cb0 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 14:48:28 -0300 Subject: [PATCH 11/12] remove unused yaml dependency --- package-lock.json | 16 +--------------- package.json | 3 +-- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 90f2517..11c8d06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,8 +31,7 @@ "prettier": "^3.0.0", "tsconfig-paths": "^4.2.0", "tsx": "^4.20.5", - "typescript": "^5.1.6", - "yaml": "^2.6.1" + "typescript": "^5.1.6" } }, "node_modules/@aws-crypto/sha256-browser": { @@ -4737,19 +4736,6 @@ "node": ">=0.4" } }, - "node_modules/yaml": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", - "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", - "dev": true, - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - } - }, "node_modules/zod": { "version": "3.24.1", "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz", diff --git a/package.json b/package.json index 80d2629..8ef9749 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "prettier": "^3.0.0", "tsconfig-paths": "^4.2.0", "tsx": "^4.20.5", - "typescript": "^5.1.6", - "yaml": "^2.6.1" + "typescript": "^5.1.6" } } From 43830172e4dd898f76de585140cc01988a313377 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Fri, 26 Sep 2025 15:10:27 -0300 Subject: [PATCH 12/12] simplify utils.sh by removing backend proxy, env loading, and cli options --- utils.sh | 196 ++++++++++++------------------------------------------- 1 file changed, 41 insertions(+), 155 deletions(-) diff --git a/utils.sh b/utils.sh index c276d52..ea6143a 100755 --- a/utils.sh +++ b/utils.sh @@ -2,13 +2,10 @@ set -euo pipefail PROJECT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd) -DEV_DIR="${PROJECT_ROOT}/development" - -BASE_COMPOSE_FILE="${DEV_DIR}/docker-compose.yml" -OVERRIDE_COMPOSE_FILE="" # set when running locally +DEVELOPMENT_DIR="${PROJECT_ROOT}/development" +BASE_COMPOSE_FILE="${DEVELOPMENT_DIR}/docker-compose.yml" INFRA_SERVICES=( - event-sourcing-backend-proxy event-sourcing-event-store event-sourcing-projection-store event-sourcing-email-server @@ -18,12 +15,7 @@ INFRA_SERVICES=( usage() { cat <<'EOF' - Usage: ./utils.sh [options] - - Options: - -q, --quiet Suppress verbose output from docker and services - -v, --verbose Enable verbose output (default) - --log-level Set backend log level (error|warn|info|debug, default: info) + Usage: ./utils.sh Commands: run Start infrastructure containers and run the backend locally @@ -55,133 +47,40 @@ init_compose_command() { compose_cmd() { local files=( -f "${BASE_COMPOSE_FILE}" ) - if [[ -n "${OVERRIDE_COMPOSE_FILE}" && -f "${OVERRIDE_COMPOSE_FILE}" ]]; then - files+=( -f "${OVERRIDE_COMPOSE_FILE}" ) - fi - "${DOCKER_COMPOSE[@]}" --project-directory "${DEV_DIR}" "${files[@]}" "$@" + "${DOCKER_COMPOSE[@]}" --project-directory "${DEVELOPMENT_DIR}" "${files[@]}" "$@" } -load_docker_compose_env() { - # Load environment variables from docker-compose.yml - local compose_file="development/docker-compose.yml" - - if [[ ! -f "${compose_file}" ]]; then - echo "Error: Docker compose file not found at ${compose_file}" >&2 - return 1 - fi - - # Check if required tools are available - if ! command -v npx >/dev/null 2>&1; then - echo "Error: npx not found. Please ensure Node.js is installed." >&2 - return 1 - fi - - if ! command -v jq >/dev/null 2>&1; then - echo "Error: jq not found. Please install jq for JSON processing." >&2 - return 1 - fi +make_local_compose_override() { + require_command npx - # Extract environment variables from docker-compose.yml - local env_vars - env_vars=$(npx yaml --json < "${compose_file}" 2>/dev/null | \ - jq -r '.[0].services."event-sourcing-backend".environment | to_entries[] | "\(.key)=\(.value)"' 2>/dev/null) + local tmp_override + tmp_override=$(mktemp 2>/dev/null || mktemp -t docker-compose.local.override) - if [[ $? -ne 0 || -z "$env_vars" ]]; then - echo "Error: Failed to parse docker-compose.yml or extract environment variables." >&2 + 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 - # Process and export each environment variable - while IFS= read -r line || [[ -n "$line" ]]; do - # Skip empty lines - [[ -z "$line" ]] && continue - - # Parse KEY=VALUE format - if [[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then - local key="${BASH_REMATCH[1]}" - local value="${BASH_REMATCH[2]}" - - # Remove surrounding quotes if present - if [[ "$value" =~ ^[\"\'](.*)[\"\']$ ]]; then - value="${BASH_REMATCH[1]}" - fi - - export "$key"="$value" - fi - done <<< "$env_vars" -} - -set_backend_env() { - export NODE_ENV="${NODE_ENV:-development}" - - export AMBAR_HTTP_USERNAME="${AMBAR_HTTP_USERNAME:-username}" - export AMBAR_HTTP_PASSWORD="${AMBAR_HTTP_PASSWORD:-password}" - - export EVENT_STORE_HOST="${EVENT_STORE_HOST:-localhost}" - export EVENT_STORE_PORT="${EVENT_STORE_PORT:-5432}" - export EVENT_STORE_DATABASE_NAME="${EVENT_STORE_DATABASE_NAME:-my_es_database}" - export EVENT_STORE_USER="${EVENT_STORE_USER:-my_es_username}" - export EVENT_STORE_PASSWORD="${EVENT_STORE_PASSWORD:-my_es_password}" - export EVENT_STORE_CREATE_TABLE_WITH_NAME="${EVENT_STORE_CREATE_TABLE_WITH_NAME:-event_store}" - export EVENT_STORE_CREATE_REPLICATION_USER_WITH_USERNAME="${EVENT_STORE_CREATE_REPLICATION_USER_WITH_USERNAME:-replication_username}" - export EVENT_STORE_CREATE_REPLICATION_USER_WITH_PASSWORD="${EVENT_STORE_CREATE_REPLICATION_USER_WITH_PASSWORD:-replication_password}" - export EVENT_STORE_CREATE_REPLICATION_PUBLICATION="${EVENT_STORE_CREATE_REPLICATION_PUBLICATION:-replication_publication}" - - export MONGODB_PROJECTION_DATABASE_USERNAME="${MONGODB_PROJECTION_DATABASE_USERNAME:-my_mongo_username}" - export MONGODB_PROJECTION_DATABASE_PASSWORD="${MONGODB_PROJECTION_DATABASE_PASSWORD:-my_mongo_password}" - export MONGODB_PROJECTION_HOST="${MONGODB_PROJECTION_HOST:-localhost}" - export MONGODB_PROJECTION_PORT="${MONGODB_PROJECTION_PORT:-27017}" - export MONGODB_PROJECTION_DATABASE_NAME="${MONGODB_PROJECTION_DATABASE_NAME:-projections}" - - export SMTP_HOST="${SMTP_HOST:-localhost}" - export SMTP_PORT="${SMTP_PORT:-1025}" - export SMTP_USERNAME="${SMTP_USERNAME:-smtp_username}" - export SMTP_PASSWORD="${SMTP_PASSWORD:-smtp_password}" - export SMTP_FROM_EMAIL="${SMTP_FROM_EMAIL:-no-reply@example.localdevelopment}" - - export S3_ENDPOINT_URL="${S3_ENDPOINT_URL:-http://localhost:7999}" - export S3_ACCESS_KEY="${S3_ACCESS_KEY:-user}" - export S3_SECRET_KEY="${S3_SECRET_KEY:-password}" - export S3_BUCKET_NAME="${S3_BUCKET_NAME:-administrator-files}" - export S3_REGION="${S3_REGION:-us-east-1}" -} - -# Build a temporary compose override that: -# - Publishes DB ports for local connections -# - Adds host alias inside event-bus -# - Adds a backend proxy container to forward to host backend -make_local_compose_override() { - local tmp_override - # Create a unique temporary file in a cross-platform way - tmp_override=$(mktemp 2>/dev/null || mktemp -t docker-compose.local.override) - cat >"${tmp_override}" <