Skip to content

Commit 03e04db

Browse files
pengyingclaude
andcommitted
docs(samples): add READMEs for samples, Kotlin backend, and frontend
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ae00167 commit 03e04db

3 files changed

Lines changed: 146 additions & 0 deletions

File tree

samples/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Grid API Samples
2+
3+
Sample applications demonstrating the Grid API payout flow — creating a customer, linking a bank account, creating and executing a quote, and simulating funding in the sandbox.
4+
5+
## Structure
6+
7+
```
8+
samples/
9+
├── frontend/ # Shared React frontend (works with any backend)
10+
└── kotlin/ # Kotlin (Ktor) backend using the Grid Kotlin SDK
11+
```
12+
13+
## Quick Start
14+
15+
See the [Kotlin backend README](kotlin/README.md) for setup instructions.
16+
17+
## Adding a New Language Backend
18+
19+
Each backend must implement the same API contract:
20+
21+
| Method | Path | Description |
22+
|--------|------|-------------|
23+
| POST | `/api/customers` | Create a customer |
24+
| POST | `/api/customers/{id}/external-accounts` | Create an external account |
25+
| POST | `/api/quotes` | Create a quote |
26+
| POST | `/api/quotes/{id}/execute` | Execute a quote |
27+
| POST | `/api/sandbox/send-funds` | Simulate sandbox funding |
28+
| POST | `/api/webhooks` | Receive webhook events from Grid |
29+
| GET | `/api/sse` | Stream webhook events to the frontend via SSE |
30+
31+
The backend should run on port `8080`. The frontend proxies `/api` requests to `http://localhost:8080`.

samples/frontend/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Grid API Sample Frontend
2+
3+
Shared React frontend for the Grid API sample backends. Works with any backend that implements the [API contract](../README.md).
4+
5+
## Running
6+
7+
```bash
8+
npm install
9+
npm run dev
10+
```
11+
12+
The dev server starts on [http://localhost:5173](http://localhost:5173) and proxies `/api` requests to `http://localhost:8080`.
13+
14+
## Configuring the Backend URL
15+
16+
If your backend runs on a different port, update the proxy target in `vite.config.ts`:
17+
18+
```typescript
19+
proxy: {
20+
'/api': {
21+
target: 'http://localhost:YOUR_PORT',
22+
}
23+
}
24+
```
25+
26+
## Tech Stack
27+
28+
- React 18 + TypeScript
29+
- Vite 6
30+
- Tailwind CSS 4

samples/kotlin/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Grid API Kotlin Sample
2+
3+
A sample application demonstrating the Grid API payout flow using the [Grid Kotlin SDK](https://github.com/lightsparkdev/grid-kotlin-sdk).
4+
5+
## What It Does
6+
7+
This sample walks through a complete payout:
8+
9+
1. **Create Customer** — Register an individual customer on the platform
10+
2. **Create External Account** — Link a USD bank account to the customer
11+
3. **Create Quote** — Get a real-time quote for USDC to USD conversion
12+
4. **Execute Quote** — Initiate the payment
13+
5. **Sandbox Fund** — Simulate funding to complete the transaction
14+
15+
Webhook events are streamed to the frontend in real time via Server-Sent Events (SSE).
16+
17+
## Prerequisites
18+
19+
- **Java 21+** ([Eclipse Temurin](https://adoptium.net/) recommended)
20+
- **Node.js 18+** (for the frontend)
21+
- **Grid API sandbox credentials** from [app.lightspark.com](https://app.lightspark.com)
22+
23+
## Setup
24+
25+
1. Copy the environment template:
26+
27+
```bash
28+
cp .env.example .env
29+
```
30+
31+
2. Fill in your credentials in `.env`:
32+
33+
```bash
34+
GRID_API_TOKEN_ID=your_api_token_id
35+
GRID_API_CLIENT_SECRET=your_api_client_secret
36+
GRID_WEBHOOK_PUBLIC_KEY=your_webhook_public_key
37+
```
38+
39+
## Running
40+
41+
Start the backend and frontend in two separate terminals:
42+
43+
**Terminal 1 — Backend (port 8080):**
44+
45+
```bash
46+
cd samples/kotlin
47+
./gradlew run
48+
```
49+
50+
**Terminal 2 — Frontend (port 5173):**
51+
52+
```bash
53+
cd samples/frontend
54+
npm install
55+
npm run dev
56+
```
57+
58+
Open [http://localhost:5173](http://localhost:5173) in your browser.
59+
60+
## Webhook Setup
61+
62+
To receive webhooks locally, expose your backend with a tunnel:
63+
64+
```bash
65+
ngrok http 8080
66+
```
67+
68+
Then configure the webhook URL in your [Grid dashboard](https://app.lightspark.com) as:
69+
70+
```
71+
https://<your-ngrok-id>.ngrok.io/api/webhooks
72+
```
73+
74+
## Architecture
75+
76+
```
77+
Browser (React) → Vite Dev Server (:5173) → Ktor Backend (:8080) → Grid API
78+
proxy /api Grid Kotlin SDK
79+
80+
Grid Webhooks (POST)
81+
82+
SSE stream → Browser
83+
```
84+
85+
The backend is a thin proxy — it holds your API credentials and translates JSON requests into Grid SDK calls. The frontend handles the step-by-step wizard flow.

0 commit comments

Comments
 (0)