Pay-per-query startup intelligence agent. PitchBook-level research for the people priced out: founders, students, small funds. No subscription. No API key. Pay per query in USDC on Base via x402.
Hackathon: Microsoft × Coinbase × Tavily Agentic Commerce Hackathon, 2026. Scope: backend only. Frontend lives elsewhere.
- Accept a natural-language query (
"top Series A edtech startups 2025"). - Return HTTP
402 Payment Requiredwith x402 payment terms. - Verify USDC payment on Base via x402 facilitator.
- Run Tavily multi-source search (Crunchbase, TechCrunch, SEC EDGAR, LinkedIn, open web).
- Synthesize results into a structured one-page brief via Azure OpenAI (OpenAI direct as fallback).
- Return JSON brief.
Total latency target: <10s. Cost per query: ~$0.005 USDC.
┌──────────────┐ POST /query (no payment) ┌────────────────┐
│ Caller │ ─────────────────────────────────────▶│ /query route │
│ (agent or │ │ (Express) │
│ human via │ ◀──── 402 Payment Required ──────────│ │
│ frontend) │ (x-payment-required hdr) └────────────────┘
└──────┬───────┘ │
│ │
│ POST /query + X-PAYMENT header │
│ (signed USDC transfer on Base) │
▼ ▼
┌────────────────────────┐ ┌──────────────────────────────────┐
│ x402-express │ ───────▶│ Orchestrator │
│ middleware: │ │ - validate query │
│ - parse X-PAYMENT │ │ - dispatch Tavily search │
│ - verify via │ │ - dispatch OpenAI synthesis │
│ facilitator │ │ - return structured brief │
│ - settle on Base │ └────────┬─────────────────────────┘
└────────────────────────┘ │
├──▶ Tavily Search SDK
├──▶ Azure OpenAI (gpt-4o-mini; OpenAI fallback)
└──▶ Postgres (query log, briefs cache)
Caller wallet: Coinbase CDP Agentic Wallet (autonomously signs the X-PAYMENT)
Server wallet: Coinbase CDP wallet (receives settled USDC on Base)
| Layer | Choice |
|---|---|
| Runtime | Node 20 + TypeScript |
| HTTP | Express (x402 middleware compat) |
| Search | Tavily SDK (@tavily/core) |
| LLM | Azure OpenAI (gpt-4o-mini, primary) — OpenAI direct as fallback via env |
| Wallet (caller side, demo) | Coinbase CDP Agentic Wallets (launch ref) |
| Wallet (server side) | Coinbase CDP wallet — receives settled USDC |
| Payments | x402-express middleware, USDC on Base Sepolia (demo) / Base mainnet (prod) |
| DB | Postgres (Neon) — query log, brief cache |
| Host | Azure Container Apps (Microsoft sponsor credits) |
| Local chain | Anvil (Foundry) optional, for offline x402 dev |
sitch-backend/
├── README.md
├── package.json
├── tsconfig.json
├── .env.example # template only — never commit .env
├── .gitignore
├── src/
│ ├── index.ts # Express app entry
│ ├── routes/
│ │ └── query.ts # POST /query — main paid endpoint
│ ├── x402/
│ │ └── middleware.ts # x402-express config + pricing
│ ├── orchestrator/
│ │ └── orchestrator.ts # query → search → synthesis pipeline
│ ├── tavily/
│ │ └── search.ts # Tavily multi-source search
│ ├── synthesis/
│ │ └── brief.ts # OpenAI tool-use → structured brief
│ ├── wallet/
│ │ └── cdp.ts # Coinbase CDP server wallet
│ ├── agents/
│ │ └── (reserved for future multi-agent expansion)
│ └── db/
│ └── client.ts # Postgres client + migrations
├── tests/
└── scripts/
└── seed.ts # seed demo data
First call (no payment):
POST /query
Content-Type: application/json
{ "query": "top Series A AI startups in healthcare 2025" }Response:
HTTP/1.1 402 Payment Required
X-Payment-Required: { chain: "base-sepolia", asset: "USDC", amount: "5000", recipient: "0x..." }Second call (with payment header):
POST /query
X-Payment: <base64-signed-usdc-transfer>
Content-Type: application/json
{ "query": "top Series A AI startups in healthcare 2025" }Response (200):
{
"query": "top Series A AI startups in healthcare 2025",
"brief": {
"summary": "...",
"key_companies": [
{ "name": "...", "stage": "Series A", "amount_raised_usd": 25000000, "lead_investors": [...], "source_urls": [...] }
],
"market_trends": [...],
"content_angles": [...]
},
"sources": [...],
"payment": { "tx_hash": "0x...", "amount_usdc": "0.005", "settled_at": "..." },
"latency_ms": 7421
}Liveness probe. No payment required.
Returns current per-query pricing in USDC. No payment required.
Solo build. Branches kept for organized commits + clean PR history (judges look at repo activity).
| Branch | Purpose |
|---|---|
main |
Demo-ready. Scaffold + merged features. |
feature/x402-middleware |
x402-express setup + pricing config |
feature/tavily-search |
Tavily search wrapper + source filtering |
feature/agentkit-wallet |
Coinbase Agentic Wallet (awal) + x402 signing |
feature/synthesis-agent |
Azure OpenAI synthesis → structured brief (OpenAI fallback) |
feature/orchestrator |
Pipeline glue: search → synth → return |
PR rule: feature → main, squash merge. No direct commits to main after scaffold.
Postgres/DB deferred to v0.2. v0 uses in-memory query log only. Judges don't need persistence for a 60-sec demo.
See .env.example. Required vars:
AZURE_OPENAI_ENDPOINT,AZURE_OPENAI_API_KEY,AZURE_OPENAI_DEPLOYMENT,AZURE_OPENAI_API_VERSION(synthesis; primary)OPENAI_API_KEY(fallback; only used if Azure vars unset)TAVILY_API_KEY(search)CDP_API_KEY_NAME,CDP_API_KEY_PRIVATE_KEY(Coinbase Developer Platform — NOT the coinbase.com exchange key)X402_FACILITATOR_URL,X402_RECEIVING_ADDRESS,X402_NETWORK,X402_PRICE_USDCBASE_RPC_URLPORT(default 8787)
Never commit .env. It is in .gitignore. Per project security rules, no secrets in repo.
npm install
cp .env.example .env # fill in your keys locally
npm run dev # tsx watch on :8787| Hour | Branch | Deliverable |
|---|---|---|
| 0–1 | main |
Scaffold + README + env template (this commit) |
| 1–3 | feature/x402-middleware |
x402-express wired, returns 402 with correct pricing |
| 3–5 | feature/tavily-search |
Tavily multi-source search, returns normalized hits |
| 5–7 | feature/synthesis-agent |
OpenAI tool-use → structured brief JSON |
| 7–8 | feature/agentkit-wallet |
CDP wallet receiving + (optional) caller-side demo signer |
| 8–10 | feature/orchestrator |
End-to-end pipeline + Postgres logging |
| 10–11 | main |
Merge all PRs, deploy to Azure Container Apps |
| 11–12 | — | Demo script: query → 402 → pay → brief in <10s |
- Frontend (separate repo).
- Brief caching dedup beyond exact-query match.
- Multi-language (English only).
- Streaming responses (return full JSON, no SSE for v0).
- Non-USDC payment paths.
- Crunchbase / PitchBook direct API integration (Tavily covers public web).
- Tavily: real-time multi-source web search is the data layer.
- Coinbase: x402 protocol + CDP Agentic Wallets handle autonomous payment.
- Microsoft: Azure Container Apps hosts the agent runtime; Azure OpenAI powers synthesis.
- x402: every paid call uses HTTP 402 + USDC settlement on Base.