webupdate

This commit is contained in:
Local Server
2026-01-18 02:22:05 -06:00
parent 6fc159051a
commit 2a2a3d99e5
135 changed files with 54897 additions and 9825 deletions

212
docs/EMAIL_SETUP_GUIDE.md Normal file
View File

@@ -0,0 +1,212 @@
# 📧 Sky Art Shop - Email Configuration Guide
This guide will help you set up email sending for verification codes and newsletters.
---
## Prerequisites
- A Gmail account (recommended for simplicity)
- 2-Factor Authentication enabled on that Gmail account
---
## Step 1: Enable 2-Factor Authentication on Gmail
1. Go to: **<https://myaccount.google.com/security>**
2. Scroll to "Signing in to Google"
3. Click on **"2-Step Verification"**
4. Follow the prompts to enable it (if not already enabled)
5. Complete the setup with your phone number
---
## Step 2: Generate an App Password
1. Go to: **<https://myaccount.google.com/apppasswords>**
2. Sign in if prompted
3. At the bottom, click **"Select app"** → Choose **"Mail"**
4. Click **"Select device"** → Choose **"Other (Custom name)"**
5. Type: `Sky Art Shop`
6. Click **"Generate"**
7. You'll see a **16-character password** like: `abcd efgh ijkl mnop`
8. **COPY THIS PASSWORD** (you won't see it again!)
---
## Step 3: Configure Your Backend
### Option A: Edit .env file directly
Open the file:
```bash
nano /media/pts/Website/SkyArtShop/backend/.env
```
Find these lines at the bottom and update them:
```
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=YOUR_GMAIL@gmail.com
SMTP_PASS=YOUR_APP_PASSWORD
SMTP_FROM="Sky Art Shop" <YOUR_GMAIL@gmail.com>
```
**Replace:**
- `YOUR_GMAIL@gmail.com` → Your actual Gmail address (appears 2 times)
- `YOUR_APP_PASSWORD` → The 16-character app password (remove all spaces)
**Example** (if your email is `myshop@gmail.com` and password is `abcd efgh ijkl mnop`):
```
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=myshop@gmail.com
SMTP_PASS=abcdefghijklmnop
SMTP_FROM="Sky Art Shop" <myshop@gmail.com>
```
Save the file: `Ctrl+O`, then `Enter`, then `Ctrl+X`
---
## Step 4: Test Your Configuration
Run the test script:
```bash
cd /media/pts/Website/SkyArtShop/backend
node test-email.js your-personal-email@example.com
```
Replace `your-personal-email@example.com` with an email where you can check the inbox.
**If successful, you'll see:**
```
✅ EMAIL SENT SUCCESSFULLY!
📬 Check your inbox at: your-personal-email@example.com
```
---
## Step 5: Restart the Server
```bash
pm2 restart skyartshop
```
---
## Troubleshooting
### "Authentication failed" error
- Make sure you're using the **App Password**, not your regular Gmail password
- Check that the app password has no spaces
- Verify 2-Factor Authentication is enabled
### "Connection refused" error
- Check SMTP_HOST is exactly `smtp.gmail.com`
- Check SMTP_PORT is `587`
- Make sure your server has internet access
### Emails going to spam
- Ask recipients to mark your emails as "Not Spam"
- Add a proper SMTP_FROM name
- For production, consider using SendGrid or Mailgun
### "Less secure apps" message
- Don't enable "Less secure apps" - use App Passwords instead
- App Passwords are more secure and work better
---
## Alternative Email Services (For Production)
### SendGrid (Recommended for production)
- 100 emails/day free
- Website: <https://sendgrid.com>
```
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=apikey
SMTP_PASS=your-sendgrid-api-key
SMTP_FROM="Sky Art Shop" <noreply@yourdomain.com>
```
### Mailgun
- 5,000 emails/month free (for 3 months)
- Website: <https://mailgun.com>
### Amazon SES
- Very cheap for high volume
- Website: <https://aws.amazon.com/ses/>
---
## Quick Reference
| Setting | Gmail Value |
|---------|-------------|
| SMTP_HOST | smtp.gmail.com |
| SMTP_PORT | 587 |
| SMTP_SECURE | false |
| SMTP_USER | <your-email@gmail.com> |
| SMTP_PASS | 16-char-app-password |
---
## Files Modified
- `/backend/.env` - Contains your SMTP credentials
- `/backend/test-email.js` - Test script to verify configuration
- `/backend/routes/customer-auth.js` - Uses these settings to send verification emails
---
## What Emails Will Be Sent?
Once configured, the system will automatically send:
1. **Verification Codes** - When customers sign up
2. **Password Reset** - When customers forget their password (future feature)
3. **Newsletters** - For subscribed customers (future feature)
4. **Order Confirmations** - After purchases (future feature)
---
## Security Notes
⚠️ **Never commit your .env file to Git**
⚠️ **Never share your App Password**
⚠️ **Rotate your App Password if compromised**
The `.env` file is already in `.gitignore` so it won't be uploaded to version control.
---
## Need Help?
If you encounter issues:
1. Check the PM2 logs: `pm2 logs skyartshop`
2. Run the test script again with verbose output
3. Verify your Gmail App Password is correct
---
*Last updated: January 2026*

View File

@@ -11,21 +11,26 @@ Completed comprehensive Phase 1 frontend audit and refactoring focusing on elimi
## Problems Identified & Fixed
### 1. Duplicate Script Loading (CRITICAL BUG)
**Issue:** about.html and contact.html loaded cart.js TWICE, causing double initialization conflicts
- First load at line ~440
- Second load at line ~600
- **Impact:** Cart/wishlist required two clicks to open (one script opened, other closed it)
**Fix:**
**Fix:**
- Removed duplicate cart.js loads
- Implemented initialization check: shop-system.js sets `window.ShopSystem.isInitialized = true`
- cart.js now skips initialization if shop-system already loaded
- **Result:** Cart/wishlist now opens on first click
### 2. Inconsistent Script Loading Order
**Issue:** Every page loaded scripts in different order, causing race conditions and initialization failures
**Before:**
```
home.html: api-cache → main → shop-system → page-transitions → back-button
shop.html: api-cache → shop-system → cart → api-client → notifications → ...
@@ -35,6 +40,7 @@ about.html: page-transitions → back-button → main → navigation → cart
```
**After (Standardized):**
```
All pages now follow:
1. api-cache.js (if page makes API calls)
@@ -45,25 +51,31 @@ All pages now follow:
```
### 3. Redundant Cart Implementations
**Issue:** Cart logic existed in 3 separate places, causing conflicts and maintenance nightmares
- cart.js (ShoppingCart class, 402 lines)
- cart-functions.js (62 lines)
- shop-system.js (ShopSystem class, 731 lines)
**Fix:**
- Removed cart.js from all pages (shop.html, product.html had it)
- shop-system.js is the single source of truth for cart & wishlist
- cart.js archived (may contain useful patterns for future reference)
- cart-functions.js archived (functionality integrated into shop-system)
### 4. Obsolete "Enhanced" Files
**Issue:** Multiple versions of same functionality suggesting incomplete migrations
- main.js (11K) + main-enhanced.js (23K)
- accessibility.js (6.8K) + accessibility-enhanced.js (9.1K)
- lazy-load.js (1.9K) + lazy-load-optimized.js (5.2K)
- responsive.css (11K) + responsive-enhanced.css (7.5K) + responsive-fixes.css (9.9K)
**Fix:**
- Kept base versions (main.js, accessibility.js, responsive.css)
- Archived "enhanced" and "optimized" versions
- **Total archived:** 14 JS files + 2 CSS files
@@ -71,6 +83,7 @@ All pages now follow:
## Files Archived
### JavaScript (14 files, ~126KB)
```
assets/js/archive/
├── accessibility-enhanced.js (9.1K)
@@ -90,6 +103,7 @@ assets/js/archive/
```
### CSS (2 files, ~17KB)
```
assets/css/archive/
├── responsive-enhanced.css (7.5K)
@@ -99,6 +113,7 @@ assets/css/archive/
## Current Active Architecture
### Core JavaScript Files (9 files)
```
api-cache.js (4.5K) - API request caching and deduplication
api-client.js (2.6K) - API client utilities
@@ -111,6 +126,7 @@ shop-system.js (22K) - Cart & wishlist system (SINGLE SOURCE OF TRUTH)
```
### Core CSS Files (8 files)
```
cart-wishlist.css (4.9K) - Cart and wishlist dropdown styles
main.css (63K) ⚠️ Large file - candidate for modularization in Phase 2
@@ -123,6 +139,7 @@ theme-colors.css (9.4K) - Color palette and design tokens
```
### HTML Pages (14 pages, all standardized)
```
about.html (19K) ✅
blog.html (14K) ✅
@@ -143,6 +160,7 @@ shop.html (37K) ✅
## Script Loading Pattern (Standardized)
### Pages with API Calls (7 pages)
```html
<!-- home, shop, blog, portfolio, product, about, contact -->
<script src="/assets/js/api-cache.js"></script>
@@ -155,6 +173,7 @@ shop.html (37K) ✅
```
### Static Pages (4 pages)
```html
<!-- faq, privacy, returns, shipping-info -->
<script src="/assets/js/main.js"></script>
@@ -167,12 +186,15 @@ shop.html (37K) ✅
## Security Improvements
### Implemented
**XSS Prevention:** All user-generated content uses `escapeHtml()` before insertion
- shop-system.js: `this.escapeHtml(item.name)` for cart and wishlist items
- main.js: `window.Utils.escapeHtml()` utility available globally
- cart.js (archived): `window.Utils.escapeHtml()` used consistently
### Remaining (Phase 3)
⚠️ **CSP Headers:** Not implemented in HTML files (backend task)
⚠️ **Form Validation:** Input sanitization needed on contact form
⚠️ **localStorage Encryption:** Cart/wishlist data stored in plain text
@@ -180,12 +202,14 @@ shop.html (37K) ✅
## Performance Metrics
### Before Refactoring
- **19 total JS files** (some loaded multiple times)
- **10 total CSS files** (with duplicates)
- **Inconsistent loading order** causing race conditions
- **Double initialization** of cart/wishlist systems
### After Refactoring
- **9 active JS files** (50% reduction)
- **8 active CSS files** (20% reduction)
- **Consistent loading order** across all pages
@@ -193,6 +217,7 @@ shop.html (37K) ✅
- **14 JS + 2 CSS files archived** for reference
### Measured Improvements
- ✅ Cart/wishlist opens on first click (was 2 clicks)
- ✅ API cache loads before API calls (prevents duplicate requests)
- ✅ No JavaScript race conditions (scripts load in dependency order)
@@ -201,6 +226,7 @@ shop.html (37K) ✅
## Known Issues & Technical Debt
### High Priority (Phase 2)
1. **main.css is 63KB** - Should be modularized into:
- layout.css
- components.css
@@ -216,34 +242,39 @@ shop.html (37K) ✅
- Consolidate breakpoints
### Medium Priority (Phase 3)
4. **No CSS methodology** - Mixed approaches (BEM, utility classes, semantic)
- Establish consistent naming convention
- Document CSS architecture
5. **page-overrides.css patches** - Page-specific hacks suggest structural issues
2. **page-overrides.css patches** - Page-specific hacks suggest structural issues
- Refactor base styles to eliminate need for overrides
- Create proper component variants
6. **Version query strings inconsistent**
3. **Version query strings inconsistent**
```html
page-transitions.js?v=1766709739 (some pages)
page-transitions.js?v=1767228800 (other pages)
```
- Implement build-time cache busting
- Or use single version variable
### Low Priority (Future)
7. **shopping.js archived but may have useful patterns**
- Review archived code for useful functionality
- Document any features worth preserving
8. **cart.js had sophisticated error handling**
2. **cart.js had sophisticated error handling**
- Compare with shop-system.js implementation
- Ensure no regression in UX
## Responsive Design Analysis
### Current Breakpoints (from responsive.css)
```css
@media (max-width: 768px) /* Mobile & Tablet */
@media (max-width: 480px) /* Mobile only */
@@ -252,16 +283,20 @@ shop.html (37K) ✅
```
### Issues Identified
⚠️ **Inconsistent breakpoints** across files
- main.css has different breakpoints than responsive.css
- navbar-mobile-fix.css patches suggest responsive failures
- page-overrides.css has mobile-specific hacks
⚠️ **No tablet-specific breakpoint** (768px-1024px)
- iPad and tablets may render incorrectly
- Need dedicated tablet breakpoint
### Recommended Breakpoints (Phase 2)
```css
/* Mobile First Approach */
@media (min-width: 480px) /* Landscape phones */
@@ -273,12 +308,14 @@ shop.html (37K) ✅
## Backend Compatibility
### Verified ✅
- All API endpoints remain unchanged
- API cache still works (request deduplication)
- Backend routes unchanged
- Database queries unaffected
### Dependencies
- Backend serves static files from `/media/pts/Website/SkyArtShop/website/public/`
- Nginx configuration updated (previous fix)
- PM2 process manager untouched
@@ -287,6 +324,7 @@ shop.html (37K) ✅
## Git History
### Commits
```bash
7200bd7 - Fix double-click cart/wishlist issue: prevent duplicate initialization
0ac69e9 - Phase 1: Remove obsolete files and standardize all pages
@@ -294,6 +332,7 @@ shop.html (37K) ✅
```
### Files Changed
- **Modified:** 10 HTML files (standardized script loading)
- **Archived:** 16 files (14 JS + 2 CSS)
- **Created:** assets/js/archive/, assets/css/archive/
@@ -301,6 +340,7 @@ shop.html (37K) ✅
## Testing Recommendations
### Critical (Test Immediately)
1. **Cart functionality** on all pages
- Add to cart
- Remove from cart
@@ -322,45 +362,52 @@ shop.html (37K) ✅
- contact.html (contact info)
### Important (Test Soon)
4. **Page transitions** across all pages
5. **Back button** behavior
6. **Mobile menu** toggle
7. **Responsive behavior** at 768px, 480px breakpoints
2. **Back button** behavior
3. **Mobile menu** toggle
4. **Responsive behavior** at 768px, 480px breakpoints
### Nice to Have
8. **Browser cache** behavior after hard refresh
9. **Console errors** check
10. **Performance** metrics (load time, LCP, CLS)
2. **Console errors** check
3. **Performance** metrics (load time, LCP, CLS)
## Next Steps (Phase 2)
### Immediate
1. **Test all functionality** (see above)
2. **Monitor console for errors**
3. **Verify responsive behavior**
### Short Term (This Week)
4. **Modularize main.css** (63KB → 4x ~16KB files)
5. **Merge navbar-mobile-fix.css** into navbar.css
6. **Audit responsive.css** for duplications
7. **Eliminate page-overrides.css** by fixing root causes
2. **Merge navbar-mobile-fix.css** into navbar.css
3. **Audit responsive.css** for duplications
4. **Eliminate page-overrides.css** by fixing root causes
### Medium Term (Next Week)
8. **Establish CSS methodology** (BEM recommended)
9. **Create design system documentation**
10. **Add CSP headers** (backend task)
11. **Implement form validation** and input sanitization
12. **Add comprehensive error boundaries**
2. **Create design system documentation**
3. **Add CSP headers** (backend task)
4. **Implement form validation** and input sanitization
5. **Add comprehensive error boundaries**
### Long Term (Future)
13. **Build system** for CSS/JS minification
14. **Critical CSS** extraction
15. **Asset optimization** (images, fonts)
16. **Performance monitoring** setup
2. **Critical CSS** extraction
3. **Asset optimization** (images, fonts)
4. **Performance monitoring** setup
## Rollback Plan
If issues arise:
```bash
# Revert all Phase 1 changes
git reset --hard 7200bd7~3
@@ -372,6 +419,7 @@ git revert 7200bd7 # Revert double-click fix
```
**Archived files can be restored:**
```bash
mv assets/js/archive/* assets/js/
mv assets/css/archive/* assets/css/
@@ -380,6 +428,7 @@ mv assets/css/archive/* assets/css/
## Conclusion
Phase 1 successfully established a clean, consistent, maintainable frontend foundation by:
- ✅ Eliminating duplicate code and conflicting implementations
- ✅ Standardizing script loading order across all pages
- ✅ Archiving obsolete files while preserving them for reference

View File

@@ -0,0 +1,93 @@
# Sky Art Shop - Organized Workspace Structure
## 📁 Current Organized Structure
### Core Folders
- `backend/` - All server-side code, APIs, routes, and database logic
- `website/` - All frontend code, HTML, CSS, JavaScript, and assets
- `config/` - Configuration files (nginx, ecosystem, database)
- `scripts/` - Shell scripts and automation tools
- `docs/` - All documentation organized by category
### Documentation Organization
- `docs/database/` - Database schemas, migrations, and fixes
- `docs/frontend/` - Frontend updates, UI fixes, and styling
- `docs/mobile/` - Mobile optimizations and responsive design
- `docs/performance/` - Performance analysis and optimizations
- `docs/fixes/` - Bug fixes, refactoring, and troubleshooting
- `docs/development/` - Development logs and debug information
- `docs/project-logs/` - General project documentation and logs
### Root Level (Clean)
- `.env` - Environment configuration
- `.env.example` - Environment template
- `.gitignore` - Git ignore rules
- `README.md` - Main project documentation
- `organize-workspace.sh` - Workspace organization script
## 🎯 Organization Goals Achieved
**Separated Documentation**: All .txt and .md files moved to appropriate docs/ subfolders
**Categorized by Function**: Database, frontend, mobile, performance docs separated
**Clean Root Directory**: Only essential configuration and main files remain
**Logical Structure**: Easy to navigate and find specific documentation
**Script Organization**: All .sh files moved to scripts/ folder
## 📋 Files That Were Organized
**Database Documentation:**
- DATABASE_FIXES_SUMMARY.md
- DATABASE_QUICK_REF.md
**Frontend Documentation:**
- FRONTEND_FIXED.md
- FRONTEND_FIXES_SUMMARY.md
- MOBILE_MENU_WORKING.md
- MOBILE_NAVBAR_FIX.md
- NAVBAR_FIX_HOME_PAGE.txt
**Performance Documentation:**
- PERFORMANCE_OPTIMIZATION.md
- PERFORMANCE_QUICK_REF.md
**Fix Documentation:**
- FIXES_APPLIED.txt
- REFACTORING_COMPLETE.txt
- REFACTORING_QUICK_REF.md
- REFACTORING_SUMMARY.md
**Project Logs:**
- CACHE_SOLUTION_PERMANENT.txt
- DEEP_DEBUG_SUMMARY.txt
- DIAGNOSIS_COMPLETE.txt
- PORTFOLIO_DEBUG_COMPLETE.md
- PROBLEM_SOLVED.txt
- PROJECT_README.md
- ROOT_CAUSE_FINAL.txt
**Scripts:**
- setup-ssl.sh
- setup.sh
- test-api-performance.sh
- test-blog-drawers.sh
- test-drawers.sh
- organize-workspace.sh
## 🎉 Benefits of New Organization
1. **Easier Navigation** - Find specific documentation quickly
2. **Better Maintenance** - Logical grouping makes updates easier
3. **Clean Development** - Clutter-free root directory for better focus
4. **Team Collaboration** - Clear structure for team members
5. **Version Control** - Better git history with organized commits
The workspace is now properly organized with all files in their respective folders!