Data Flow Overview
Request/Response Flow
Idea
- Request:
POST /api/idea—{ idea, sessionId? } - Flow: Create/get context →
processIdea(idea, sessionId)→ persistanalysis,clarifyingQuestions - Response:
{ status, sessionId, stage: 'idea_input', analysis, clarifying_questions, next_stage: 'intent_analysis' }
Intent
- Request:
POST /api/intent—{ sessionId, answers, idea? } - Flow: Load context (DB then memory); if missing and
ideaprovided, recreate →refineIntent(idea, answers, sessionId)→ persistanswers,refinedRequirements - Response:
{ status, stage: 'intent_analysis', refined_requirements, next_stage: 'platform_selection' }
Platform
- Request:
POST /api/platform—{ sessionId, refinedRequirements?, supabaseIntegration? } - Flow: Load context; recover
refinedRequirementsfrom body if needed →selectPlatform(refinedRequirements, sessionId)→ normalizecost_scripttoUNIFIED_PRICE_SCRIPT→ persistplatformOptions,supabaseIntegration - Response:
{ status, stage: 'platform_selection', platform_options, recommended, next_stage: 'payment_processing' }
Payment (Solana)
- Request:
POST /api/payment—{ sessionId, selectedPlatform, userWalletPubKey } - Flow: Load context → find platform cost →
validatePayment(userWalletPubKey, cost_script)→ persistpaymentDetails(wallet, amount,paymentMethod: 'solana') - Response:
{ status, stage: 'payment_processing', payment_details?, payment_issues?, next_stage?: 'execution' }
Payment (Dodo)
- Create checkout:
POST /api/dodo/create-checkout—{ sessionId, platform }→ Dodo API →{ checkout_url } - Webhook:
POST /api/dodo/webhook—payment.succeededetc. → updateWorkflow(dodoPaymentId,paymentMethod: 'dodo',selectedPlatformfrom metadata) - Confirm (optional):
POST /api/dodo/confirm-paymentfor client-side confirmation flow
Execute
- Request:
POST /api/execute—{ sessionId, transactionSignature?, platform? } - Flow: Load/rebuild context → verify
transactionSignatureif present → checkisAgentEnabledfor each agent →executeX402Workflow(...)which callsgeneratePlatformDeliverables→ persistexecutionResult→ updateAgentStat,Transaction,User.totalSpent - Response:
{ status, stage: 'execution', execution_result: { agents_executed, deliverables, total_cost_script, execution_time_minutes, review_passed?, review_issues? }, next_stage: 'completion' }
State Transitions
Stages advance in order:idea_input → intent_analysis → platform_selection → payment_processing → execution → completion.
- idea_input: Set by
/api/idea;next_stage=intent_analysis. - intent_analysis: Set by
/api/intent;next_stage=platform_selection. - platform_selection: Set by
/api/platform;next_stage=payment_processing. - payment_processing: Set by
/api/paymentor Dodo webhook; user then proceeds to Execute. - execution: Set by
/api/execute;next_stage=completion. - completion: No API; UI shows results.
getNextStage('completion')isnull.
validateStageTransition(from, to) allows only to === from or to === getNextStage(from).
Data Persistence
Workflow (Prisma)
- Model:
Workflowinprisma/schema.prisma - Stored:
sessionId,currentStage,idea,analysisSummary,analysisFeatures,complexity,estimatedAgents,clarifyingQuestions,answers,refinedTitle,refinedDesc,refinedFeatures,targetAudience,techReqs,selectedPlatform,supabaseIntegration,walletAddress,amountScript,transactionSig,dodoPaymentId,paymentMethod,zipFile,zipFileName,zipFileSize, timestamps - Not stored (or only in memory):
platformOptions(array),executionResult(object). APIs merge from in-memory when available.
Other Models
- User —
walletAddress,totalSpent, etc.; updated on Execute for Solana payments. - Transaction —
userWallet,planType,amount,status,transactionHash,agentTriggered; written on Execute. - AgentStat — Per-agent
executions,successes,errors,totalExecutionTime; updated on Execute. - AgentControl — Per-agent
enabled; used byisAgentEnabledin Execute. - ZipFile —
sessionId,fileName,fileData,fileSize,projectName,userWallet; populated when projects are zipped for download. - ExecutionLog, Ticket, PromptSale — Used by other features (logs, support, marketplace).
In-Memory
- x402:
workflowStore: Map<sessionId, WorkflowContext>when DB is not used or forplatformOptions/executionResult. - a2a:
A2AMessageBus—Map<sessionId, A2AMessage[]>and subscriber sets.