Skip to content

Backend API that uses AI to find opposing viewpoints for any article, helping users break out of their information bubbles

Notifications You must be signed in to change notification settings

raptor1820/bubblebackendjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🫧 Bubble Burst Backend

Backend API for the Bubble Burst project - Break out of your information bubble with AI-powered opposing perspectives

Built with Bun Powered by OpenAI License


🎯 What is Bubble Burst Backend?

Bubble Burst Backend is the server-side component of the Bubble Burst project - an intelligent API service designed to combat confirmation bias and filter bubbles. Give it any article URL, and it will use AI to find and return articles with opposing viewpoints on the same topic.

This backend powers the Bubble Burst application by providing the core intelligence layer that analyzes articles, generates smart search queries, and discovers opposing perspectives. In an era of echo chambers and algorithmic content curation, it helps users see the full picture by exposing them to diverse viewpoints they might otherwise never encounter.

✨ Features

  • πŸ€– AI-Powered Analysis - Uses GPT-4 Turbo to understand article sentiment and topic
  • πŸ” Smart Search - Automatically generates optimized Google queries for opposing viewpoints
  • πŸ“° Article Extraction - Cleanly extracts and processes article content
  • ⚑ Lightning Fast - Built on Bun for maximum performance
  • 🌐 RESTful API - Simple HTTP interface for easy integration
  • πŸ”’ CORS Enabled - Ready for web application integration

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client        β”‚
β”‚   Request       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Hono Web Server                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Driver (Orchestration)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚         β”‚              β”‚            β”‚
    β–Ό         β–Ό              β–Ό            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Extract β”‚ β”‚ GPT-4β”‚  β”‚ Google  β”‚  β”‚  Return  β”‚
β”‚Article β”‚β†’β”‚Query β”‚β†’ β”‚ Custom  β”‚β†’ β”‚ Articles β”‚
β”‚ Text   β”‚ β”‚ Gen  β”‚  β”‚ Search  β”‚  β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Bun installed on your system
  • OpenAI API key
  • Google Custom Search API key and CX key

Installation

  1. Clone the repository

    git clone https://github.com/raptor1820/bubblebackendjs.git
    cd bubblebackendjs
  2. Install dependencies

    bun install
  3. Configure environment variables

    Create a .env file in the root directory:

    OPENAI_API_KEY=your_openai_api_key_here
    GOOGLE_SEARCH_KEY=your_google_search_api_key
    GOOGLE_CX_KEY=your_google_cx_key
  4. Start the server

    bun run dev

The server will start on the default Hono port (typically 3000).

πŸ“‘ API Usage

Endpoint

GET /?url={article_url}

Parameters

Parameter Type Required Description
url string Yes The URL of the article to analyze

Example Request

curl "http://localhost:3000/?url=https://example.com/article"

Example Response

[
    {
        "title": "Alternative Perspective on Topic",
        "displayLink": "example.com",
        "link": "https://example.com/opposing-view",
        "read_time": "0 min"
    },
    {
        "title": "Different Take on Subject",
        "displayLink": "news.com",
        "link": "https://news.com/counterpoint",
        "read_time": "0 min"
    }
]

Error Response

{
    "error": "error"
}

πŸ› οΈ Technology Stack

Technology Purpose
Bun Runtime & Package Manager
Hono Lightweight Web Framework
OpenAI GPT-4 AI-Powered Query Generation
Google Custom Search API Article Discovery
@extractus/article-extractor Content Extraction
TypeScript Type Safety

πŸ”§ How It Works

  1. Article Extraction: The service fetches the provided URL and extracts the main article text using @extractus/article-extractor, stripping away HTML and leaving clean content.

  2. AI Analysis: The extracted text is sent to GPT-4 Turbo with a specialized prompt that:

    • Identifies the main subject of the article
    • Determines the sentiment/perspective
    • Generates a Google search query designed to find opposing viewpoints
  3. Search & Retrieve: The AI-generated query is used with Google Custom Search API to find relevant articles with opposing perspectives.

  4. Response: The service returns a curated list of articles with titles, links, and metadata.

πŸ“‚ Project Structure

bubblebackendjs/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Main server & routing
β”‚   β”œβ”€β”€ driver.ts             # Orchestration logic
β”‚   β”œβ”€β”€ extractArticleText.ts # Article content extraction
β”‚   β”œβ”€β”€ genGoogleQuery.ts     # AI query generation
β”‚   └── getArticles.ts        # Google search integration
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ bun.lockb
└── README.md

🎨 Use Cases

  • News Aggregation Apps: Show users both sides of controversial topics
  • Research Tools: Help researchers find counterarguments and alternative perspectives
  • Educational Platforms: Teach critical thinking by exposing students to diverse viewpoints
  • Browser Extensions: Add a "See Opposing Views" button to any article
  • Content Moderation: Understand the full context of polarizing topics

βš™οΈ Configuration

OpenAI Settings

The GPT-4 query generation can be customized in src/genGoogleQuery.ts:

{
  model: "gpt-4-turbo",
  temperature: 0.7,      // Creativity vs consistency
  max_tokens: 20,        // Query length limit
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0
}

πŸ”— Related Projects

This is the backend component of the Bubble Burst project. The complete Bubble Burst ecosystem includes:

  • Backend API (this repository) - The intelligent service layer
  • Frontend Application - User interface for interacting with the service

🀝 Contributing

Contributions are welcome! Here are some ideas for improvements:

  • Add caching to reduce API costs
  • Implement rate limiting
  • Add support for multiple languages
  • Include article summaries in responses
  • Add sentiment analysis scores
  • Enhance integration with frontend
  • Add automated tests

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Acknowledgments

πŸ“§ Contact

Repository: raptor1820/bubblebackendjs


Built with ❀️ to promote open-minded thinking

If this project helps you see different perspectives, consider giving it a ⭐!

About

Backend API that uses AI to find opposing viewpoints for any article, helping users break out of their information bubbles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published