How hackice20/perplexity-clone works
Main components
• Backend (Node.js/Express):
• Server (backend/src/server.js): Handles incoming API requests.
• AI Module (backend/src/ai.js): Interfaces with the Llama-3.3 AI model, likely hosted externally on Groq.
• Search Module (backend/src/search.js): Manages interactions with the Google Custom Search JSON API.
• Environment Configuration (backend/src/env.js) and .env.example: Manages application’s environment settings.
• Frontend (React/TypeScript):
• Main Application (frontend/src/App.tsx and frontend/src/main.tsx): Serves as the entry point and high-level component of the user interface.
• UI Components (e.g., SearchInput, SearchResults, Tooltip under frontend/src/components and its subdirectories): Handle user interactions and display results.
• Project Configuration and Styling: Files such as tailwind.config.js, vite.config.ts, and postcss.config.js indicating the use of Tailwind CSS and Vite for build and bundling.
Relationships and interactions
• Data Flow:
• The user interacts with the frontend UI. Actions (such as typing a query into the SearchInput component) trigger API calls.
• These API calls are directed to the backend server (Express) endpoints.
• The backend server uses the AI module to process the query with the Llama-3.3 model and the Search module to obtain results from the Google Custom Search API.
• Once processed, the backend sends the consolidated results back to the frontend, where components such as SearchResults display the output.
• External Services:
• External communication links from the backend to:
• The Llama-3.3 AI service (hosted on Groq).
• The Google Custom Search JSON API.
Important architectural patterns and design principles
• Separation of Concerns:
• Distinct division between frontend and backend responsibilities.
• Within the backend, separation into modules (AI, search, environment configuration) that encapsulate specific functionalities.
• API-driven Communication:
• RESTful API endpoints that bridge the frontend and backend.
• Modular, Component-based Frontend:
• React component hierarchy, depicting the relationship between the main application and its subcomponents.
Relevant technologies and frameworks
• Backend:
• Node.js, Express.js
• Use of configuration via environment variables (.env)
• Frontend:
• React and TypeScript for UI and type safety
• Tailwind CSS for styling
• Vite for development/build tooling