Note: The project's streaming API will only receive the first response in vercel then stop because my dumbass wrote streaming API enqueue but Vercel only accepts edge cases, but works fine in local development. Will fix this soon.
working.output.1.mp4
working.output.2.mp4
- Install dependencies:
bun install- Set up environment variables:
cp example.env .env.local- Configure your
.env.localfile with the following variables:
NEXTAUTH_SECRET: Generate a random string (e.g., usingopenssl rand -base64 32)ENCRYPTION_SECRET: Generate another random string for encryption (e.g., usingopenssl rand -base64 32)
- Go to Google Cloud Console > Credentials
- Create credentials > OAuth client ID
- Application type: Web application
- Name your application
- Add Authorized JavaScript origins:
http://localhost:3000orhttps://localhost:3000
- Add Authorized redirect URIs:
http://localhost:3000/api/auth/callback/googleorhttps://localhost:3000/api/auth/callback/google
- Copy the generated Client ID and Client Secret to:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRET
GEMINI_API_KEY: Get from Google AI StudioSCRAPYBARA_API_KEY: Get from Scrapybara DashboardANTHROPIC_API_KEY(optional): If you want to use your own Anthropic API key
- Create a Supabase project
- Add to your
.env.local:NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY(from project settings)SUPABASE_SERVICE_ROLE_KEY(from project API settings)
Create the following tables using Supabase SQL Editor:
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
full_name TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
email TEXT UNIQUE NOT NULL,
encrypted_api_key TEXT
);CREATE TABLE searches (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(id),
searchId TEXT,
query TEXT,
enhanced_query TEXT,
sources JSONB,
summary TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
completed_at TIMESTAMPTZ,
completed BOOLEAN DEFAULT FALSE
);If you want to use your Anthropic API key directly, replace the following line in src/app/api/enhance-search/route.ts(150:2):
// From:
const anthro = anthropic({name: "claude-3-7-sonnet-20250219"});
// To:
const anthro = anthropic({
name: "claude-3-7-sonnet-20250219",
apikey: process.env.ANTHROPIC_API_KEY
});Note: Using Claude directly is slower than normal Scrapybara calls, but it may not matter if you're running on a VM.
Scrpexity is a search enhancement application that uses a multi-agent system to provide better search results:
-
Login & Authentication:
- User logs in using Google OAuth
- Upon first login, user enters their Scrapybara API key
- The API key is encrypted and stored in the database
- During user session, the API key is passed to the session for client-side access
-
Search Processing:
- User submits a query
- The query is enhanced by Gemini 2.5 Flash Light to improve search relevance
-
Multi-Agent Search System:
- First agent: Uses Scrapybara to enter the enhanced query into DuckDuckGo (preferred over Google for less AI filtering)
- Looping through search results (3 iterations):
- Agent 1: Opens the link
- Agent 2: Reads and extracts content from the page
- Agent 3: Closes the tab
- Previous data is tracked to avoid revisiting the same links
-
Results Compilation:
- All gathered information is fed to a summarizing agent
- The agent creates a concise summary with proper citations
-
Data Streaming & Storage:
- Results are streamed in real-time to the frontend
- All search data is stored in the database for future reference
-
Error Handling:
- Robust error handling for Scrapybara-related issues:
- Low API credits
- Session limits
- Invalid card errors
- And more for smooth user experience
- Robust error handling for Scrapybara-related issues:
The application uses streaming responses to show results in real-time, giving users immediate feedback as the search progresses.
- Fix Vercel streaming API issue (currently only receives first response in production)
- Implement webhooks for real-time page update
- Fix UI glitches in search results display
- Add rate limiting to prevent API abuse