#!/usr/bin/env bash
set -euo pipefail

if [[ $# -lt 2 ]]; then
  echo "Usage: $0 <repo-root> <app-name-pascal>"
  echo "Example: $0 ~/Code/trader-app Trader"
  exit 1
fi

REPO_ROOT="$1"
APP_NAME="$2"
MAC_APP_NAME="${APP_NAME}Mac"
BACKEND_NAME="${APP_NAME}Backend"

mkdir -p "$REPO_ROOT/web"
mkdir -p "$REPO_ROOT/mac/$MAC_APP_NAME/$MAC_APP_NAME/EmbeddedBackend"
mkdir -p "$REPO_ROOT/scripts"
mkdir -p "$REPO_ROOT/docs"

cat > "$REPO_ROOT/docs/architecture.md" <<DOC
# ${APP_NAME} Architecture

- web backend source: ./web
- mac shell source: ./mac/${MAC_APP_NAME}
- embedded backend binary: ./mac/${MAC_APP_NAME}/${MAC_APP_NAME}/EmbeddedBackend/${BACKEND_NAME}
DOC

cat > "$REPO_ROOT/scripts/README.build.md" <<DOC
# Build Script Placeholders

Add:
- build_embedded_backend.sh
- build_selfcontained_mac_app.sh
- create_installer_dmg.sh
DOC

echo "Created layout for ${APP_NAME}:"
echo "- $REPO_ROOT/web"
echo "- $REPO_ROOT/mac/$MAC_APP_NAME"
echo "- $REPO_ROOT/scripts"
echo "- $REPO_ROOT/docs"
