Skip to content

ctrlxcvz/good-news-you-missed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌟 Good News Engine

An AI-powered autonomous curator that transforms doomscrolling into hope-scrolling

License: MIT Firebase Gemini

Features β€’ Demo β€’ Quick Start β€’ Roadmap β€’ Contributing


🎯 The Problem

Doomscrolling is destroying our mental health. Studies show 73% of news consumers experience anxiety from constant negative coverage. We built an autonomous AI agent that fights back.

πŸ’‘ The Solution

Every 6 hours, our serverless engine:

  1. πŸ” Scans 100+ global headlines
  2. πŸ€– AI-filters for genuinely uplifting stories (no toxic positivity)
  3. ✨ Summarizes with context and emotional intelligence
  4. πŸ“± Delivers hope directly to your app/feed

Zero maintenance. Zero cost (under 10K users). 100% good vibes.


✨ Features

Core Engine

  • 🧠 Smart AI Curation - Gemini 2.5 Flash enforces strict "Good News" criteria
    • ❌ No politics/crime/tragedy
    • βœ… Yes to science breakthroughs, human kindness, environmental wins
  • ⚑ Batch Processing - Analyzes 20+ articles per AI call (cost: ~$0.002/batch)
  • πŸ”„ Auto-Deduplication - URL fingerprinting prevents story repeats
  • 🧹 Self-Cleaning Database - 48-hour TTL keeps Firestore lean

Developer Experience

  • πŸš€ One-Command Deploy - firebase deploy --only functions
  • πŸ” Secret Manager Integration - No .env files, no leaked keys
  • πŸ“Š Built-in Analytics - Track filter rates and AI performance
  • πŸ§ͺ Local Testing Suite - Validate filters before deployment

🎬 Live Demo

Try the engine: goodnews-demo.web.app

Sample Output:

{
  "title": "Scientists Develop Plastic-Eating Enzyme 10x More Efficient",
  "summary": "Researchers at UT Austin engineered a bacterial enzyme that breaks down PET plastic in hours instead of centuries...",
  "category": "Environment",
  "sentiment": "breakthrough",
  "publishedAt": "2025-01-14T08:30:00Z"
}

πŸš€ Quick Start

Prerequisites

node --version  # 20+
firebase --version  # 13+

1. Clone & Install

git clone https://codeberg.org/yourusername/good-news-engine
cd good-news-engine
npm install

2. Get API Keys (Free Tiers)

  • NewsData.io: Get Key (200 requests/day free)
  • Gemini API: Get Key (1,500 requests/day free)

3. Configure Secrets

# Initialize Firebase
firebase login
firebase init functions

# Store keys securely
firebase functions:secrets:set GEMINI_API_KEY
firebase functions:secrets:set NEWSDATA_API_KEY

4. Deploy

firebase deploy --only functions
# βœ… Function deployed: https://us-central1-yourproject.cloudfunctions.net/fetchGoodNews

5. Test Manually

# Trigger the function
curl -X POST https://YOUR_FUNCTION_URL

# Check Firestore
firebase firestore:read goodNews --limit 5

πŸ“ Project Structure

good-news-engine/
β”œβ”€β”€ functions/
β”‚   β”œβ”€β”€ index.js           # Main Cloud Function
β”‚   β”œβ”€β”€ filters.js         # AI prompt templates
β”‚   └── package.json
β”œβ”€β”€ firestore.rules        # Security rules
β”œβ”€β”€ firebase.json
β”œβ”€β”€ README.md
└── .gitignore

πŸ›£οΈ Roadmap

Phase 1: Core Engine βœ… Complete

  • Automated fetching + filtering
  • Gemini 2.5 Flash integration
  • Firestore storage with TTL

Phase 2: Enhancement 🚧 In Progress

  • Category Tagging - Science, Environment, Health, etc.
  • Sentiment Scoring - "Inspiring" vs "Hopeful" vs "Breakthrough"
  • Multi-Language Support - Spanish, French, German (using Gemini's built-in translation)
  • RSS Feed Output - goodnews.rss for compatibility

Phase 3: Community Features πŸ“… Q2 2025

  • Upvote System - Let users vote on their favorite stories
  • Weekly Digest Email - Automated Mailchimp/SendGrid integration
  • Browser Extension - Replace "Trending News" with good news
  • Public API - Share good news with other developers

Phase 4: Scale & Monetization πŸ’‘ Future

  • Premium Tier - Custom filters, private instances ($5/mo)
  • White-Label Licensing - For mental health apps
  • Corporate Wellness - Slack/Teams integration

πŸ’° Cost Breakdown (Transparent Pricing)

Free Tier (0-1K users/day)

Service Usage Cost
NewsData.io 200 requests/day $0
Gemini API 1,500 requests/day $0
Firebase Functions 2M invocations/month $0
Firestore 50K reads/day $0
Total $0/month

Growth Tier (1K-10K users/day)

Service Usage Cost
NewsData.io 10K requests/month $0 (free tier)
Gemini API 45K requests/month $0 (free tier)
Firebase Functions 6M invocations/month $0
Firestore 1.5M reads/month ~$0.50
Total ~$0.50/month

Scale Tier (10K+ users/day)

Estimated at $15-30/month depending on traffic patterns. Contact us for optimization strategies.


πŸ› οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Cloud Schedulerβ”‚  (Every 6 hours)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Firebase Functionβ”‚
β”‚  fetchGoodNews  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ NewsData.io  β”‚  β”‚ Gemini 2.5   β”‚
β”‚  API Fetch   β”‚  β”‚  Flash AI    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                 β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚   Firestore DB  β”‚
       β”‚  (Auto-Cleanup) β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Decisions:

  1. Batch Processing - Process 20 articles in one AI call instead of 20 separate calls
  2. URL Fingerprinting - Hash URLs to prevent duplicate storage
  3. TTL Pattern - Store createdAt timestamp, query with where('createdAt', '>', 48hoursAgo)
  4. Stateless Functions - No persistent memory between runs

πŸ§ͺ Testing Locally

Run the function locally

firebase emulators:start --only functions,firestore

Test the AI filter

node test-gemini.js

Example test file (test-gemini.js):

const { analyzeArticles } = require('./functions/filters');

const mockArticles = [
  {
    title: "Local Dog Rescues Family from Fire",
    description: "Hero pup alerts sleeping family to kitchen blaze..."
  },
  {
    title: "Political Scandal Rocks Capital",
    description: "Corruption investigation expands..."
  }
];

analyzeArticles(mockArticles).then(results => {
  console.log('βœ… Good News:', results.filter(r => r.isGoodNews));
  console.log('❌ Filtered:', results.filter(r => !r.isGoodNews));
});

🀝 Contributing

We welcome contributions! Here are ways to help:

Low-Effort Contributions

  • πŸ› Report Bugs - Open an issue with reproduction steps
  • πŸ’‘ Suggest Features - Share your ideas in Discussions
  • πŸ“– Improve Docs - Fix typos, add examples
  • ⭐ Star the Repo - Help others discover this project

Code Contributions

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-idea)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-idea)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.


πŸ”’ Security

Secrets Management

  • Never commit API keys to version control
  • Use Firebase Secret Manager for production
  • Rotate keys every 90 days
  • Enable 2FA on all service accounts

Firestore Rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /goodNews/{article} {
      allow read: if true;  // Public read
      allow write: if false;  // Only Cloud Functions can write
    }
  }
}

Report Vulnerabilities

Email security@yourproject.com (do not open public issues for security bugs)


πŸ“œ License

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

TL;DR: You can use, modify, and distribute this freely. Just include the original license.


πŸ™ Acknowledgments

  • NewsData.io - For providing free news API access
  • Google AI - For Gemini 2.5 Flash's incredible filtering capabilities
  • Firebase Team - For the best serverless platform
  • You - For caring about mental health and positive news

πŸ“¬ Contact & Support


🌍 Join the Movement

Every deploy makes the internet a little brighter. ✨

If this project helped you, consider:

  • ⭐ Starring the repo
  • 🐦 Sharing on social media
  • πŸ’¬ Telling a friend who needs good news
  • β˜• Buy us a coffee

πŸ’° Support the Project

Find me on nostr, codeberg, and substack ONLY!

πŸ’œ nostr
πŸ’Ύ codeberg
πŸ“– substack

If you find this helpful, consider sending a tip!

Asset Address
Lightning (Zap) gallantdisk053@walletofsatoshi.com
Bitcoin (BTC) bc1q073hyc4gnd4zpr3zvxldqxd7pwusktw7tguu4g
Monero (XMR) 88hWjDuptnBerfkoTTAUhJ4AFuiMnMPSVVQhAbiV2rSEV7Gj2FaytRv1bnL8gPmL6U4L4XhFVBc4KbQLDmDM9hEaC4S1FV5

Zap Bitcoin Monero

πŸ’‘ Privacy Note

When sending Monero (XMR), your transaction is private by default. For Bitcoin, consider using a fresh address for each tip if you want to maintain maximum on-chain privacy.


Built with ❀️ and AI to fight doomscrolling

⬆ Back to Top

About

A curated, positive news PWA built with Next.js. Delivers an uplifting reading experience by filtering for good news, featuring a beautiful UI, offline reading, and one-tap installation. πŸš€ PWA-first, Android APK coming soon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors