mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-06 05:37:53 +01:00
- Add public profile route at /profiles/[username] with server-side rendering - Convert project pages to Server Components with generateMetadata for SEO - Add Open Graph and Twitter Card metadata for social media previews - Fix middleware to allow public access to /profiles/ and /projects/ routes - Add PublicProfileClient and ProjectPageClient components for interactivity - Update route constants with PROFILES.VIEW(username) for public profiles - Add 404 pages for profiles and projects - Deprecate SocialMetaTags component (replaced with generateMetadata API) - Fix database field name mapping (name vs display_name) - Add comprehensive testing scripts and documentation - Fix missing Link import in UnifiedHeader This enables users to share their profiles and projects on social media with proper preview cards (no more 'Loading...' on Twitter/Facebook). Phase 1 complete - ready for production deployment.
5.1 KiB
5.1 KiB
Projects Table Schema
Database Schema
The projects table is the unified entity for all Bitcoin fundraising initiatives.
Required Columns
id(uuid, PRIMARY KEY) - Unique project identifieruser_id(uuid, NOT NULL) - Referencesauth.users(id)- Owner of the projecttitle(text, NOT NULL) - Project title/namedescription(text, NOT NULL) - Project descriptionstatus(text, DEFAULT 'draft') - Project status: 'draft', 'active', 'paused'created_at(timestamp) - Creation timestampupdated_at(timestamp) - Last update timestamp
Optional Columns
goal_amount(numeric(20,8), nullable) - Funding goal in base currencycurrency(text, DEFAULT 'SATS') - Currency: 'SATS', 'BTC', 'CHF', 'USD', 'EUR'funding_purpose(text, nullable) - Description of how funds will be usedbitcoin_address(text, nullable) - Bitcoin address for receiving donationslightning_address(text, nullable) - Lightning address for receiving donationscategory(text, nullable) - Project categorytags(text[], DEFAULT '{}') - Array of tagsraised_amount(numeric(20,8), DEFAULT 0) - Total amount raised in base currencycontributor_count(integer, DEFAULT 0) - Number of unique contributors
Frontend Mapping
The frontend uses the FundingPage interface which expects:
total_funding- Maps toraised_amountfrom databasecurrent_amount- Maps toraised_amountfrom databaseraised_amount- Direct mapping from database
The project store automatically maps these fields when loading projects.
API Endpoints
GET /api/projects/[id]
Returns a single project with profile information.
Response Structure:
{
"success": true,
"data": {
"id": "uuid",
"user_id": "uuid",
"title": "string",
"description": "string",
"goal_amount": number | null,
"currency": "string",
"raised_amount": number,
"status": "string",
"profiles": {
"id": "uuid",
"username": "string",
"name": "string",
"avatar_url": "string" | null
},
...
}
}
POST /api/projects
Creates a new project.
Request Body:
{
"title": "string (required)",
"description": "string (required)",
"goal_amount": number | null,
"currency": "SATS" | "BTC" | "CHF" | "USD" | "EUR",
"funding_purpose": "string" | null,
"bitcoin_address": "string" | null,
"lightning_address": "string" | null,
"category": "string" | null,
"tags": ["string"]
}
Routes
Frontend Routes
/projects/[id]- View project page (plural "projects" - unified route for all users)/projects/create- Create new project/projects/create?edit=[id]- Edit existing project
Route Consolidation (2025-01-30):
- All project view routes consolidated to
/projects/[id](plural) - Old
/project/[id]route redirects to/projects/[id]for backward compatibility - Single unified route provides consistent UX for authenticated and public users
Status Values
The status column uses a CHECK constraint to enforce valid values:
draft- Project is not yet published (visible only to author, not in search results)active- Project is published and actively accepting donations (visible to everyone, appears in search)paused- Project is published but temporarily paused (visible to everyone via direct link, not in search, not accepting donations)completed- Project has finished (visible to everyone via direct link, not in search, not accepting donations)cancelled- Project was cancelled (visible to everyone via direct link, not in search, not accepting donations)
Status Transitions
Valid status transitions:
draft→active(publish)active→paused(pause donations)active→completed(mark as done)active→cancelled(cancel project)active→draft(unpublish)paused→active(resume donations)paused→draft(unpublish)completed→draft(unpublish/archive)cancelled→draft(unpublish/archive)
Visibility Rules
- Draft projects: Only visible to the author
- Active projects: Visible to everyone, appear in search results
- Paused/Completed/Cancelled projects: Visible to everyone via direct link, but do NOT appear in search results
Field Mapping Summary
| Database Column | Frontend Field | Notes |
|---|---|---|
raised_amount |
raised_amount |
Direct mapping |
raised_amount |
total_funding |
For FundingPage compatibility |
raised_amount |
current_amount |
For FundingPage compatibility |
status = 'active' |
isActive = true |
Computed in store |
status = 'draft' |
isDraft = true |
Computed in store |
Indexes
idx_projects_user_id- User's projects lookupidx_projects_status- Filter by statusidx_projects_created_at- Sort by creation dateidx_projects_raised_amount- Sort by funding amount
Migration
Run the migration 20250130_ensure_projects_schema_consistency.sql to ensure all columns exist and have correct defaults.