Vectr is an AI-powered image search application template that automatically generates descriptions for uploaded images and indexes them for semantic search.
- π€ Drag-and-drop image uploads with Vercel Blob Storage
- π€ AI-powered image descriptions using Grok 2 Vision
- π Semantic search with Upstash Vector Search (stores metadata too!)
- π Resilient processing with Vercel Workflow automatic retries
- π¨ Beautiful UI built with shadcn/ui and Tailwind CSS
- π° Incredibly cheap - No database needed!
When you upload an image, Vectr automatically:
- πΎ Stores the image in Vercel Blob Storage
- π§ Generates a detailed description using Grok 2 Vision AI
- π Indexes the description AND metadata in Upstash for semantic search
sequenceDiagram
participant User
participant App as Next.js App
participant Workflow as Vercel Workflow
participant Blob as Vercel Blob
participant AI as Grok Vision AI
participant Search as Upstash Search
User->>App: Upload Image (FormData)
App->>Workflow: POST /api/upload
Note over Workflow: Start Workflow
Workflow->>Blob: Upload to Storage (Step 1)
Note over Blob: Max 3 retries<br/>Rate limit handling
Blob-->>Workflow: Blob URL + Metadata
Workflow->>AI: Generate Description (Step 2)
Note over AI: Max 5 retries<br/>Rate limit handling
AI-->>Workflow: Image Description
Workflow->>Search: Index with Metadata (Step 3)
Note over Search: Max 5 retries<br/>Stores description + blob metadata
Search-->>Workflow: Success
Workflow-->>App: 200 OK
User->>App: Search Images
App->>Search: Semantic Query
Search-->>App: Results with Metadata
App-->>User: Display Results
Each step in the image processing workflow is isolated and runs on a separate serverless function with automatic retries:
Step 1: Upload Image (upload-image.ts)
- πΎ Uploads to Vercel Blob Storage
- β±οΈ Handles rate limiting with 1-minute retry delays
- π Maximum 3 retry attempts
- β Fatal error on quota exceeded or invalid files
Step 2: Generate Description (generate-description.ts)
- π€ Uses Grok 2 Vision AI to analyze the image
- β±οΈ Handles rate limiting with 5-minute retry delays
- π Maximum 5 retry attempts
- β Fatal error on invalid/unsupported images
Step 3: Index Image (index-image.ts)
- π Indexes description AND blob metadata in Upstash
- πΎ Stores all image data (url, size, contentType, etc.) as metadata
- β±οΈ Handles rate limiting with 1-minute retry delays
- π Maximum 5 retry attempts
- β Fatal error on invalid data
Vectr uses sophisticated error handling to ensure reliable processing:
- π RetryableError: Temporary failures (rate limits, network issues, timeouts)
- β FatalError: Permanent failures (invalid data, constraint violations)
- π Context-aware retries: Each step tracks attempt count and timestamps
- π― Smart HTTP responses: 400 for fatal errors, 500 for retryable errors
- β‘ Framework: Next.js 15 with App Router and React 19
- π Workflow: Vercel Workflow (alpha)
- π€ AI: Grok 2 Vision via Vercel AI SDK
- π Search & Storage: Upstash Vector Search (stores metadata too!)
- πΎ Blob Storage: Vercel Blob Storage
- π¨ UI: shadcn/ui + Tailwind CSS 4
- π Type Safety: TypeScript + Zod
The easiest way to deploy Vectr is using the Vercel Marketplace:
During deployment, you'll be prompted to set up:
- π Upstash Vector Search - Semantic search + metadata storage
- πΎ Vercel Blob Storage - Image storage
Both services have generous free tiers and will be automatically configured. No database needed!
- π’ Node.js 18+
- π¦ pnpm (recommended)
- Clone the repository:
git clone https://github.com/your-username/vectr.git
cd vectr- Install dependencies:
pnpm install- Set up environment variables:
Create a .env.local file with:
# Upstash Search
UPSTASH_SEARCH_URL="https://..."
UPSTASH_SEARCH_TOKEN="..."
# Vercel Blob
BLOB_READ_WRITE_TOKEN="..."
# AI Gateway Key (only needed locally)
AI_GATEWAY_API_KEY="..."- Run the development server:
pnpm devOpen http://localhost:3000 to see your app.
- π
pnpm dev- Start development server with Turbopack - ποΈ
pnpm build- Build for production - β
pnpm check- Run linting checks - β¨
pnpm format- Format code with Biome
vectr/
βββ app/
β βββ actions/
β β βββ search.ts # Server action for search
β βββ api/
β β βββ upload/
β β βββ route.ts # Workflow route handler
β β βββ upload-image.ts # Step 1: Upload to Blob
β β βββ generate-description.ts # Step 2: AI description
β β βββ index-image.ts # Step 3: Index with metadata
β βββ layout.tsx
β βββ page.tsx
βββ components/
β βββ header.tsx
β βββ results.tsx
β βββ upload-button.tsx
β βββ uploaded-images-provider.tsx
βββ lib/
β βββ utils.ts
βββ package.json
| Variable | Description | Required |
|---|---|---|
UPSTASH_SEARCH_URL |
Upstash Vector Search endpoint | Yes |
UPSTASH_SEARCH_TOKEN |
Upstash authentication token | Yes |
BLOB_READ_WRITE_TOKEN |
Vercel Blob Storage token | Yes |
XAI_API_KEY |
xAI API key for Grok Vision | Yes |
Vectr includes comprehensive logging for monitoring and debugging:
- π
[WORKFLOW]- Workflow-level events and timing - π§
[stepId]- Step-level events with unique identifiers - π
[API]- HTTP request/response logging
All logs include timestamps, attempt counts, and duration metrics.
Contributions are welcome! Please feel free to submit a Pull Request. Our Contributing Guide has more information on how to get started.
MIT