Backend API for the Bubble Burst project - Break out of your information bubble with AI-powered opposing perspectives
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.
- π€ 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
βββββββββββββββββββ
β Client β
β Request β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Hono Web Server β
ββββββββββ¬βββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Driver (Orchestration) β
ββββββββββ¬βββββββββββββββββββββββββββββ
β
ββββββ΄βββββ¬βββββββββββββββ¬βββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
ββββββββββ ββββββββ βββββββββββ ββββββββββββ
βExtract β β GPT-4β β Google β β Return β
βArticle βββQuery ββ β Custom ββ β Articles β
β Text β β Gen β β Search β β β
ββββββββββ ββββββββ βββββββββββ ββββββββββββ
- Bun installed on your system
- OpenAI API key
- Google Custom Search API key and CX key
-
Clone the repository
git clone https://github.com/raptor1820/bubblebackendjs.git cd bubblebackendjs -
Install dependencies
bun install
-
Configure environment variables
Create a
.envfile 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
-
Start the server
bun run dev
The server will start on the default Hono port (typically 3000).
GET /?url={article_url}
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The URL of the article to analyze |
curl "http://localhost:3000/?url=https://example.com/article"[
{
"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": "error"
}| 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 |
-
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. -
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
-
Search & Retrieve: The AI-generated query is used with Google Custom Search API to find relevant articles with opposing perspectives.
-
Response: The service returns a curated list of articles with titles, links, and metadata.
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
- 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
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
}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
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
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Bun - the fast all-in-one JavaScript runtime
- Powered by OpenAI - making AI accessible
- Search by Google Custom Search API
Repository: raptor1820/bubblebackendjs
Built with β€οΈ to promote open-minded thinking
If this project helps you see different perspectives, consider giving it a β!