- Move 100+ files from root to proper directories - Migration scripts → scripts/db/ - SQL files → supabase/sql/archive/ - Test/debug scripts → scripts/test/ - Documentation → docs/archive/ (organized by category) - Shell scripts → scripts/ (organized by category) - Fix test organization - Remove nested tests/unit/tests/unit/ structure - Consolidate test files to proper locations - Update documentation references - Update migration script paths in workflow docs - Update scripts/README.md with moved file notes - Delete placeholder files - Remove empty placeholder.ipynb - Result: Root directory now contains only essential config files - Result: Professional, organized codebase structure - Result: All files in proper locations per project standards See docs/CLEANUP_COMPLETE.md for full details.
13 KiB
Project Create Form Architecture
Overview
The refactored project creation form is a conversion-optimized, demo-first experience designed to minimize friction and maximize user success. It features contextual guidance, real-time feedback, and smart defaults tailored for Bitcoin-savvy users.
Philosophy
- Demo-First: Users can create and publish projects without blockers (e.g., Bitcoin address optional)
- Contextual Guidance: Just-in-time help appears based on the field being edited
- Progressive Disclosure: Advanced features hidden until needed
- Conversion-Focused: Every element serves to reduce drop-off and increase completion
File Structure
src/
├── components/
│ ├── create/
│ │ ├── guidance/
│ │ │ ├── FieldGuidance.tsx # Contextual help sidebar
│ │ │ ├── StickyProgress.tsx # Sticky progress indicator
│ │ │ ├── CurrencyConverter.tsx # BTC/SATS/Fiat converter
│ │ │ └── index.ts # Module exports
│ │ └── templates/
│ │ └── ProjectTemplates.tsx # Pre-filled examples
│ ├── wizard/
│ │ ├── ProjectWizard.tsx # Main form component (refactored)
│ │ └── ProjectWizard.tsx.backup # Original (backup)
│ └── project/
│ └── MissingWalletBanner.tsx # Post-creation wallet prompt
├── app/
│ ├── projects/create/page.tsx # Create page route
│ └── (authenticated)/project/[id]/
│ └── page.tsx # Project detail page
└── app/wallets/page.tsx # Wallet education page
Component Architecture
1. ProjectWizard (Main Form)
Path: src/components/wizard/ProjectWizard.tsx
Purpose: Main project creation form with integrated guidance system
Key Features:
- Single-page form (no wizard steps)
- Real-time validation with inline error messages
- Autosave to localStorage every 10 seconds
- Smart field focus detection for contextual help
- Template loading from URL params or user selection
State Management:
interface ProjectFormData {
title: string; // Required
description: string; // Required
goalAmount: string; // Optional
goalCurrency: 'CHF' | 'USD' | 'EUR' | 'BTC' | 'SATS';
fundingPurpose: string; // Optional
bitcoinAddress: string; // Optional (can add later)
selectedCategories: string[]; // Optional
}
Validation Rules:
- Title: 3-100 characters, required
- Description: No minimum, 2000 max, required
- Goal Amount: Positive number, optional
- Bitcoin Address: Valid format (bc1..., 1..., 3...), optional
- Other fields: Optional, no validation
2. FieldGuidance (Contextual Help)
Path: src/components/create/guidance/FieldGuidance.tsx
Purpose: Display field-specific tips, examples, and best practices
Behavior:
- Updates when user focuses on a field
- Shows relevant icon, title, description
- Displays best practices as checklist
- Provides real examples for each field
Field Types:
type FieldType =
| 'title'
| 'description'
| 'goalAmount'
| 'currency'
| 'fundingPurpose'
| 'bitcoinAddress'
| 'categories'
| null;
Example Output (Title field):
┌─────────────────────────────────┐
│ 🎯 Project Title │
│ Best Practices: │
│ ✓ Keep under 60 characters │
│ ✓ Be specific │
│ ✓ Avoid jargon │
│ │
│ Examples: │
│ • Community Garden Project │
│ • Local Animal Shelter │
└─────────────────────────────────┘
3. StickyProgress (Progress Indicator)
Path: src/components/create/guidance/StickyProgress.tsx
Purpose: Keep users aware of progress when scrolling
Behavior:
- Hidden by default
- Appears after scrolling 200px down
- Shows completion percentage
- Displays mini-checklist (desktop only)
- Replaces main header to save space
Visual Design:
┌────────────────────────────────────────────┐
│ 🎯 Create Project | 65% complete │
│ ━━━━━━━━━━━━━━━━━━━━░░░░░░░░ │
│ ✓ Title ✓ Description ○ Wallet │
└────────────────────────────────────────────┘
4. CurrencyConverter
Path: src/components/create/guidance/CurrencyConverter.tsx
Purpose: Help users understand amount equivalents across currencies
Behavior:
- Only visible when goal amount > 0
- Shows BTC, SATS, and major fiat equivalents
- Updates in real-time as user types
- Includes disclaimer about BTC-only settlement
Example:
Amount Breakdown
─────────────────
BTC: ₿ 0.05102040
SATS: 5,102,040 sats
─────────────────
USD: $5,000.00
EUR: €4,693.88
CHF: CHF 4,489.80
ⓘ Live rates. All donations settle in Bitcoin.
5. Templates (Projects, Assets, Services)
Paths:
src/components/create/templates/ProjectTemplates.tsxsrc/components/create/templates/AssetTemplates.tsxsrc/components/create/templates/ServiceTemplates.tsx
Purpose: Reduce blank-page anxiety with pre-filled examples.
Available (examples):
- Projects: Community Garden, Animal Shelter, Art Exhibition, Open Source Project
- Assets: Digital Collectible, Physical Item, Membership Pass
- Services: 1-hour Consultation, Design Sprint, Bug Fix Bundle, Copy Edit, On-site Session
Behavior:
- Displayed near the form; click to prefill form defaults.
- Non-destructive; user can edit after applying.
- Reuses
EntityForminitial values to keep DRY.
6. MissingWalletBanner
Path: src/components/project/MissingWalletBanner.tsx
Purpose: Convert demo projects into active fundraising campaigns
Visibility:
- Only shown to project owners
- Only when both
bitcoin_addressandlightning_addressare null - Dismissable (persists in session)
Actions:
- "Add Wallet Address" → Edit page
- "Get a Wallet First" → /wallets (new tab)
Visual Design:
┌──────────────────────────────────────────────┐
│ 💼 Add Your Bitcoin Address to Start │
│ Receiving Donations │
│ │
│ Your project is live, but you can't │
│ receive donations yet! │
│ │
│ [Add Wallet Address] [Get a Wallet First] │
│ │
│ ⓘ Self-custodial: No KYC, no middleman │
└──────────────────────────────────────────────┘
User Flow
Happy Path (First-Time Creator)
-
Arrive at /projects/create
- See empty form with placeholder text
- Right sidebar shows "Click on a field to get started"
-
Click on Title field
- Focus detected
- Right sidebar updates with title guidance
- User types: "Community Garden Project"
- Progress bar updates to ~30%
-
Click on Description field
- Sidebar updates with description guidance
- User writes 2-3 paragraphs
- Progress bar updates to ~70%
-
Scroll down
- Sticky progress bar appears at top
- Sidebar remains visible (sticky)
-
See template examples
- Click "Community Garden" template
- Form prefills with example content
- Toast: "Template loaded! Edit and make it yours."
- Scrolls back to top
-
Edit prefilled content
- Customize title, description
- Adjust goal amount → Currency converter appears
- Select categories
- Skip Bitcoin address (will add later)
-
Click "Create Project"
- Validation passes
- Project created with status: "active"
- Redirected to /dashboard
- Draft cleared from localStorage
-
View project
- Navigate to project page
- See MissingWalletBanner at top
- Click "Get a Wallet First" → /wallets
- Learn about wallets, choose provider
-
Add wallet
- Return to project
- Click "Add Wallet Address"
- Edit page opens
- Add Bitcoin address
- Save → Banner disappears
Technical Details
Autosave Logic
// Save draft every 10 seconds if form has content
useEffect(() => {
const interval = setInterval(() => {
const hasContent = formData.title.trim() || formData.description.trim();
if (hasContent) {
const key = isEditMode ? `project-edit-${projectId}` : 'project-draft';
localStorage.setItem(key, JSON.stringify(formData));
}
}, 10000);
return () => clearInterval(interval);
}, [formData, isEditMode, projectId]);
Field Focus Detection
const [activeField, setActiveField] = useState<FieldType>(null);
const handleFieldFocus = (field: FieldType) => {
setActiveField(field); // Triggers FieldGuidance update
};
// In JSX:
<Input
onFocus={() => handleFieldFocus('title')}
// ...
/>
Sticky Behavior
// StickyProgress component
useEffect(() => {
const handleScroll = () => {
setIsVisible(window.scrollY > 200); // Show after 200px
};
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);
Currency Conversion
// Mock rates (production: fetch from API)
const MOCK_RATES = {
BTC_TO_USD: 98000,
BTC_TO_EUR: 92000,
BTC_TO_CHF: 88000,
};
// Convert to satoshis (base unit)
const toSatoshis = (): number => {
switch (fromCurrency) {
case 'SATS':
return amount;
case 'BTC':
return amount * 100_000_000;
case 'CHF':
return (amount / rates.BTC_TO_CHF) * 100_000_000;
// ...
}
};
Best Practices
When Adding New Fields
- Update FormData interface in
ProjectWizard.tsx - Add validation in
validateField()function - Create guidance content in
FieldGuidance.tsx - Update completion logic in
getCompletionPercentage() - Add to API payload in
handleSubmit()
When Modifying Guidance
- Keep tips actionable and concise
- Use checkmarks for positive framing
- Provide 2-3 real examples
- Update all field types in
guidanceContentobject
Performance Considerations
- Autosave interval: 10 seconds (balance between UX and performance)
- Sticky threshold: 200px (appears after user commits to scrolling)
- Currency converter: Only render when amount > 0
- Template click: Smooth scroll to top (avoid jarring jump)
Integration Points
API Endpoints
POST /api/projects- Create new projectPUT /api/projects/:id- Update existing projectGET /api/projects/:id- Fetch project details
External Links
/wallets- Wallet education page (opens in new tab)/project/:id/edit- Edit project/dashboard- Post-creation redirect
LocalStorage Keys
project-draft- New project draftproject-edit-${projectId}- Edit session draft
Future Enhancements
Phase 2
- Real-time currency rate API integration
- Image upload with drag-drop
- Rich text editor for description
- Project preview modal
- A/B test description min-length requirement
Phase 3
- Lightning invoice generation
- Multi-language support
- Collaborative editing
- AI-powered title/description suggestions
Troubleshooting
Issue: Guidance not updating
Cause: activeField state not changing on focus
Fix: Ensure onFocus={() => handleFieldFocus('fieldName')} is present on all inputs
Issue: Progress bar stuck at 0%
Cause: getCompletionPercentage() logic error
Fix: Verify all field weights sum to 100
Issue: Template not loading
Cause: PROJECT_TEMPLATES import missing
Fix: Check import { PROJECT_TEMPLATES } from '@/components/create/templates/ProjectTemplates'
Issue: Banner always visible
Cause: isOwner check failing
Fix: Verify project.user_id === user?.id comparison
Maintenance
Monthly Tasks
- Review analytics for drop-off points
- Update exchange rates in
MOCK_RATES - Test autosave on slow connections
- Validate guidance content accuracy
Quarterly Tasks
- A/B test template effectiveness
- User interviews on guidance clarity
- Performance audit (bundle size, render time)
- Accessibility audit (keyboard nav, screen readers)
Contact
For questions or issues related to the create form:
- Architecture: See this document
- UX decisions: See original requirements in chat
- Code changes: Check git history for context
Last Updated: 2025-10-30 Version: 2.0 (Refactored) Status: ✅ Production Ready