# VU Key Web Portal ## Overview Web application for users to manage their VoiceUwu keys - login, view purchases, share keys with others, donate keys, and purchase additional keys. This is the customer-facing portal that complements the keyserver backend. ## Core Features ### 1. User Authentication - Email/password login - OAuth integration (Google, Apple Sign-In) - Password reset functionality - Account creation during first purchase ### 2. Key Management Dashboard - View all owned keys - Key activation status - Purchase history with receipts - Key expiration dates (if applicable) ### 3. Key Sharing - Share keys with specific email addresses - Generate shareable links with expiration - Revoke shared access - View who has access to shared keys ### 4. Key Donation - Donate keys to community pool - Specify donation conditions (regions, user types) - View donation history and impact - Anonymous donation options ### 5. Key Purchasing - Browse available key packages - Stripe and PayPal checkout integration - Bulk purchase discounts - Gift key purchases for others ## User Flows ### Login Flow 1. User visits portal 2. Login with email/password or OAuth 3. Redirect to dashboard 4. Auto-sync keys from keyserver ### Key Management Flow 1. Dashboard shows all owned keys 2. Click key to view details (purchase date, platform, status) 3. Options to share, donate, or view usage ### Key Sharing Flow 1. Select key to share 2. Enter recipient email or generate link 3. Set sharing permissions and expiration 4. Recipient gets notification/link 5. Shared key appears in recipient's dashboard ### Key Donation Flow 1. Select keys to donate 2. Choose donation type (community pool, specific criteria) 3. Confirm donation 4. Keys transferred to donation system 5. Donation receipt and impact tracking ### Purchase Flow 1. Browse key packages 2. Select quantity and type 3. Stripe/PayPal checkout 4. Payment processed via keyserver 5. Keys immediately available in dashboard ## API Endpoints ### Authentication ``` POST /auth/login # Email/password login POST /auth/oauth/google # Google OAuth POST /auth/oauth/apple # Apple Sign-In POST /auth/register # Create account POST /auth/reset-password # Password reset POST /auth/logout # Logout ``` ### User Management ``` GET /user/profile # Get user profile PUT /user/profile # Update profile GET /user/keys # Get user's keys GET /user/purchases # Purchase history ``` ### Key Operations ``` POST /keys/share # Share key with user POST /keys/share/link # Generate shareable link DELETE /keys/share/:id # Revoke sharing GET /keys/shared-with-me # Keys shared with user POST /keys/donate # Donate keys GET /keys/donations # Donation history ``` ### Purchasing ``` GET /store/packages # Available key packages POST /store/purchase/stripe # Purchase with Stripe POST /store/purchase/paypal # Purchase with PayPal POST /store/gift # Gift keys to others ``` ## Database Schema ### Users Table ```sql CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, password_hash VARCHAR(255), google_id VARCHAR(255), apple_id VARCHAR(255), created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW() ); ``` ### User Keys Table ```sql CREATE TABLE user_keys ( id SERIAL PRIMARY KEY, user_id INTEGER REFERENCES users(id), key_id VARCHAR(255) NOT NULL, purchase_platform VARCHAR(50), purchase_transaction VARCHAR(255), purchased_at TIMESTAMP DEFAULT NOW(), expires_at TIMESTAMP, status VARCHAR(20) DEFAULT 'active' ); ``` ### Key Shares Table ```sql CREATE TABLE key_shares ( id SERIAL PRIMARY KEY, key_id VARCHAR(255) NOT NULL, owner_id INTEGER REFERENCES users(id), shared_with_id INTEGER REFERENCES users(id), shared_with_email VARCHAR(255), share_link_token VARCHAR(255), expires_at TIMESTAMP, created_at TIMESTAMP DEFAULT NOW(), revoked_at TIMESTAMP ); ``` ### Key Donations Table ```sql CREATE TABLE key_donations ( id SERIAL PRIMARY KEY, key_id VARCHAR(255) NOT NULL, donor_id INTEGER REFERENCES users(id), donation_type VARCHAR(50), criteria JSONB, donated_at TIMESTAMP DEFAULT NOW(), claimed_by INTEGER REFERENCES users(id), claimed_at TIMESTAMP ); ``` ## Frontend Components ### Dashboard Component ```typescript interface DashboardProps { user: User; keys: UserKey[]; purchases: Purchase[]; } function Dashboard({ user, keys, purchases }: DashboardProps) { return (