01Problem
What was broken
Existing prompt sharing platforms have no real creator payout mechanism and weak moderation. A credit-based marketplace needs atomic transactions and a tamper-proof audit trail, or double-spends and disputed payouts are a matter of when, not if.
02Impact
What it does now
Purchases, credit adjustments and payouts all run inside SERIALIZABLE transactions with row-level locking, so a double-spend isn't possible. Every admin action writes to an append-only audit log that can't be updated or deleted, which gives a full record when a payout gets disputed. XP and badges reward publishing, selling and getting reviewed, so the incentive to keep creating sits inside the product.
03Architecture
How it is built
TanStack Start server functions handle auth, purchases and every financial operation. PostgreSQL runs hand-rolled migrations, with SERIALIZABLE isolation on anything that touches money. The accent color lives in one CSS custom property and a React context, so changing the theme repaints the UI without a reload.
┌──────────────────────────────────────────────────┐
│ PROMPTSTAR MARKETPLACE │
└──────────────────────────────────────────────────┘
[User Marketplace] ──► [Browse / Search / Filter]
│ │
[Buy Prompt] [Creator Tools]
│ │
└────────┬───────────────┘
│
[Financial Transaction]
│
[SERIALIZABLE + Row Locking]
│
┌───────────┴──────────────┐
│ │
[Credit Debit] [Author Payout]
(Buyer) (70% credit)
│ │
└────────────┬───────────┘
│
[Immutable Audit Log]
│
[Admin Dashboard]Modules
- Auth Engine
- Marketplace Core
- Financial Ledger
- Gamification
- Admin Dashboard
04Intelligence
Where the AI sits
An LLM recommends prompts using a user's preferences, purchase history and trending collections. Flagged content goes to a human moderator in the admin dashboard instead of getting removed automatically.
05Decisions
Trade-offs I chose
- 01
SERIALIZABLE Transactions for Financial Operations
All purchases, credit adjustments and payouts run inside SERIALIZABLE transactions with explicit row-level locking (SELECT ... FOR UPDATE). That closes the race condition where two requests read the same balance before either one writes it back.
- 02
Append-Only Audit Log
Every admin action writes to an audit_logs table with database-enforced constraints: no UPDATE, no DELETE. When a payout gets disputed months later, the record is still exactly what happened.
- 03
Real-Time Live Theming via CSS Custom Properties
Accent color lives in one --magenta custom property. Changing the theme in Studio repaints every text-magenta, bg-magenta and ring-magenta instance without a page reload or a flash of the old color.
- 04
XP-Based Gamification with Badges
XP accrues passively: publish a prompt (+100), make a sale (+500), get saved (+50), write a review (+75). Levels unlock every 1k XP, and badges like First Star, Creator, Hot Streak and Top Seller sit on the profile card.
