Skip to content

alokranjan609/NewsGram-Redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Newsgram

Newsgram is a web application that fetches news articles from an API and displays them on a webpage. It includes a server-side component that handles news fetching and integrates caching using Redis to enhance performance.

Features

  • Server-Side News Fetching: Handles fetching news from the API.
  • Redis Caching: Caches news articles in Redis to reduce redundant API calls.
  • Automatic Cache Expiration: Cached content is automatically expired after a set period (e.g., 60 minutes).
  • Efficient API Usage: Reduces load on the external news API by using cached results when available.

Tech Stack

  • Frontend: React
  • Backend: Node.js/Express
  • Caching: Redis

Installation

Clone the Repository

  git clone https://github.com/alokranjan609/NewsGram-Redis
  cd newsgram

Install Dependencies

  • Server
    cd server
    npm install
  • Client
  cd ../client
  npm install

Set Up Redis

docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest

Environment Variables

  • Create a .env file in the server directory with the following content:
GNEWS_API_KEY=your_news_api_key

Run the Application

  • Start the Backend Server
cd server
npm start
  • Start the Frontend Client
cd ../client
npm start

Access the Application

Open your browser and visit http://localhost:3000 to view the application.

How It Works

  • Query Handling: The server checks if the query result is cached in Redis.
  • Cache Hit: Returns cached data if available, improving response time.
  • Cache Miss: Fetches data from the API, stores it in Redis, and returns the result.
  • Cache Expiration: Cached data expires after a specified period to ensure fresh content.

Contributions

Contributions are welcome! Please open issues, submit pull requests, or provide suggestions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published