Skip to content

Esstar612/newspaper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฐ The Newspaper

A modern, full-stack news aggregation platform with real-time weather forecasts and stock market data. Built with Next.js 16, TypeScript, and MongoDB.

Next.js TypeScript MongoDB Vercel License

Live Demo | Report Bug | Request Feature


โœจ Features

๐Ÿ“ฐ Multi-Source News Aggregation

  • Real-time news from NewsAPI and New York Times
  • Automatic daily updates via cron jobs
  • Search and filter by source, keywords, or date
  • 400+ articles daily across 6 categories:
    • Business
    • Technology
    • World News
    • Science
    • Health
    • Sports

๐ŸŒค๏ธ Weather Dashboard

  • Real-time weather data from OpenWeatherMap
  • 5-day forecast with hourly breakdowns
  • Interactive visualizations using Recharts:
    • Temperature bar charts
    • Humidity line graphs
    • Weather condition pie charts
  • Location autocomplete with geocoding
  • Geolocation support for automatic location detection

๐Ÿ“ˆ Stock Market Data

  • Real-time stock prices via Market Data API
  • Support for major stock symbols (AAPL, GOOGL, TSLA, etc.)
  • Multi-currency conversion (USD, EUR, GBP, JPY, etc.)
  • Clean, responsive card-based interface

๐Ÿค– Automated Data Management

  • Cron jobs for automatic news ingestion (daily at midnight UTC)
  • Database cleanup to maintain optimal performance (7-day retention)
  • Smart deduplication to prevent duplicate articles
  • Efficient MongoDB indexing for fast queries

๐Ÿš€ Demo

Landing Page Modern landing page with feature cards and smooth animations

News Feed Searchable news feed with category filtering

Weather Dashboard Interactive weather dashboard with data visualizations


๐Ÿ› ๏ธ Tech Stack

Frontend

  • Next.js 16 (App Router, React Server Components)
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling
  • Recharts - Data visualization library

Backend

  • Next.js API Routes - Serverless functions
  • MongoDB Atlas - Cloud database
  • Mongoose - ODM for MongoDB

APIs & Services

  • NewsAPI - News headlines
  • New York Times API - Premium news content
  • OpenWeatherMap API - Weather data
  • Market Data API - Stock market data
  • Frankfurter API - Currency conversion
  • BigDataCloud API - Geolocation

DevOps

  • Vercel - Deployment and hosting
  • Vercel Cron Jobs - Scheduled tasks
  • GitHub Actions - CI/CD (optional)

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have:


โšก Quick Start

1. Clone the repository

git clone https://github.com/Esstar612/newspaper.git
cd newspaper

2. Install dependencies

npm install

3. Set up environment variables

Create a .env.local file in the root directory:

# MongoDB
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/newspaper

# News APIs
NEWS_API_KEY=your_newsapi_key
NYT_API_KEY=your_nyt_api_key

# Weather API
OPENWEATHER_API_KEY=your_openweather_key

# Stock Market API
MARKET_DATA_API_KEY=your_market_data_key

# Cron Security (optional but recommended)
CRON_SECRET=your_secret_key_here

4. Run the development server

npm run dev

Open http://localhost:3000 in your browser.

5. Build for production

npm run build
npm start

๐Ÿ—„๏ธ Database Schema

Article Model

{
  title: String,           // Article headline
  description: String,     // Article summary
  url: String,            // Article URL (unique)
  imageUrl: String,       // Featured image
  source: String,         // News source (NYT, NewsAPI, etc.)
  publishedAt: Date,      // Publication date
  providerId: String,     // Source-specific ID
  createdAt: Date,        // Auto-generated
  updatedAt: Date         // Auto-generated
}

Indexes

  • url: Unique index for deduplication
  • publishedAt: Sorted queries
  • source + publishedAt: Filtered sorted queries

๐Ÿ”„ Cron Jobs

The app uses Vercel Cron Jobs to automate data management:

News Ingestion (0 0 * * * - Daily at midnight UTC)

// Fetches from multiple sources
- NewsAPI: 100 articles
- NYT Business: 50 articles
- NYT Technology: 50 articles
- NYT World: 50 articles
- NYT Science: 50 articles
- NYT Health: 50 articles
- NYT Sports: 50 articles
// Total: ~400 articles/day

Database Cleanup (0 3 * * * - Daily at 3 AM UTC)

// Maintains optimal database size
- Removes articles older than 7 days
- Keeps ~14,000 articles max
- Database size: ~14 MB

๐Ÿ“Š API Usage & Costs

All APIs are used within free tier limits:

API Daily Usage Free Limit % Used
NewsAPI 1 call 100 calls 1%
NYT API 6 calls 500 calls 1.2%
OpenWeatherMap On-demand 1,000 calls Variable
Market Data On-demand 100 calls Variable

Total Cost: $0/month ๐ŸŽ‰


๐ŸŽจ Features Breakdown

News Page

  • Search: Full-text search across titles and descriptions
  • Filters: Filter by news source (NewsAPI, NYT, etc.)
  • Pagination: Cursor-based pagination for infinite scroll
  • Responsive Cards: Beautiful article cards with images
  • External Links: Direct links to original articles

Weather Page

  • Current Weather: Temperature, conditions, humidity
  • 5-Day Forecast: Detailed hourly predictions
  • Location Search: Autocomplete city search
  • Geolocation: Automatic location detection
  • Visualizations:
    • Temperature trends (bar chart)
    • Humidity patterns (line chart)
    • Weather distribution (pie chart)

Stocks Page

  • Real-Time Prices: Live stock market data
  • Currency Conversion: Convert to 30+ currencies
  • Popular Stocks: Quick access to major symbols
  • Clean UI: Simple, readable design

๐Ÿš€ Deployment

Deploy to Vercel

  1. Fork this repository

  2. Import to Vercel

  • Go to vercel.com/new
  • Import your forked repository
  • Vercel will auto-detect Next.js
  1. Add Environment Variables
  • Go to Project Settings โ†’ Environment Variables
  • Add all keys from .env.local
  1. Deploy
  • Click "Deploy"
  • Your app will be live in ~2 minutes!
  1. Verify Cron Jobs
  • Go to Project Settings โ†’ Crons
  • You should see 2 cron jobs listed

Custom Domain (Optional)

  1. Go to Project Settings โ†’ Domains
  2. Add your custom domain
  3. Configure DNS records as instructed

๐Ÿงช Testing

Run all tests

npm test

Test specific API routes

# Test news ingestion
curl http://localhost:3000/api/cron/ingest-news

# Test weather API
curl http://localhost:3000/api/weather?q=London

# Test stock API
curl http://localhost:3000/api/stocks/AAPL

๐Ÿ“ Project Structure

newspaper/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ admin/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ingest-news/      # Manual news ingestion
โ”‚   โ”‚   โ”œโ”€โ”€ cron/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ingest-news/      # Automated news fetch
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ cleanup-old-news/ # Database cleanup
โ”‚   โ”‚   โ”œโ”€โ”€ forecast/             # Weather forecast
โ”‚   โ”‚   โ”œโ”€โ”€ geocoding/            # Location search
โ”‚   โ”‚   โ”œโ”€โ”€ news/                 # News feed API
โ”‚   โ”‚   โ”œโ”€โ”€ stocks/[symbol]/      # Stock data
โ”‚   โ”‚   โ””โ”€โ”€ weather/              # Current weather
โ”‚   โ”œโ”€โ”€ news/                     # News page
โ”‚   โ”œโ”€โ”€ stocks/                   # Stocks page
โ”‚   โ”œโ”€โ”€ weather/                  # Weather page
โ”‚   โ””โ”€โ”€ page.tsx                  # Landing page
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ ArticleCard.tsx           # News article card
โ”‚   โ”œโ”€โ”€ Header.tsx                # Navigation header
โ”‚   โ”œโ”€โ”€ TemperatureBarGraph.tsx   # Weather chart
โ”‚   โ”œโ”€โ”€ HumidityLineGraph.tsx     # Weather chart
โ”‚   โ””โ”€โ”€ WeatherPieChart.tsx       # Weather chart
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ db.ts                     # MongoDB connection
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ Article.ts                # Article schema
โ”œโ”€โ”€ public/                       # Static assets
โ”œโ”€โ”€ vercel.json                   # Cron configuration
โ”œโ”€โ”€ .env.local                    # Environment variables (not committed)
โ””โ”€โ”€ package.json

๐Ÿค Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ› Known Issues

  • Weather timing precision limited on Vercel Hobby plan (ยฑ59 minutes)
  • News API free tier limited to 100 requests/day
  • Stock data may have slight delays (free tier limitation)

See open issues for a full list of known issues.


๐Ÿ”ฎ Roadmap

  • User authentication and personalization
  • Bookmarking and reading lists
  • Email notifications for breaking news
  • Mobile app (React Native)
  • Dark/light theme toggle
  • Advanced search filters
  • Social sharing features
  • RSS feed generation
  • Multi-language support

๐Ÿ“ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ‘ค Author

Star Olaojo


๐Ÿ™ Acknowledgments


โญ Show your support

Give a โญ๏ธ if this project helped you!


๐Ÿ“ง Contact

Project Link: https://github.com/Esstar612/newspaper

Live Demo: https://newspaper-kohl.vercel.app


Made with โค๏ธ by Star Olaojo

About

A full-stack newspaper-style web app aggregating live news, stock market data, and weather using Next.js, TypeScript, and MongoDB.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors