updateweb

This commit is contained in:
Local Server
2026-01-18 02:24:38 -06:00
parent 2a2a3d99e5
commit 5b86f796d6
32 changed files with 502 additions and 1867 deletions

View File

@@ -0,0 +1,82 @@
#!/bin/bash
# Sky Art Shop Workspace Organization Script
# This script organizes all scattered files into their appropriate folders
echo "🔧 Organizing Sky Art Shop Workspace..."
# Create organized folder structure
mkdir -p docs/database
mkdir -p docs/frontend
mkdir -p docs/mobile
mkdir -p docs/performance
mkdir -p docs/fixes
mkdir -p docs/development
mkdir -p docs/project-logs
mkdir -p logs
# Move database related files
echo "📊 Organizing database files..."
mv DATABASE_*.* docs/database/ 2>/dev/null || true
# Move frontend related files
echo "🎨 Organizing frontend files..."
mv FRONTEND_*.* docs/frontend/ 2>/dev/null || true
mv MOBILE_*.* docs/mobile/ 2>/dev/null || true
mv NAVBAR_*.* docs/frontend/ 2>/dev/null || true
# Move performance files
echo "⚡ Organizing performance files..."
mv PERFORMANCE_*.* docs/performance/ 2>/dev/null || true
# Move fix documentation
echo "🔧 Organizing fix documentation..."
mv FIXES_*.* docs/fixes/ 2>/dev/null || true
mv *_COMPLETE.txt docs/fixes/ 2>/dev/null || true
mv REFACTORING_*.* docs/fixes/ 2>/dev/null || true
# Move general project logs
echo "📋 Organizing project logs..."
mv CACHE_*.* docs/project-logs/ 2>/dev/null || true
mv DEEP_DEBUG_*.* docs/development/ 2>/dev/null || true
mv DIAGNOSIS_*.* docs/development/ 2>/dev/null || true
mv PROJECT_README.md docs/project-logs/ 2>/dev/null || true
mv PORTFOLIO_*.* docs/project-logs/ 2>/dev/null || true
mv PROBLEM_*.* docs/project-logs/ 2>/dev/null || true
mv ROOT_CAUSE_*.* docs/project-logs/ 2>/dev/null || true
# Move any remaining .txt and .md files (except README.md)
echo "📝 Moving remaining documentation files..."
find . -maxdepth 1 -name "*.txt" ! -name "README.md" -exec mv {} docs/project-logs/ \; 2>/dev/null || true
find . -maxdepth 1 -name "*.md" ! -name "README.md" -exec mv {} docs/project-logs/ \; 2>/dev/null || true
# Move shell scripts (except this one)
echo "🔨 Organizing shell scripts..."
find . -maxdepth 1 -name "*.sh" ! -name "organize-workspace.sh" -exec mv {} scripts/ \; 2>/dev/null || true
# Clean up any corrupted files
echo "🧹 Cleaning up corrupted files..."
rm -f "t\"" "tatus" "ystemctl*" "*successfully\"" "organized*" "ac" 2>/dev/null || true
# Show final structure
echo ""
echo "✅ Workspace organization complete!"
echo ""
echo "📁 Organized Structure:"
echo "├── backend/ - Server-side code and APIs"
echo "├── website/ - Frontend code and assets"
echo "├── config/ - Configuration files"
echo "├── scripts/ - Shell scripts and automation"
echo "├── docs/"
echo "│ ├── database/ - Database related documentation"
echo "│ ├── frontend/ - Frontend fixes and updates"
echo "│ ├── mobile/ - Mobile optimization docs"
echo "│ ├── performance/ - Performance optimization docs"
echo "│ ├── fixes/ - Bug fixes and refactoring docs"
echo "│ ├── development/ - Development logs and debug info"
echo "│ └── project-logs/ - General project documentation"
echo "├── .env - Environment variables"
echo "├── .gitignore - Git ignore rules"
echo "└── README.md - Main project documentation"
echo ""
echo "🎉 All files have been organized into their respective folders!"

155
scripts/setup-ssl.sh Normal file
View File

@@ -0,0 +1,155 @@
#!/bin/bash
# SSL Setup Script for skyartshop.dynns.com
# Run this script with sudo: sudo bash setup-ssl.sh
DOMAIN="skyartshop.dynns.com"
EMAIL="your-email@example.com" # Change this to your email!
NGINX_CONF="/media/pts/Website/SkyArtShop/config/nginx-skyartshop.conf"
NGINX_ENABLED="/etc/nginx/sites-enabled/skyartshop"
NGINX_AVAILABLE="/etc/nginx/sites-available/skyartshop"
echo "=========================================="
echo " SSL Setup for $DOMAIN"
echo "=========================================="
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "❌ Please run this script with sudo:"
echo " sudo bash setup-ssl.sh"
exit 1
fi
# Step 1: Install Certbot if not installed
echo "📦 Step 1: Checking Certbot installation..."
if ! command -v certbot &> /dev/null; then
echo " Installing Certbot..."
apt update
apt install -y certbot python3-certbot-nginx
echo " ✅ Certbot installed"
else
echo " ✅ Certbot already installed"
fi
# Step 2: Create certbot webroot directory
echo ""
echo "📁 Step 2: Creating webroot directory..."
mkdir -p /var/www/certbot
echo " ✅ Directory created: /var/www/certbot"
# Step 3: Create temporary nginx config (HTTP only for initial cert)
echo ""
echo "🔧 Step 3: Setting up temporary nginx config for certificate verification..."
cat > /etc/nginx/sites-available/skyartshop-temp << 'EOF'
server {
listen 80;
listen [::]:80;
server_name skyartshop.dynns.com;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
allow all;
}
location / {
root /var/www/skyartshop/public;
index index.html;
}
}
EOF
# Disable old config and enable temp
rm -f /etc/nginx/sites-enabled/skyartshop 2>/dev/null
rm -f /etc/nginx/sites-enabled/skyartshop-temp 2>/dev/null
ln -sf /etc/nginx/sites-available/skyartshop-temp /etc/nginx/sites-enabled/skyartshop-temp
# Test and reload nginx
nginx -t && systemctl reload nginx
echo " ✅ Temporary config active"
# Step 4: Obtain SSL Certificate
echo ""
echo "🔐 Step 4: Obtaining SSL certificate from Let's Encrypt..."
echo " Domain: $DOMAIN"
echo ""
read -p "Enter your email for Let's Encrypt notifications: " USER_EMAIL
if [ -z "$USER_EMAIL" ]; then
USER_EMAIL="admin@$DOMAIN"
fi
certbot certonly --webroot \
-w /var/www/certbot \
-d $DOMAIN \
--email $USER_EMAIL \
--agree-tos \
--non-interactive \
--force-renewal
if [ $? -ne 0 ]; then
echo ""
echo "❌ Certificate generation failed!"
echo ""
echo "Troubleshooting steps:"
echo "1. Make sure your domain $DOMAIN points to this server's IP"
echo "2. Check if port 80 is open in your firewall"
echo "3. Try running: certbot certonly --standalone -d $DOMAIN"
echo ""
exit 1
fi
echo " ✅ SSL certificate obtained successfully!"
# Step 5: Install the full nginx config with SSL
echo ""
echo "🔧 Step 5: Installing production nginx configuration..."
# Remove temp config
rm -f /etc/nginx/sites-enabled/skyartshop-temp
rm -f /etc/nginx/sites-available/skyartshop-temp
# Copy and enable production config
cp "$NGINX_CONF" "$NGINX_AVAILABLE"
ln -sf "$NGINX_AVAILABLE" "$NGINX_ENABLED"
# Test nginx config
echo " Testing nginx configuration..."
nginx -t
if [ $? -eq 0 ]; then
systemctl reload nginx
echo " ✅ Nginx reloaded with SSL configuration"
else
echo " ❌ Nginx configuration test failed!"
exit 1
fi
# Step 6: Setup auto-renewal
echo ""
echo "🔄 Step 6: Setting up automatic certificate renewal..."
# Certbot auto-renewal is typically set up automatically via systemd timer
systemctl enable certbot.timer 2>/dev/null || true
systemctl start certbot.timer 2>/dev/null || true
echo " ✅ Auto-renewal configured"
# Step 7: Final verification
echo ""
echo "=========================================="
echo " ✅ SSL Setup Complete!"
echo "=========================================="
echo ""
echo "Your website is now available at:"
echo " 🔒 https://$DOMAIN"
echo ""
echo "Certificate details:"
certbot certificates --domain $DOMAIN 2>/dev/null | grep -A5 "Certificate Name"
echo ""
echo "Next steps:"
echo "1. Test your site: https://$DOMAIN"
echo "2. Test SSL: https://www.ssllabs.com/ssltest/analyze.html?d=$DOMAIN"
echo ""
echo "Certificate will auto-renew. To manually renew:"
echo " sudo certbot renew"
echo ""

113
scripts/setup.sh Executable file
View File

@@ -0,0 +1,113 @@
#!/bin/bash
# 🚀 SkyArtShop Quick Start Script
# This script sets up your development environment
set -e
echo "🎨 SkyArtShop - Production Structure Setup"
echo "=========================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_step() {
echo -e "${BLUE}${NC} $1"
}
print_success() {
echo -e "${GREEN}${NC} $1"
}
print_warning() {
echo -e "${YELLOW}${NC} $1"
}
# Check if node is installed
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed. Please install Node.js first."
exit 1
fi
print_success "Node.js version: $(node --version)"
echo ""
# Frontend Setup
print_step "Setting up Frontend..."
cd frontend
if [ ! -f ".env" ]; then
print_warning "Creating .env file from .env.example"
cp .env.example .env 2>/dev/null || echo "VITE_API_URL=http://localhost:3000/api" > .env
fi
print_step "Installing frontend dependencies..."
npm install
print_success "Frontend setup complete!"
echo ""
# Backend Setup
cd ../backend
print_step "Setting up Backend..."
if [ ! -f ".env" ]; then
print_warning "Creating .env file from .env.example"
cp .env.example .env 2>/dev/null || cat > .env << EOF
PORT=3000
NODE_ENV=development
DATABASE_URL="postgresql://user:password@localhost:5432/skyartshop?schema=public"
JWT_SECRET=$(openssl rand -base64 32 2>/dev/null || echo "change-this-secret-key-in-production")
JWT_EXPIRES_IN=7d
CORS_ORIGIN=http://localhost:5173
MAX_FILE_SIZE=5242880
EOF
print_warning "⚠️ Please update the DATABASE_URL in backend/.env with your database credentials"
fi
print_step "Installing backend dependencies..."
npm install
print_step "Generating Prisma client..."
npx prisma generate
print_success "Backend setup complete!"
echo ""
# Summary
echo "=========================================="
echo "✅ Setup Complete!"
echo "=========================================="
echo ""
echo "📝 Next Steps:"
echo ""
echo "1. Update backend/.env with your database credentials"
echo " Edit: backend/.env"
echo ""
echo "2. Run database migrations:"
echo " cd backend && npx prisma migrate dev"
echo ""
echo "3. Start development servers:"
echo ""
echo " Terminal 1 (Backend):"
echo " $ cd backend && npm run dev"
echo ""
echo " Terminal 2 (Frontend):"
echo " $ cd frontend && npm run dev"
echo ""
echo "4. Open your browser:"
echo " Frontend: http://localhost:5173"
echo " Backend: http://localhost:3000"
echo ""
echo "📚 Documentation:"
echo " - docs/ARCHITECTURE.md - Full architecture guide"
echo " - docs/STRUCTURE_COMPLETE.md - Structure overview"
echo " - frontend/readme.md - Frontend guide"
echo " - backend/readme.md - Backend guide"
echo ""
print_success "Happy coding! 🎉"

91
scripts/test-api-performance.sh Executable file
View File

@@ -0,0 +1,91 @@
#!/bin/bash
echo "=== Testing API Performance and Frontend-Backend Communication ==="
echo ""
# Test endpoints with timing
test_endpoint() {
local endpoint="$1"
local description="$2"
echo "Testing: $description"
echo "Endpoint: $endpoint"
# First request (cold)
start=$(date +%s%N)
status=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:5000$endpoint")
end=$(date +%s%N)
time_ms=$(( (end - start) / 1000000 ))
echo " ├─ HTTP Status: $status"
echo " ├─ Response Time (cold): ${time_ms}ms"
# Second request (should be cached on backend)
start=$(date +%s%N)
status2=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:5000$endpoint")
end=$(date +%s%N)
time_ms2=$(( (end - start) / 1000000 ))
echo " ├─ Response Time (warm): ${time_ms2}ms"
# Calculate improvement
if [ $time_ms -gt 0 ]; then
improvement=$(( (time_ms - time_ms2) * 100 / time_ms ))
echo " └─ Performance gain: ${improvement}%"
fi
echo ""
}
# Test all main endpoints
test_endpoint "/api/products" "All Products"
test_endpoint "/api/products/featured?limit=4" "Featured Products"
test_endpoint "/api/categories" "Categories"
test_endpoint "/api/portfolio/projects" "Portfolio Projects"
test_endpoint "/api/blog/posts" "Blog Posts"
test_endpoint "/api/pages" "Custom Pages"
# Test page loading
echo "=== Testing Page Load Times ==="
echo ""
test_page() {
local page="$1"
local description="$2"
echo "Testing: $description"
echo "Page: $page"
start=$(date +%s%N)
status=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:5000$page")
end=$(date +%s%N)
time_ms=$(( (end - start) / 1000000 ))
echo " ├─ HTTP Status: $status"
echo " └─ Load Time: ${time_ms}ms"
echo ""
}
test_page "/home" "Home Page"
test_page "/shop" "Shop Page"
test_page "/portfolio" "Portfolio Page"
test_page "/blog" "Blog Page"
echo "=== Database Index Verification ==="
PGPASSWORD=SkyArt2025Pass psql -h localhost -U skyartapp -d skyartshop -t -c "
SELECT
schemaname,
tablename,
indexname
FROM pg_indexes
WHERE schemaname = 'public'
AND indexname LIKE 'idx_%'
ORDER BY tablename, indexname;
" 2>/dev/null | head -30
echo ""
echo "=== Cache Statistics (if available) ==="
echo "Backend cache is enabled with middleware"
echo ""
echo "✅ Performance testing complete!"

79
scripts/test-blog-drawers.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
echo "==========================================="
echo " BLOG PAGE DRAWER FIX VERIFICATION"
echo "==========================================="
echo ""
# Test the blog page specifically
echo "✓ Testing Blog Page Drawer Fix..."
echo ""
# Check HTML structure
echo "1. Blog HTML Structure:"
BLOG_CART=$(curl -s http://localhost:5000/blog | grep 'class="cart-drawer"')
BLOG_WISHLIST=$(curl -s http://localhost:5000/blog | grep 'class="wishlist-drawer"')
if [ ! -z "$BLOG_CART" ] && [ ! -z "$BLOG_WISHLIST" ]; then
echo " ✓ Cart drawer: Found (no .open class)"
echo " ✓ Wishlist drawer: Found (no .open class)"
else
echo " ✗ Drawer elements not found"
fi
echo ""
echo "2. CSS Version:"
CSS_VERSION=$(curl -s http://localhost:5000/blog | grep -o 'modern-theme.css?v=[^"]*')
echo "$CSS_VERSION"
echo ""
echo "3. Cart Drawer CSS:"
CART_RIGHT=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 3 "\.cart-drawer {" | grep "right:")
CART_VIS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.cart-drawer {" | grep "visibility:")
CART_OPACITY=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.cart-drawer {" | grep "opacity:")
echo "$CART_RIGHT" | sed 's/^/ /'
echo "$CART_VIS" | sed 's/^/ /'
echo "$CART_OPACITY" | sed 's/^/ /'
echo ""
echo "4. Wishlist Drawer CSS:"
WISH_RIGHT=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 3 "\.wishlist-drawer {" | grep "right:")
WISH_VIS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.wishlist-drawer {" | grep "visibility:")
WISH_OPACITY=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.wishlist-drawer {" | grep "opacity:")
echo "$WISH_RIGHT" | sed 's/^/ /'
echo "$WISH_VIS" | sed 's/^/ /'
echo "$WISH_OPACITY" | sed 's/^/ /'
echo ""
echo "==========================================="
echo " VERIFICATION RESULT"
echo "==========================================="
if echo "$CART_RIGHT" | grep -q "right: -400px" && \
echo "$CART_VIS" | grep -q "visibility: hidden" && \
echo "$WISH_RIGHT" | grep -q "right: -400px" && \
echo "$WISH_VIS" | grep -q "visibility: hidden"; then
echo "✓ SUCCESS: Blog page drawer fix is properly applied!"
echo ""
echo "The cart and wishlist drawers on the blog page:"
echo " • Are positioned off-screen (right: -400px)"
echo " • Are hidden by default (visibility: hidden)"
echo " • Will slide in smoothly when clicked"
echo " • Have the same fix as all other pages"
else
echo "✗ ISSUE DETECTED: Some CSS properties are missing"
fi
echo ""
echo "==========================================="
echo " MANUAL VERIFICATION STEPS"
echo "==========================================="
echo "1. Open http://localhost:5000/blog in browser"
echo "2. Hard refresh: Ctrl+F5 (Windows/Linux) or Cmd+Shift+R (Mac)"
echo "3. Verify drawers are NOT visible on page load"
echo "4. Click cart icon → drawer slides in from right"
echo "5. Click wishlist icon → drawer slides in from right"
echo "6. Click outside or X button → drawers slide out"
echo "==========================================="

82
scripts/test-drawers.sh Executable file
View File

@@ -0,0 +1,82 @@
#!/bin/bash
echo "=========================================="
echo " CART & WISHLIST DRAWER TEST SUITE"
echo "=========================================="
echo ""
# Test 1: Check CSS is correct
echo "TEST 1: Verifying CSS for cart drawer..."
CART_CSS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 15 "\.cart-drawer {")
if echo "$CART_CSS" | grep -q "right: -400px" && echo "$CART_CSS" | grep -q "visibility: hidden"; then
echo "✓ PASS: Cart drawer CSS is correct (right: -400px, visibility: hidden)"
else
echo "✗ FAIL: Cart drawer CSS is incorrect"
echo "$CART_CSS"
fi
echo ""
echo "TEST 2: Verifying CSS for wishlist drawer..."
WISHLIST_CSS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 15 "\.wishlist-drawer {")
if echo "$WISHLIST_CSS" | grep -q "right: -400px" && echo "$WISHLIST_CSS" | grep -q "visibility: hidden"; then
echo "✓ PASS: Wishlist drawer CSS is correct (right: -400px, visibility: hidden)"
else
echo "✗ FAIL: Wishlist drawer CSS is incorrect"
echo "$WISHLIST_CSS"
fi
echo ""
echo "TEST 3: Checking HTML on all pages..."
for page in "" "shop" "portfolio" "about" "blog" "contact" "product"; do
CART_CLASS=$(curl -s "http://localhost:5000/${page}" 2>/dev/null | grep -o 'class="cart-drawer[^"]*"' | head -1)
WISHLIST_CLASS=$(curl -s "http://localhost:5000/${page}" 2>/dev/null | grep -o 'class="wishlist-drawer[^"]*"' | head -1)
if [[ "$CART_CLASS" == 'class="cart-drawer"' ]] && [[ "$WISHLIST_CLASS" == 'class="wishlist-drawer"' ]]; then
echo "✓ PASS: /${page} - No .open class on drawers"
else
echo "✗ FAIL: /${page} - Unexpected classes: $CART_CLASS $WISHLIST_CLASS"
fi
done
echo ""
echo "TEST 4: Verifying JavaScript files are loading..."
JS_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/assets/js/modern-theme.js)
if [ "$JS_STATUS" == "200" ]; then
echo "✓ PASS: JavaScript file loads successfully (HTTP $JS_STATUS)"
else
echo "✗ FAIL: JavaScript file failed to load (HTTP $JS_STATUS)"
fi
echo ""
echo "TEST 5: Checking mobile responsive styles..."
MOBILE_CSS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "@media (max-width: 480px)")
if echo "$MOBILE_CSS" | grep -q "width: 100%" && echo "$MOBILE_CSS" | grep -q "right: -100%"; then
echo "✓ PASS: Mobile styles correctly set (100% width, right: -100%)"
else
echo "✗ FAIL: Mobile styles are incorrect"
fi
echo ""
echo "TEST 6: Verifying PM2 process status..."
PM2_STATUS=$(pm2 jlist | jq -r '.[0].pm2_env.status')
if [ "$PM2_STATUS" == "online" ]; then
echo "✓ PASS: Server is running (status: $PM2_STATUS)"
else
echo "✗ FAIL: Server status is $PM2_STATUS"
fi
echo ""
echo "=========================================="
echo " TEST SUMMARY"
echo "=========================================="
echo "All tests completed. Review results above."
echo ""
echo "MANUAL TEST INSTRUCTIONS:"
echo "1. Open http://localhost:5000 in your browser"
echo "2. Hard refresh (Ctrl+F5 or Cmd+Shift+R)"
echo "3. Verify NO cart or wishlist visible on page load"
echo "4. Click cart icon - drawer should slide in from right"
echo "5. Click outside or close button - drawer should slide out"
echo "6. Repeat for wishlist icon"
echo "7. Test on mobile view (resize browser < 480px)"
echo "=========================================="