AI build guide

Build an institutional trading platform with one prompt.

Paste the prompt below into Lovable, Claude, Cursor, ChatGPT, or any AI coding agent. It includes everything the model needs to know: API contract, auth, error codes, file structure, constraints. The output is production-grade by default.

Before you paste

  1. 1
    Sign up as an operatorat partners.varjix.com/register — pick a plan (Launch / Pro / Scale). Verify your email.
  2. 2
    Connect your own Deriv App IDvia partners.varjix.com/platforms. You'll need an App ID from app.deriv.com. Without your own app, markup goes to VARJIX's default app.
  3. 3
    Mint your API keyat api.varjix.com/dashboard/keys. Copy the vk_live_* string IMMEDIATELY — it's shown once.
  4. 4
    Open your AI coding agentLovable, Cursor, Claude (claude.ai/code), ChatGPT, or any agent with file-write access. Paste the prompt below in a fresh chat.

The prompt

Copy raw
Prompt2,776 chars
You are building a production-grade trading platform on the VARJIX API.

VARJIX is REST infrastructure: I bring my own Deriv App ID (operator-owned, I keep 100% of broker markup), VARJIX is the rails that handle auth, idempotency, order ledger, and per-trader scope. VARJIX never custodies trader funds — Deriv holds them.

Read the full API contract here BEFORE writing code:
- OpenAPI 3.1 spec:   https://api.varjix.com/openapi.json
- llms-full.txt:      https://api.varjix.com/llms-full.txt
- Developer console:  https://api.varjix.com/dashboard

Build me a Next.js 14 (App Router) trading platform with:
1. Trader sign-up + Deriv OAuth (using MY app ID — env DERIV_APP_ID + DERIV_OAUTH_URL)
2. After OAuth, the backend POSTs the tokens to VARJIX /v1/auth/deriv/exchange to register the trader
3. A trade page with: live tick chart (R_100), DIGITOVER/UNDER buttons, stake input, single-digit barrier picker
4. POST /v1/orders/binary on click — tick contracts settle inline; show the closed P&L immediately
5. A balance widget that polls GET /v1/balance every 5s
6. An order history table backed by GET /v1/orders (cursor-paginated)
7. Strict TypeScript, no `any`. Zod schemas for every VARJIX response. clientOrderId via crypto.randomUUID(). One `vx()` fetch helper with full error mapping (UNAUTHENTICATED, MARKET_CLOSED, INSUFFICIENT_BALANCE, INVALID_CONTRACT, BROKER_UPSTREAM, RATE_LIMITED with Retry-After).

Constraints:
- Store VARJIX_API_KEY ONLY on the server (Next.js Route Handler / Server Action). NEVER in the client.
- Every call to VARJIX must carry the Bearer key + the trader's external id.
- Use the user's stable id from your auth provider as traderExternalId (passed once on /auth/deriv/exchange, then reused).
- Idempotency: every POST /orders/binary needs a fresh UUID v4 from the SERVER (don't trust the client).

Tech defaults: Next.js 14, Tailwind, shadcn/ui, NextAuth or Clerk for trader sign-in, lightweight-charts for the chart. Dark theme. Mobile-first.

Deliverables (in this order):
1. .env.example with: VARJIX_API_KEY, VARJIX_API_BASE=https://api.varjix.com/v1, DERIV_APP_ID, DERIV_OAUTH_URL, NEXTAUTH_SECRET
2. lib/varjix.ts — typed fetch helper + Zod schemas for /v1/me, /v1/balance, /v1/orders/binary, /v1/orders, /v1/accounts
3. app/api/auth/deriv/callback/route.ts — exchange Deriv OAuth code → tokens → forward to VARJIX
4. app/api/orders/place/route.ts — server action: validates input, generates UUID, calls VARJIX, returns settled order
5. app/api/balance/route.ts — proxies GET /v1/balance for the signed-in trader
6. app/(trade)/page.tsx — UI, chart, order panel, history. Skeleton states + error toasts.
7. README with curl smoke commands for every flow.

Build this end-to-end. Show me the file tree first, then write each file.

Why this works

Spec-first

The prompt points the AI at /openapi.json. Every modern coding agent (Claude 4, GPT-5, Cursor) parses OpenAPI natively and generates typed clients without hallucinating endpoints.

Error-aware

Listing every error code (with HTTP + meaning) up front means the AI writes proper recovery code instead of generic try/catch.

Security baked-in

'Store VARJIX_API_KEY only on the server' + 'UUID from server, not client' prevents the most common AI-generated mistake (leaking keys to the browser).

Deliverable list

Explicit ordered file list = the AI works incrementally + your review is easy. No 'thinking about the architecture' time.

What you'll get

A working Next.js trading platform in ~10 minutes:

tree
my-trading-app/
├── .env.example
├── lib/
│   └── varjix.ts              # typed fetch helper + Zod schemas
├── app/
│   ├── api/
│   │   ├── auth/deriv/callback/route.ts
│   │   ├── orders/place/route.ts
│   │   └── balance/route.ts
│   ├── (trade)/page.tsx       # main UI
│   └── layout.tsx
├── components/
│   ├── Chart.tsx
│   ├── OrderPanel.tsx
│   ├── BalanceWidget.tsx
│   └── OrderHistory.tsx
└── README.md

From there, customize the brand (colors, logo, copy), wire your domain, and you're live. Operator markup flows directly from Deriv to your account; VARJIX never sees a cent of trading funds.

Ready?

Mint your key, open Lovable, paste the prompt above.