mirror of
https://github.com/tinyfish-io/tinyfish-cookbook.git
synced 2026-09-14 17:41:39 +08:00
c01680f070
Migrates Wing Command from raw TinyFish HTTP calls to the official SDK, and tears out the Supabase + Redis infrastructure that was never needed for this use case. The app now runs entirely in-memory — no database to provision, no cache to configure, just two API keys and you're running. The app itself finds the best chicken wing spots near you by zip code. Pick a flavor persona, and it fires parallel browser agents at DoorDash, Uber Eats, Grubhub, and Google simultaneously, streaming results back as each source finishes rather than waiting for all of them. --------- Co-authored-by: Krishna Agarwal <krishna.laptop3727@gmail.com> Co-authored-by: Simantak Dabhade <simantak@mac.local>
Wing Command v4
Find the best chicken wings near you — powered by TinyFish + Gemini.
Enter a zip code and flavor preference. Wing Command dispatches parallel TinyFish browser agents across DoorDash, UberEats, Grubhub, Yelp, and Google — streaming live results back as each agent completes.
Architecture
User enters zip code + flavor
↓
/api/scout (SSE)
├── Gemini discovers 5-7 source URLs for the location
└── TinyFish agents scrape each source in parallel
↓
Results stream to UI as each agent completes
TinyFish API Usage
import { TinyFish, EventType, RunStatus } from '@tiny-fish/sdk';
const client = new TinyFish({ apiKey: process.env.TINYFISH_API_KEY });
const stream = await client.agent.stream({ url, goal });
for await (const event of stream) {
if (event.type === EventType.COMPLETE) {
if (event.status === RunStatus.COMPLETED) {
// event.result contains extracted restaurant data
}
break;
}
}
Results are streamed back to the browser via SSE (TransformStream) as each agent finishes.
Setup
cd wing-command
npm install
cp .env.example .env.local
# Fill in your API keys
npm run dev
Environment Variables
| Variable | Description |
|---|---|
TINYFISH_API_KEY |
TinyFish browser agents — get yours at agent.tinyfish.ai/api-keys |
GEMINI_API_KEY |
URL discovery via gemini-2.0-flash — get yours at aistudio.google.com/apikey |
Tech Stack
| Layer | Technology |
|---|---|
| Framework | Next.js 14 (App Router) |
| Language | TypeScript |
| Web scraping | TinyFish Agent API (@tiny-fish/sdk) |
| URL discovery | Google Gemini (@google/generative-ai) |
| Streaming | Server-Sent Events via TransformStream |
| Styling | Tailwind CSS |
Constraint Checklist
| Constraint | Status |
|---|---|
| Raw SSE fetch? | NO — uses @tiny-fish/sdk |
| Mino references? | NO — all removed |
| Hardcoded secrets? | NO — .env.local only |
| Module-level SDK instantiation? | NO — instantiated inside handler |
| External database? | NO — pure in-memory |