
Vectr
Vectr is an AI-powered image search application template that automatically generates descriptions for uploaded images and indexes them for semantic search.
⨠Features
- š¤ 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!
š How It Works
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
Loading diagram...
šļø Architecture
Workflow Steps
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
Error Handling
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
š ļø Tech Stack
- ā” 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
š Deploy to Vercel
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!
š» Local Development
Prerequisites
- š¢ Node.js 18+
- š¦ pnpm (recommended)
Setup
- Clone the repository:
git clone https://github.com/your-username/vectr.gitcd vectr
- Install dependencies:
pnpm install
- Set up environment variables:
Create a .env.local file with:
# Upstash SearchUPSTASH_SEARCH_URL="https://..."UPSTASH_SEARCH_TOKEN="..."# Vercel BlobBLOB_READ_WRITE_TOKEN="..."# AI Gateway Key (only needed locally)AI_GATEWAY_API_KEY="..."
- Run the development server:
pnpm dev
Open http://localhost:3000 to see your app.
š Scripts
- š
pnpm dev- Start development server with Turbopack - šļø
pnpm build- Build for production - ā
pnpm check- Run linting checks - āØ
pnpm format- Format code with Biome
š Project Structure
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
š Environment Variables
| 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 |
š Observability
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.
š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request. Our Contributing Guide [blocked] has more information on how to get started.
š License
MIT