A sophisticated AI-powered search engine that combines real-time web search with intelligent content summarization, built with modern web technologies and advanced AI integration.
https://perplexity-ai-clone-theta.vercel.app/
- Overview
- Key Features
- Technology Stack
- Architecture
- Installation
- Usage
- API Integration
- Database Schema
- Performance Optimizations
- Contributing
- License
This project is a full-featured clone of Perplexity AI, demonstrating advanced full-stack development capabilities. It combines real-time web search with AI-powered content analysis to provide intelligent, comprehensive answers to user queries.
- Real-time Search Integration: Leverages Brave Search API for up-to-date information
- AI-Powered Summarization: Uses Google's Gemini 2.0 Flash for intelligent content processing
- Asynchronous Processing: Background job processing with Inngest for optimal performance
- Modern UI/UX: Responsive design with advanced loading states and animations
- Scalable Architecture: Microservices approach with separated concerns
Below are some screenshots demonstrating the main features and UI of the Perplexity AI Clone:
The landing page with a clean, modern interface for starting your search.
Browse trending topics and categories for inspiration and exploration.
Interactive chat interface for asking questions and receiving AI-powered answers.
Seamless conversation flow with persistent chat history.
View sources and references for AI-generated answers, ensuring transparency.
Organized storage of your previous searches and responses for easy access.
- Real-time web search (Brave API) with AI summarization
- Multi-format results (web, images, videos, news)
- Category-based discovery (Tech, Finance, Sports, etc.)
- Advanced filtering and sorting capabilities
- Gemini 2.0 Flash Integration: Latest Google AI model for content processing
- Background Processing: Non-blocking AI operations with Inngest
- Rich Content Formatting: Markdown rendering with syntax highlighting
- Responsive Design: Mobile-first approach with Tailwind CSS
- Tabbed Interface: Organized content display (Answer, Images, Videos, Sources)
- Real-time Loading States: Skeleton loaders and progress indicators
- Interactive Components: Advanced UI components with Radix UI
- Supabase Integration: PostgreSQL backend with real-time capabilities
- Chat History: Persistent conversation storage
- Library Management: Organized query and response storage
- User Authentication: Secure user management with Clerk
- Next.js 15.3.3 - React framework with App Router
- React 19.0.0 - Latest React with concurrent features
- Tailwind CSS 4.0 - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Lucide React - Beautiful icon library
- Brave Search API - Real-time web search
- Google Gemini 2.0 Flash - AI content processing
- Inngest - Background job processing
- Supabase - Database and authentication
- Clerk - User authentication and management
- TypeScript - Type-safe development
- ESLint - Code quality and consistency
- PostCSS - CSS processing
- UUID - Unique identifier generation
The application follows a modern, scalable architecture:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β API Layer ββββββΊβ AI Processing β
β (Next.js) βββββΊβ (Route.js) β βββΊβ (Inngest) β
βββββββββββββββββββ βββββββββββββββββββ β βββββββββββββββββββ
β β β β
βΌ βΌ β βΌ
βββββββββββββββββββ βββββββββββββββββββ β βββββββββββββββββββ
β UI Components β β Brave API β β β Gemini AI β
β (React) β β (Search) β β β (Processing) β
βββββββββββββββββββ βββββββββββββββββββ β βββββββββββββββββββ
β β β β
βΌ βΌ β βΌ
βββββββββββββββββββ βββββββββββββββββββ β βββββββββββββββββββ
β State Mgmt β β Database ββββ β Authenticationβ
β (Context) β β (Supabase) β β (Clerk) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- User Input β Search query submission
- Brave API β Real-time web search results
- Database Storage β Search results and metadata
- AI Processing β Background Gemini analysis
- Response Generation β Formatted markdown content
- UI Update β Real-time display with loading states
- Node.js 18+
- npm or yarn
- Supabase account
- Brave Search API key
- Google Gemini API key
- Clerk account
-
Clone the repository
git clone https://github.com/Hrishubh/perplexity-ai-clone.git cd perplexity-ai-clone
-
Install dependencies
npm install
-
Environment Configuration Create a
.env.local
file with the following variables:# Supabase Configuration NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_KEY=your_supabase_anon_key # API Keys NEXT_PUBLIC_BRAVE_API_KEY=your_brave_api_key NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_api_key # Authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key # Inngest Configuration INNGEST_EVENT_KEY=your_inngest_event_key INNGEST_SIGNING_KEY=your_inngest_signing_key
-
Database Setup
-- Create Library table CREATE TABLE Library ( id SERIAL PRIMARY KEY, libId UUID UNIQUE NOT NULL, searchInput TEXT NOT NULL, userEmail TEXT, type TEXT DEFAULT 'search', created_at TIMESTAMP DEFAULT NOW() ); -- Create Chats table CREATE TABLE Chats ( id SERIAL PRIMARY KEY, libId UUID REFERENCES Library(libId), searchResult JSONB, userSearchInput TEXT, aiResp TEXT, created_at TIMESTAMP DEFAULT NOW() );
-
Run the development server
npm run dev
- Open your browser Navigate to http://localhost:3000
- Enter your query in the search box
- Choose between "Search" or "Research" modes
- Click the search button or press Enter
- View real-time search results while AI processes
- Explore the comprehensive AI-generated summary
- Tabbed Navigation: Switch between Answer, Images, Videos, and Sources
- Category Discovery: Browse trending topics by category
- Chat History: Access previous searches and responses
- Real-time Updates: Monitor AI processing status
// Real-time web search
const result = await axios.post("/api/brave-search-api", {
searchInput: query,
searchType: "search"
});
// Background AI processing
const aiResp = await step.ai.infer("generate-ai-llm-model-call", {
model: step.ai.models.gemini({
model: "gemini-2.0-flash",
apiKey: process.env.NEXT_PUBLIC_GEMINI_API_KEY,
})
});
// Asynchronous processing
const inngestRunId = await inngest.send({
name: "llm-model",
data: { searchInput, searchResult, recordId }
});
id
: Primary keylibId
: Unique identifier for search sessionssearchInput
: User's search queryuserEmail
: Associated user emailtype
: Search type (search/research)created_at
: Timestamp
id
: Primary keylibId
: Foreign key to LibrarysearchResult
: JSONB search resultsuserSearchInput
: Original user inputaiResp
: AI-generated responsecreated_at
: Timestamp
- Next.js App Router: Server-side rendering and static generation
- Code Splitting: Automatic route-based code splitting
- Image Optimization: Next.js Image component with lazy loading
- CSS Optimization: Tailwind CSS with PurgeCSS
- Background Processing: Non-blocking AI operations
- Database Indexing: Optimized queries with proper indexing
- Caching Strategy: Efficient data retrieval patterns
- API Rate Limiting: Protection against abuse
- Asynchronous Jobs: Inngest for scalable background processing
- Model Optimization: Gemini 2.0 Flash for speed and accuracy
- Response Caching: Store processed results for reuse
- Error Handling: Graceful degradation and retry mechanisms
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
- Perplexity AI - For inspiration and feature reference
- Brave Search - For providing the search API
- Google Gemini - For AI processing capabilities
- Supabase - For database and authentication services
- Clerk - For user management
- Inngest - For background job processing
- GitHub: @Hrishubh
- LinkedIn: Hrishubh Bhandari
- Email: [email protected]
β Star this repository if you found it helpful!
Made with β€οΈ by Hrishubh Bhandari