An AI-enhanced search engine with a minimalist design, dark/light mode support, and production-grade architecture.
npm installCopy .env.example to .env.local and fill in your API keys:
cp .env.example .env.localMinimum Required:
OPENROUTER_API_KEY- Get free key from OpenRouter (uses theopenrouter/freerouter by default)
Optional:
OLLAMA_API_KEY- Ollama Cloud key (answer provider #2, default modelbeam:cloud— Reflection's Beam, zero data retention, free on Ollama Cloud for a limited time)EXA_API_KEY- Exa key (neural search grounding; leads the parallel fan-out, OSINT-oriented; not used for answers)UPSTASH_REDIS_REST_URL+UPSTASH_REDIS_REST_TOKEN- Upstash Redis (optional — shared answer/search/suggestion caches and rate limiting across edge instances; falls back to in-memory when unset)LAYERBASE_REDIS_REST_URL+LAYERBASE_REDIS_REST_TOKEN- Fallback/warm Redis (any Upstash-compatible REST endpoint such as Layerbase; written to best-effort alongside the primary;/api/cron/redis-warmis pinged every 10 min by GitHub Actions to keep it from sleeping)CRON_SECRET- Bearer token protecting the warm endpoint (see.github/workflows/redis-warm.yml)SERPAPI_KEY- For real-time Google searchGOOGLE_SEARCH_API_KEY+GOOGLE_SEARCH_CX- Alternative search provider
Resilient provider chains (last-resort paths need no keys):
- AI answers: OpenRouter → Ollama Cloud → local synthesis of sources (no LLM key required)
- Web search: SerpAPI + Google Custom Search + Exa (neural, leads the merge) + DuckDuckGo → fanned out in parallel, merged and deduped
See .env.example for detailed setup instructions.
npm run devVisit http://localhost:3000 in your browser.
- 🎨 Ultra-minimalist design with dark/light mode
- 🔍 Real-time AI suggestions powered by OpenRouter
- 📊 AI-generated summaries with traditional web results
- ⚡ Sub-100ms response times (Edge Runtime)
- 📱 Mobile-first responsive layout
- ♿ Accessible (ARIA labels, keyboard navigation)
- 🔐 Production-grade architecture with:
- openrouter/free router + automatic provider failover
- Semantic caching for duplicate queries (per instance)
- Rate limiting per IP
- Input sanitization
- Structured error handling
- Comprehensive logging
- SETUP.md - Detailed installation, API key setup, and deployment guide
- .env.example - Environment setup guide
npm run build # Production build
npm start # Run production server
npm run lint # Check code quality
npm test # Run test suite
npm test:watch # Watch mode
node scripts/generate-og-image.mjs # Regenerate public/og-image.pngsrc/
├── app/
│ ├── page.tsx # Home page
│ ├── results/ # Search results page
│ ├── api/
│ │ └── ai/
│ │ ├── stream/ # Streaming answers (main feature)
│ │ ├── suggest/ # AI suggestions
│ │ └── cache/ # Cache monitoring
│ └── api/search/ # Web search aggregation
├── components/
│ ├── search/ # Search UI components
│ ├── layout/ # Layout components
│ └── ui/ # Base UI components
├── hooks/
│ ├── useSearch.ts # Search state management
│ ├── useStreamingAnswer.ts # SSE consumer
│ └── useSearchHistory.ts # History persistence
└── lib/
├── constants.ts # All magic numbers
├── errors.ts # Error types & formatting
├── logger.ts # Structured logging
├── sanitize.ts # Input validation
├── openrouter/ # AI integration
└── rate-limit.ts # Rate limiting
Answers stream from OpenRouter's openrouter/free router (override with OPENROUTER_MODEL), with automatic failover to Ollama Cloud → a locally synthesized, citation-linked answer — so the app still returns a grounded result if every LLM provider is down.
Normalize queries to catch "What is AI?" vs "what IS artificial intelligence?" as the same question, returning cached answers instantly. Note: caches live in the edge instance's memory — each instance has its own, so hit rates follow instance traffic.
All APIs run on Vercel Edge Runtime for <100ms cold starts, globally replicated, with per-IP rate limiting and automatic key failover.
# Run all tests
npm test
# Watch mode
npm test:watch
# Run specific file
npm test -- modelsTest Coverage:
- Rate limiting logic
- Model classification & naming
- Error handling
- Input sanitization
- Query validation
- Follow TypeScript strict mode
- Add tests for new features
- Use standardized error handling (
Errors.*) - Use structured logging (
logger.*) - Add JSDoc comments to exports
- Search Results: fast when warm (15s Redis context cache); cold path bounded by the slowest provider
- AI Answer: <2-3s (model racing + streaming)
- Suggestions: <1s (cached)
- Cache Hits: <50ms (instant)
- Input sanitization on all queries
- Input sanitization on all queries
- Rate limiting per IP
- No API keys in client code
- Structured error messages (no details leaked)
MIT - See LICENSE for details.
"OPENROUTER_API_KEY missing"
- Create
.env.local(see .env.example) - Get free key from OpenRouter
- Restart
npm run dev
Search returning no results
- All providers are queried in parallel; results are merged and deduped (Exa leads); only if every provider fails does the endpoint error
- Check the dev server console — each provider logs a warning with its failure reason
- Check that rate limit not exceeded
Slow first query
- First query has model racing lookup (~2s)
- Subsequent queries cached (~50ms)
- Model list cached (10 min TTL)
For environment setup see .env.example; for deployment see SETUP.md.
Built with Next.js, React, TypeScript, Tailwind CSS, and OpenRouter AI.