Discover the depths of knowledge with Fus-Search Bot, an intelligent AI-powered search and discovery engine that combines real-time web search with advanced AI analysis.
- β¨ Features
- π Quick Start
- π οΈ Technology Stack
- ποΈ Architecture
- π Project Structure
- π§ Configuration
- π¨ Design System
- π API Documentation
- π Deployment
- π‘ Usage Examples
- π§ͺ Testing
- π€ Contributing
- π License
- Multi-Source Web Search: Integrates SerpAPI, DuckDuckGo, and fallback systems
- Real-time Results: Live web scraping and content analysis
- Smart Fallbacks: Graceful degradation when APIs are unavailable
- Content Extraction: Deep content scraping from multiple sources
- Multi-Strategy Analysis: Factual, analytical, and contextual answer generation
- Query Classification: Automatically detects query types (definition, how-to, comparison, etc.)
- Confidence Scoring: AI-calculated confidence levels for answers
- Follow-up Generation: Intelligent follow-up question suggestions
- Apple-level Design: Sophisticated, clean interface with attention to detail
- Dark/Light Themes: Seamless theme switching with system preference detection
- Typing Animation: Engaging typewriter effect for AI responses
- Micro-interactions: Thoughtful hover states and smooth transitions
- Responsive Design: Optimized for mobile, tablet, and desktop
- Search History: Persistent search history with timestamp tracking
- Source Citations: Comprehensive source listing with relevance scores
- Real-time Status: Live indicators for search progress and AI analysis
- Error Handling: Graceful error recovery with user-friendly messages
Node.js >= 18.0.0
npm >= 8.0.0 or yarn >= 1.22.0-
Clone the repository
git clone https://github.com/your-username/fus-search-bot.git cd fus-search-bot -
Install dependencies
npm install # or yarn install -
Environment setup (Optional but recommended)
cp .env.example .env
Edit
.envwith your API keys:# Optional: Enhanced search capabilities VITE_SERPAPI_KEY=your_serpapi_key_here VITE_SCRAPER_API_KEY=your_scraper_api_key_here
-
Start development server
npm run dev # or yarn dev -
Open in browser
http://localhost:5173
While Fus-Search Bot works without API keys using fallback systems, adding these keys significantly enhances functionality:
- Purpose: Enhanced Google search results with better accuracy
- Get API Key: serpapi.com (100 free searches/month)
- Benefits: Real-time Google results, better source quality
- Purpose: Reliable content extraction from web pages
- Get API Key: scraperapi.com (1000 free requests/month)
- Benefits: Bypass CORS restrictions, better content extraction
- React 18.3.1: Modern React with hooks and concurrent features
- TypeScript 5.5.3: Full type safety and enhanced developer experience
- Vite 5.4.2: Lightning-fast build tool and dev server
- Tailwind CSS 3.4.1: Utility-first CSS framework
- Lucide React: Beautiful, customizable icons
- Custom Design System: Apple-inspired design principles
- SerpAPI: Google search results integration
- DuckDuckGo API: Privacy-focused search fallback
- Custom AI Service: Multi-strategy answer generation
- ScraperAPI: Content extraction and web scraping
- ESLint: Code linting with React and TypeScript rules
- PostCSS: CSS processing with Autoprefixer
- Vite Proxy: CORS handling for external APIs
graph TD
A[User Query] --> B[SearchInterface]
B --> C[useSearch Hook]
C --> D[WebSearchService]
C --> E[AIService]
D --> F[SerpAPI]
D --> G[DuckDuckGo API]
D --> H[Fallback Results]
F --> I[Content Scraping]
G --> I
H --> I
I --> E
E --> J[Multi-Strategy Analysis]
J --> K[Answer Generation]
K --> L[SearchResults Display]
class WebSearchService {
// Multi-source search with intelligent fallbacks
async searchWeb(query: string, numResults: number): Promise<Source[]>
// Content extraction from web pages
async scrapeContent(url: string): Promise<string>
// Contextual fallback results generation
private generateRelatedTopics(query: string): Array<{title: string, description: string}>
}class AIService {
// Main answer generation with confidence scoring
async generateAnswer(query: string, sources: Source[], content: string[]): Promise<{
answer: string;
followUpQuestions: string[];
confidence: number;
}>
// Multiple analysis strategies
private generateFactualAnswer(query: string, context: string): Promise<string>
private generateAnalyticalAnswer(query: string, context: string): Promise<string>
private generateContextualAnswer(query: string, context: string): Promise<string>
}- Query Input: User enters search query in SearchInterface
- Search Execution: useSearch hook triggers WebSearchService
- Multi-Source Search:
- Primary: SerpAPI for Google results
- Fallback: DuckDuckGo API
- Final Fallback: Contextual topic generation
- Content Extraction: Scrape detailed content from top sources
- AI Processing: AIService analyzes content using multiple strategies
- Response Generation: Comprehensive answer with citations
- Display: SearchResults shows answer with typing animation
The application implements a robust 3-tier fallback system:
// Tier 1: SerpAPI (Premium Google results)
try {
return await this.searchWithSerpAPI(query, numResults);
} catch {
// Tier 2: DuckDuckGo (Free alternative)
try {
return await this.searchWithDuckDuckGo(query, numResults);
} catch {
// Tier 3: Contextual fallbacks (Always available)
return await this.getFallbackResults(query);
}
}fus-search-bot/
βββ π public/ # Static assets
βββ π src/
β βββ π components/ # React components
β β βββ SearchInterface.tsx # Main search input component
β β βββ SearchResults.tsx # AI response display component
β β βββ SearchHistory.tsx # Search history management
β βββ π hooks/ # Custom React hooks
β β βββ useSearch.ts # Main search logic hook
β βββ π services/ # Business logic services
β β βββ webSearch.ts # Web search and scraping service
β β βββ aiService.ts # AI processing and analysis service
β βββ π types/ # TypeScript definitions
β β βββ index.ts # Shared type definitions
β βββ App.tsx # Main application component
β βββ main.tsx # Application entry point
β βββ index.css # Global styles and Tailwind imports
βββ π package.json # Dependencies and scripts
βββ π vite.config.ts # Vite configuration with proxy setup
βββ π tailwind.config.js # Tailwind CSS configuration
βββ π tsconfig.json # TypeScript configuration
βββ π README.md # This file
- Search input with real-time suggestions
- Error handling and loading states
- Query suggestions based on topic categories
- Form validation and submission
- Typing animation for AI responses
- Source citations with metadata
- Confidence scoring display
- Follow-up question generation
- Persistent search history
- Click-to-search functionality
- History management (clear, limit)
| Variable | Type | Description | Required | Default |
|---|---|---|---|---|
VITE_SERPAPI_KEY |
string | SerpAPI key for Google search | No | - |
VITE_SCRAPER_API_KEY |
string | ScraperAPI key for content extraction | No | - |
// vite.config.ts
export default defineConfig({
plugins: [react()],
optimizeDeps: {
exclude: ['lucide-react'],
},
server: {
proxy: {
'/api/serpapi': {
target: 'https://serpapi.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/serpapi/, ''),
secure: true,
}
}
}
});// tailwind.config.js
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {
// Custom design system extensions
},
},
plugins: [],
};/* Primary Colors */
--purple-500: #8b5cf6
--purple-600: #7c3aed
--pink-500: #ec4899
--pink-600: #db2777
/* Neutral Colors */
--gray-50: #f9fafb
--gray-900: #111827
--slate-800: #1e293b
--slate-900: #0f172a- Headings: Inter font family, 120% line height
- Body: Inter font family, 150% line height
- Code: JetBrains Mono, monospace
Based on 8px grid system:
space-1: 4pxspace-2: 8pxspace-4: 16pxspace-6: 24pxspace-8: 32px
backdrop-blur-xl bg-white/70 border border-white/20 shadow-xlbg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600interface SearchParams {
query: string;
numResults?: number; // Default: 10
}
interface Source {
id: string;
title: string;
url: string;
snippet: string;
domain: string;
publishedDate?: string;
relevanceScore?: number;
}interface ScrapingResult {
url: string;
content: string; // Extracted text content
success: boolean;
}interface AIResponse {
answer: string;
followUpQuestions: string[];
confidence: number; // 0.0 - 1.0
}The application implements comprehensive error handling:
// Graceful degradation
try {
// Primary API call
} catch (primaryError) {
try {
// Fallback API call
} catch (fallbackError) {
// Use offline/cached results
}
}# Create optimized production build
npm run build
# Preview production build locally
npm run preview-
Build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
-
Environment variables:
VITE_SERPAPI_KEY=your_key_here VITE_SCRAPER_API_KEY=your_key_here
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod- Code Splitting: Automatic route-based splitting
- Tree Shaking: Unused code elimination
- Asset Optimization: Image and CSS optimization
- Caching: Aggressive caching for static assets
// Simple factual questions
"What is quantum computing?"
"How does photosynthesis work?"
"Define machine learning"
// Current events
"Latest developments in renewable energy"
"Recent AI breakthroughs 2024"
"Current space exploration missions"
// Comparative analysis
"React vs Vue.js comparison"
"Electric cars vs hybrid vehicles"
"iOS vs Android development"
// How-to queries
"How to start a podcast"
"How to learn Python programming"
"How to invest in stocks"After each search, Fus-Search Bot generates intelligent follow-up questions:
- Related topics exploration
- Deeper technical details
- Practical applications
- Future implications
- Persistent across sessions
- Click to re-search
- Timestamp tracking
- Easy history management
- High (80%+): Multiple reliable sources, comprehensive content
- Medium (60-80%): Good sources, moderate content depth
- Lower (<60%): Limited sources or content
- Search functionality with various query types
- Dark/light mode switching
- Responsive design on different screen sizes
- Error handling with invalid queries
- API fallback systems
- Search history functionality
- Follow-up question generation
# Lighthouse audit
npm run build
npm run preview
# Run Lighthouse on localhost:4173Test the fallback system by:
- Testing without API keys (fallback mode)
- Testing with invalid API keys (error handling)
- Testing with valid API keys (full functionality)
- Fork the repository
- Create feature branch
git checkout -b feature/amazing-feature
- Make changes and test
- Commit with conventional commits
git commit -m "feat: add amazing feature" - Push and create PR
- TypeScript: Strict mode enabled
- ESLint: React and TypeScript rules
- Prettier: Code formatting
- Conventional Commits: Commit message format
- Update documentation if needed
- Add tests for new features
- Ensure all checks pass
- Request review from maintainers
- Voice Search: Speech-to-text integration
- Export Results: PDF/Markdown export functionality
- Advanced Filters: Date, source type, language filters
- Collaborative Features: Share searches and results
- API Integration: More search providers
- Offline Mode: Cached results for offline access
- Caching Layer: Redis-based result caching
- CDN Integration: Global content delivery
- Progressive Loading: Incremental result loading
- Background Sync: Pre-fetch popular queries
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Fus-Search Bot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- Inspiration: Perplexity AI, Morphic, and modern search engines
- Design: Apple's Human Interface Guidelines
- Icons: Lucide React icon library
- APIs: SerpAPI and ScraperAPI for enhanced functionality
- Community: React and TypeScript communities
- Documentation: Check this README and inline code comments
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for questions and ideas
When reporting bugs, please include:
- Browser and version
- Steps to reproduce
- Expected vs actual behavior
- Console errors (if any)
- Screenshots (if applicable)
For feature requests, please describe:
- Use case and motivation
- Proposed solution
- Alternative solutions considered
- Additional context
π Fus-Search Bot - Discover the depths of knowledge with intelligent AI-powered search and discovery π
β Star this repo | π Report Bug | π‘ Request Feature | π€ Contribute
