Skip to content

About

SeekEngine: An Open Source Search Engine Powered by Google API SeekEngine is a simple, responsive, and customizable AI search engine built with Next.js and powered by the Google Custom Search API & Openrouter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

540 Commits

Folders and files

Repository files navigation

SeekEngine

An AI-enhanced search engine with a minimalist design, dark/light mode support, and production-grade architecture.

Quick Start

1. Install Dependencies

npm install

2. Configure Environment Variables

Copy .env.example to .env.local and fill in your API keys:

cp .env.example .env.local

Minimum Required:

  • OPENROUTER_API_KEY - Get free key from OpenRouter (uses the openrouter/free router by default)

Optional:

  • OLLAMA_API_KEY - Ollama Cloud key (answer provider #2, default model beam: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-warm is 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 search
  • GOOGLE_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.

3. Run Development Server

npm run dev

Visit http://localhost:3000 in your browser.

Features

  • 🎨 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

Documentation

  • SETUP.md - Detailed installation, API key setup, and deployment guide
  • .env.example - Environment setup guide

Development

Build & Deploy

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.png

Project Structure

src/
├── 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

Architecture Highlights

OpenRouter Free Router + Failover

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.

Semantic Caching

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.

Edge Runtime

All APIs run on Vercel Edge Runtime for <100ms cold starts, globally replicated, with per-IP rate limiting and automatic key failover.

Tests

# Run all tests
npm test

# Watch mode
npm test:watch

# Run specific file
npm test -- models

Test Coverage:

  • Rate limiting logic
  • Model classification & naming
  • Error handling
  • Input sanitization
  • Query validation

Contributing

  1. Follow TypeScript strict mode
  2. Add tests for new features
  3. Use standardized error handling (Errors.*)
  4. Use structured logging (logger.*)
  5. Add JSDoc comments to exports

Performance

  • 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)

Security

  • 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)

License

MIT - See LICENSE for details.

Support

Common Issues

"OPENROUTER_API_KEY missing"

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.

About

SeekEngine: An Open Source Search Engine Powered by Google API SeekEngine is a simple, responsive, and customizable AI search engine built with Next.js and powered by the Google Custom Search API & Openrouter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages