Conversation
Defines architecture for a Kotlin backend + shared Vite frontend sample demonstrating the payout flow (customer → external account → quote → execute → sandbox fund) with live webhook streaming via SSE. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
12-task plan covering Kotlin backend scaffold, routes, frontend scaffold, components, wizard assembly, and READMEs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add all Kotlin source files for the Grid API sample app backend: - Core infrastructure: Config, GridClientBuilder, WebhookStream, JsonUtils - Application entry point with CORS and SSE configuration - Route handlers: Customers, ExternalAccounts, Quotes, Sandbox, Webhooks, SSE - Fix build.gradle.kts to use correct SDK coordinates (com.grid.api:grid-kotlin) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add node-gradle plugin to build frontend as part of ./gradlew run - Vite outputs to backend's src/main/resources/static/ - Ktor serves static files at / (after API routes) - Update README with single-command and dev-server run options Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile OverviewGreptile SummaryThis PR adds a comprehensive Kotlin sample application for the Grid API, demonstrating the complete payout flow with a React frontend and Ktor backend. The implementation includes a step-by-step wizard for creating customers, linking external accounts, creating quotes, and executing payments, with real-time webhook streaming via SSE. Key Changes:
Architecture: The implementation is production-quality for a sample app with proper security practices (webhook signature verification, credential management via environment variables). Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| samples/kotlin/src/main/kotlin/com/grid/sample/Application.kt | Sets up Ktor server with CORS, SSE, routing, and serves frontend static files |
| samples/kotlin/src/main/kotlin/com/grid/sample/routes/Quotes.kt | Implements quote creation and execution routes; has ambiguous source type detection logic |
| samples/kotlin/src/main/kotlin/com/grid/sample/routes/Webhooks.kt | Handles webhook reception, unwraps events using SDK, broadcasts to SSE stream |
| samples/kotlin/src/main/kotlin/com/grid/sample/routes/ExternalAccounts.kt | Creates external bank accounts with proper beneficiary and account info handling |
| samples/kotlin/src/main/kotlin/com/grid/sample/routes/Customers.kt | Creates individual customers with proper optional field handling |
| samples/kotlin/build.gradle.kts | Gradle build with node plugin for frontend integration, proper dependencies |
| samples/frontend/src/components/WebhookStream.tsx | SSE-connected webhook stream component with auto-reconnect and expandable events |
| samples/frontend/vite.config.ts | Vite config with API proxy to backend and build output to Kotlin resources |
Sequence Diagram
sequenceDiagram
participant Browser
participant Vite as Vite Dev Server
participant Ktor as Ktor Backend
participant Grid as Grid API
participant Webhooks as Grid Webhooks
Browser->>Vite: Load App (http://localhost:5173)
Vite-->>Browser: React Frontend
Browser->>Ktor: SSE Connection (/api/sse)
Ktor-->>Browser: Connected
Note over Browser,Ktor: Step 1: Create Customer
Browser->>Vite: POST /api/customers
Vite->>Ktor: Proxy to :8080
Ktor->>Grid: customers.create()
Grid-->>Ktor: Customer Response
Ktor-->>Browser: Customer JSON
Note over Browser,Ktor: Step 2: Create External Account
Browser->>Vite: POST /api/customers/{id}/external-accounts
Vite->>Ktor: Proxy to :8080
Ktor->>Grid: externalAccounts.create()
Grid-->>Ktor: Account Response
Ktor-->>Browser: Account JSON
Note over Browser,Ktor: Step 3: Create Quote
Browser->>Vite: POST /api/quotes
Vite->>Ktor: Proxy to :8080
Ktor->>Grid: quotes.create()
Grid-->>Ktor: Quote Response
Ktor-->>Browser: Quote JSON
Note over Browser,Ktor: Step 4: Execute Quote
Browser->>Vite: POST /api/quotes/{id}/execute
Vite->>Ktor: Proxy to :8080
Ktor->>Grid: quotes.execute()
Grid-->>Ktor: Updated Quote
Ktor-->>Browser: Quote JSON
Note over Browser,Ktor: Step 5: Sandbox Fund
Browser->>Vite: POST /api/sandbox/send-funds
Vite->>Ktor: Proxy to :8080
Ktor->>Grid: sandbox.sendFunds()
Grid-->>Ktor: Funding Response
Ktor-->>Browser: Confirmation JSON
Note over Webhooks,Browser: Webhook Flow
Webhooks->>Ktor: POST /api/webhooks
Ktor->>Ktor: Verify signature & unwrap
Ktor->>Ktor: Broadcast to WebhookStream
Ktor-->>Browser: SSE event with webhook data
Last reviewed commit: ed33d3f
a8558f0 to
61be1bc
Compare
9e09ccc to
6d3a5a1
Compare
6d3a5a1 to
ed33d3f
Compare

No description provided.