How bhushan-amit/mini_perplexity_qna works
Project Type and Purpose
• This is a full-stack web application that offers a Q&A system. The backend retrieves information using the Bing Search API and processes it with OpenAI’s GPT-4 for generating answers. The frontend, built in React, provides a user interface for entering queries and displaying responses.
• The README clearly outlines the use of FastAPI for asynchronous handling and a clear separation of API responsibilities, while also providing deployment details to Render (backend) and Vercel (frontend).
Analyzing the File Structure
• At the top level, you have separate directories for the backend, frontend, and CI/CD configurations within the .github folder.
• Within the backend directory, notice:
• app directory with subdirectories for core configuration, main application startup, services (for Bing search and GPT integration), and tests to ensure functionality.
• The use of __init__.py files indicates a Python package structure that helps modularize the application.
• The requirements.txt file for dependencies.
• The frontend directory contains configuration files such as .env, package.json, and public resources like index.html. The src folder contains React components, indicating a clear separation of UI components (SearchBar, CitationList, etc.) and application logic.
• This organization shows a separation of concerns and hints at using an API-first design on the backend with React consuming these APIs on the frontend.
Key Components and Their Roles
• Frontend (React):
• Components: App, SearchBar, ResultDisplay, CitationList.
• Configuration files (.env) used to point to the backend API.
• Package dependencies managed by package.json and package-lock.json.
• Backend (FastAPI):
• Main entry point: backend/app/main.py.
• Configuration: backend/app/core/config.py for environment-specific settings.
• Services:
• bing_search.py: Interfaces with the Bing Search API to obtain web results.
• gpt_integration.py: Handles calls to the OpenAI GPT-4 model for generating query responses.
• Tests located in backend/app/tests to ensure core functionality.
• External Services:
• Bing Search API: For web results.
• OpenAI GPT-4: For generating responses.
• Deployment platforms: Render for backend deployment and Vercel for the frontend.
Relationships and Interactions
• The user interacts with the React frontend. Once a query is entered:
• The frontend sends the query to the FastAPI backend.
• The backend fetches relevant web data by calling the Bing Search API (via the bing_search.py service).
• The backend then processes this data and uses gpt_integration.py to generate a coherent answer using GPT-4.
• The final response, including citations from Bing, is sent back to the frontend for display.
Architectural Patterns and Design Principles
• Modular separation of concerns: Backend services are divided into configuration, main application logic, business services (for Bing and GPT), and tests.
• API-driven design: The FastAPI backend exposes endpoints that the React frontend consumes.
• Use of third-party APIs for search and AI generation, making the overall design extensible should you decide to add alternative providers.
• Component-based design in the frontend ensures the UI is maintainable and scalable.