Skip to content

Varshithvhegde/newshub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NewsHub - AI-Powered News Aggregation Platform

NewsHub - AI-Powered News Aggregation Platform

A modern, full-stack news aggregation and summarization platform built with React, TypeScript, Node.js, and Redis. NewsHub provides users with AI-powered news summaries, personalized feeds, and advanced search capabilities using Google Gemini AI and Redis vector search.

๐Ÿš€ Features

Core Functionality

  • AI-Powered News Summarization: Uses Google Gemini AI for intelligent content analysis
  • Vector Search & Similarity: Redis-based semantic search with embeddings
  • Personalized News Feeds: User preference-based content recommendations
  • Real-time News Fetching: Automated news collection from multiple sources
  • Advanced Search: Filter articles by topic, sentiment, source, and keywords
  • Responsive Design: Optimized for desktop, tablet, and mobile devices

User Experience

  • Infinite Scroll: Seamless browsing with automatic content loading
  • Article Analytics: View engagement metrics and trending articles
  • Sentiment Analysis: Visual indicators for article sentiment (positive, negative, neutral)
  • Topic Filtering: Browse news by categories and interests
  • Real-time Updates: Stay informed with the latest news from multiple sources

Technical Features

  • TypeScript: Full type safety and better development experience
  • React Query: Efficient data fetching and caching
  • React Router: Client-side routing with smooth navigation
  • Tailwind CSS: Utility-first styling with custom components
  • Shadcn/ui: Beautiful, accessible UI components
  • Redis 8+: Advanced caching, vector search, and JSON storage
  • Express.js: High-performance REST API
  • Vite: Fast development and build tooling

๐Ÿ—๏ธ System Architecture

High-Level Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Frontend      โ”‚    โ”‚   Backend       โ”‚    โ”‚   External      โ”‚
โ”‚   (React/TS)    โ”‚โ—„โ”€โ”€โ–บโ”‚   (Node.js)     โ”‚โ—„โ”€โ”€โ–บโ”‚   Services      โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข React Router  โ”‚    โ”‚ โ€ข Express.js    โ”‚    โ”‚ โ€ข NewsAPI.org   โ”‚
โ”‚ โ€ข React Query   โ”‚    โ”‚ โ€ข Redis Client  โ”‚    โ”‚ โ€ข Google Gemini โ”‚
โ”‚ โ€ข Shadcn/ui     โ”‚    โ”‚ โ€ข AI Services   โ”‚    โ”‚ โ€ข Redis Cloud   โ”‚
โ”‚ โ€ข Tailwind CSS  โ”‚    โ”‚ โ€ข Cache Layer   โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   User Layer    โ”‚    โ”‚   Data Layer    โ”‚    โ”‚   AI Layer      โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข User Interfaceโ”‚    โ”‚ โ€ข Redis JSON    โ”‚    โ”‚ โ€ข Content       โ”‚
โ”‚ โ€ข Personalizationโ”‚   โ”‚ โ€ข Vector Search โ”‚    โ”‚   Analysis      โ”‚
โ”‚ โ€ข Search/Filter โ”‚    โ”‚ โ€ข Multi-layer   โ”‚    โ”‚ โ€ข Sentiment     โ”‚
โ”‚ โ€ข Responsive UI โ”‚    โ”‚   Caching       โ”‚    โ”‚   Analysis      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Data Flow Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ NewsAPI.org โ”‚โ”€โ”€โ”€โ–บโ”‚ News        โ”‚โ”€โ”€โ”€โ–บโ”‚ AI          โ”‚โ”€โ”€โ”€โ–บโ”‚ Redis       โ”‚
โ”‚             โ”‚    โ”‚ Processor   โ”‚    โ”‚ Processor   โ”‚    โ”‚ Storage     โ”‚
โ”‚ โ€ข Raw News  โ”‚    โ”‚ โ€ข Fetch     โ”‚    โ”‚ โ€ข Gemini    โ”‚    โ”‚ โ€ข JSON      โ”‚
โ”‚ โ€ข Metadata  โ”‚    โ”‚ โ€ข Parse     โ”‚    โ”‚ โ€ข Embeddingsโ”‚    โ”‚ โ€ข Vectors   โ”‚
โ”‚ โ€ข Sources   โ”‚    โ”‚ โ€ข Validate  โ”‚    โ”‚ โ€ข Sentiment โ”‚    โ”‚ โ€ข Indexes   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                              โ”‚
                                                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Frontend    โ”‚โ—„โ”€โ”€โ”€โ”‚ API Layer   โ”‚โ—„โ”€โ”€โ”€โ”‚ Cache Layer โ”‚โ—„โ”€โ”€โ”€โ”‚ Search      โ”‚
โ”‚             โ”‚    โ”‚             โ”‚    โ”‚             โ”‚    โ”‚ Engine      โ”‚
โ”‚ โ€ข React App โ”‚    โ”‚ โ€ข Express   โ”‚    โ”‚ โ€ข Multi-    โ”‚    โ”‚ โ€ข Vector    โ”‚
โ”‚ โ€ข Componentsโ”‚    โ”‚ โ€ข Routes    โ”‚    โ”‚   layer     โ”‚    โ”‚   Search    โ”‚
โ”‚ โ€ข State Mgmtโ”‚    โ”‚ โ€ข Controllersโ”‚   โ”‚ โ€ข LRU Cache โ”‚    โ”‚ โ€ข Full-text โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Component Architecture

Frontend Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Frontend Layer                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Pages Layer                                                   โ”‚
โ”‚  โ”œโ”€โ”€ Home.tsx (News Feed)                                     โ”‚
โ”‚  โ”œโ”€โ”€ Search.tsx (Advanced Search)                             โ”‚
โ”‚  โ”œโ”€โ”€ Trending.tsx (Trending Articles)                         โ”‚
โ”‚  โ”œโ”€โ”€ PersonalizedFeed.tsx (User Preferences)                  โ”‚
โ”‚  โ”œโ”€โ”€ Article.tsx (Article Details)                            โ”‚
โ”‚  โ””โ”€โ”€ NotFound.tsx (404 Page)                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Components Layer                                              โ”‚
โ”‚  โ”œโ”€โ”€ UI Components (Shadcn/ui)                                โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ Cards, Buttons, Forms                                โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ Navigation, Modals                                   โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ Charts, Notifications                                โ”‚
โ”‚  โ”œโ”€โ”€ Custom Components                                         โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ ArticleCard.tsx                                      โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ SearchFilters.tsx                                    โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ Header.tsx                                           โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ SentimentBadge.tsx                                   โ”‚
โ”‚  โ””โ”€โ”€ Layout Components                                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Hooks Layer                                                   โ”‚
โ”‚  โ”œโ”€โ”€ useDebounce.ts (Search Optimization)                     โ”‚
โ”‚  โ”œโ”€โ”€ use-mobile.tsx (Responsive Logic)                        โ”‚
โ”‚  โ””โ”€โ”€ use-toast.ts (Notifications)                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Services Layer                                                โ”‚
โ”‚  โ”œโ”€โ”€ api.ts (API Client)                                      โ”‚
โ”‚  โ”œโ”€โ”€ userManager.ts (User Management)                         โ”‚
โ”‚  โ”œโ”€โ”€ config.ts (Configuration)                                โ”‚
โ”‚  โ””โ”€โ”€ utils.ts (Utilities)                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Backend Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Backend Layer                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  API Layer (Express.js)                                        โ”‚
โ”‚  โ”œโ”€โ”€ Routes                                                    โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ /api/news (News Management)                          โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ /api/user (User Management)                          โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ /api/metadata (Metadata)                             โ”‚
โ”‚  โ”‚   โ”œโ”€โ”€ /api/admin (Admin Functions)                         โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ /api/health (Health Checks)                          โ”‚
โ”‚  โ”œโ”€โ”€ Controllers                                               โ”‚
โ”‚  โ”‚   โ””โ”€โ”€ newsController.js (Request Handlers)                 โ”‚
โ”‚  โ””โ”€โ”€ Middleware                                                โ”‚
โ”‚      โ”œโ”€โ”€ errorHandler.js (Error Handling)                     โ”‚
โ”‚      โ””โ”€โ”€ logger.js (Logging)                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Services Layer                                                โ”‚
โ”‚  โ”œโ”€โ”€ redisService.js (Database Operations)                    โ”‚
โ”‚  โ”œโ”€โ”€ geminiService.js (AI Integration)                        โ”‚
โ”‚  โ”œโ”€โ”€ newsProcessor.js (Content Processing)                    โ”‚
โ”‚  โ”œโ”€โ”€ newsFetcherService.js (External API)                     โ”‚
โ”‚  โ””โ”€โ”€ cacheClearService.js (Cache Management)                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Data Layer (Redis)                                            โ”‚
โ”‚  โ”œโ”€โ”€ JSON Storage (Article Data)                              โ”‚
โ”‚  โ”œโ”€โ”€ Vector Search (Semantic Similarity)                      โ”‚
โ”‚  โ”œโ”€โ”€ Hash Storage (User Preferences)                          โ”‚
โ”‚  โ”œโ”€โ”€ Sorted Sets (Trending Metrics)                           โ”‚
โ”‚  โ””โ”€โ”€ Multi-layer Caching                                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

AI Integration Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Content       โ”‚    โ”‚   AI Processing โ”‚    โ”‚   Vector        โ”‚
โ”‚   Input         โ”‚โ”€โ”€โ”€โ–บโ”‚   Pipeline      โ”‚โ”€โ”€โ”€โ–บโ”‚   Storage       โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข News Articles โ”‚    โ”‚ โ€ข Gemini 2.0    โ”‚    โ”‚ โ€ข Embeddings    โ”‚
โ”‚ โ€ข Raw Text      โ”‚    โ”‚ โ€ข Summarization โ”‚    โ”‚ โ€ข Similarity    โ”‚
โ”‚ โ€ข Metadata      โ”‚    โ”‚ โ€ข Sentiment     โ”‚    โ”‚ โ€ข Search Index  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Content       โ”‚    โ”‚   AI Services   โ”‚    โ”‚   Search        โ”‚
โ”‚   Analysis      โ”‚    โ”‚                 โ”‚    โ”‚   Results       โ”‚
โ”‚                 โ”‚    โ”‚ โ€ข Text Analysis โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข Keywords      โ”‚    โ”‚ โ€ข Entity        โ”‚    โ”‚ โ€ข Semantic      โ”‚
โ”‚ โ€ข Topics        โ”‚    โ”‚   Extraction    โ”‚    โ”‚   Search        โ”‚
โ”‚ โ€ข Categories    โ”‚    โ”‚ โ€ข Classificationโ”‚    โ”‚ โ€ข Recommendationsโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Caching Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Request       โ”‚    โ”‚   Cache Layer   โ”‚    โ”‚   Data Source   โ”‚
โ”‚   Layer         โ”‚โ”€โ”€โ”€โ–บโ”‚                 โ”‚โ”€โ”€โ”€โ–บโ”‚                 โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข API Requests  โ”‚    โ”‚ โ€ข Request Cache โ”‚    โ”‚ โ€ข Redis JSON    โ”‚
โ”‚ โ€ข User Queries  โ”‚    โ”‚ โ€ข Query Cache   โ”‚    โ”‚ โ€ข Vector DB     โ”‚
โ”‚ โ€ข Search Filtersโ”‚    โ”‚ โ€ข Result Cache  โ”‚    โ”‚ โ€ข External APIs โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ–ฒ                       โ”‚                       โ”‚
         โ”‚                       โ–ผ                       โ”‚
         โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚   Cache         โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚   Statistics    โ”‚
                        โ”‚                 โ”‚
                        โ”‚ โ€ข Hit/Miss      โ”‚
                        โ”‚ โ€ข Performance   โ”‚
                        โ”‚ โ€ข Eviction      โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Framework: React 18 with TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS + Shadcn/ui components
  • State Management: React Query (TanStack Query)
  • Routing: React Router DOM
  • UI Components: Radix UI primitives
  • Icons: Lucide React
  • Date Handling: date-fns
  • Form Handling: React Hook Form + Zod validation
  • Charts: Recharts
  • Notifications: Sonner toast

Backend

  • Runtime: Node.js with Express.js
  • Database: Redis 8+ (JSON, Vector Search, Caching)
  • AI Services: Google Gemini AI (Gemini 2.0 Flash, Embeddings)
  • News API: NewsAPI.org integration
  • Caching: Multi-layer Redis caching system
  • Search: Redis Search with vector similarity
  • Scheduling: Node-cron for automated tasks

๐Ÿ“ Project Structure

newshub/
โ”œโ”€โ”€ backend/                 # Node.js backend (NewsHub API)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/    # Request handlers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ newsController.js
โ”‚   โ”‚   โ”œโ”€โ”€ routes/         # API route definitions
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ adminRoutes.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ healthRoutes.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ metadataRoutes.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ newsRoutes.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ userRoutes.js
โ”‚   โ”‚   โ”œโ”€โ”€ services/       # Business logic
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cacheClearService.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ geminiService.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ newsFetcherService.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ newsProcessor.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ redisService.js
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/     # Express middleware
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ errorHandler.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ logger.js
โ”‚   โ”‚   โ”œโ”€โ”€ utils/          # Utility functions
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ pagination.js
โ”‚   โ”‚   โ”œโ”€โ”€ config/         # Configuration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ database.js
โ”‚   โ”‚   โ”œโ”€โ”€ scripts/        # Management scripts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ clearAllCache.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ clearCache.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ clearCacheExceptUser.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ clearNews.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ deleteSearchIndex.js
โ”‚   โ”‚   โ””โ”€โ”€ app.js          # Express application
โ”‚   โ”œโ”€โ”€ scripts/            # Root-level scripts
โ”‚   โ”‚   โ””โ”€โ”€ run-news-processor.js
โ”‚   โ”œโ”€โ”€ docs/               # Documentation
โ”‚   โ”‚   โ”œโ”€โ”€ CACHE_CLEARING.md
โ”‚   โ”‚   โ”œโ”€โ”€ CACHE_MANAGEMENT.md
โ”‚   โ”‚   โ””โ”€โ”€ README.md
โ”‚   โ”œโ”€โ”€ logs/               # Application logs
โ”‚   โ”œโ”€โ”€ index.js            # Entry point
โ”‚   โ”œโ”€โ”€ addNews.js          # News addition utility
โ”‚   โ”œโ”€โ”€ test-cors.js        # CORS testing utility
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ package-lock.json
โ”‚   โ”œโ”€โ”€ vercel.json         # Vercel deployment config
โ”‚   โ”œโ”€โ”€ cache_clear_metrics_1754132194592.json
โ”‚   โ””โ”€โ”€ README.md
โ”œโ”€โ”€ frontend/               # React frontend (NewsHub Web App)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/         # Shadcn/ui components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ArticleCard.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Header.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LoadingSpinner.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PersonalizedSearchFilters.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PreferenceSetup.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SearchFilters.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ SentimentBadge.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # Page components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Article.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Home.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Index.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ NotFound.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PersonalizedFeed.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Search.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Trending.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/          # Custom React hooks
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ useDebounce.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ use-mobile.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ use-toast.ts
โ”‚   โ”‚   โ”œโ”€โ”€ lib/            # Utility libraries
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ api.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ env.ts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ userManager.ts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils.ts
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx         # Main React component
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx        # Application entry point
โ”‚   โ”‚   โ”œโ”€โ”€ index.css       # Global styles
โ”‚   โ”‚   โ””โ”€โ”€ App.css         # App-specific styles
โ”‚   โ”œโ”€โ”€ public/             # Static assets
โ”‚   โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ”‚   โ”œโ”€โ”€ placeholder.svg
โ”‚   โ”‚   โ””โ”€โ”€ robots.txt
โ”‚   โ”œโ”€โ”€ .gitignore
โ”‚   โ”œโ”€โ”€ bun.lockb           # Bun lock file
โ”‚   โ”œโ”€โ”€ components.json     # Shadcn/ui configuration
โ”‚   โ”œโ”€โ”€ env.example         # Environment variables template
โ”‚   โ”œโ”€โ”€ eslint.config.js    # ESLint configuration
โ”‚   โ”œโ”€โ”€ index.html          # HTML template
โ”‚   โ”œโ”€โ”€ package.json        # Dependencies and scripts
โ”‚   โ”œโ”€โ”€ package-lock.json
โ”‚   โ”œโ”€โ”€ postcss.config.js   # PostCSS configuration
โ”‚   โ”œโ”€โ”€ tailwind.config.ts  # Tailwind configuration
โ”‚   โ”œโ”€โ”€ tsconfig.json       # TypeScript configuration
โ”‚   โ”œโ”€โ”€ tsconfig.app.json
โ”‚   โ”œโ”€โ”€ tsconfig.node.json
โ”‚   โ”œโ”€โ”€ vercel.json         # Vercel deployment config
โ”‚   โ”œโ”€โ”€ vite.config.ts      # Vite configuration
โ”‚   โ””โ”€โ”€ vite.config.ts.timestamp-1753710958480-1ca4a5f8d9d6c.mjs
โ””โ”€โ”€ README.md               # This file

Note: The frontend is now fully developed with a complete React TypeScript application including:

  • Comprehensive UI components with Shadcn/ui
  • Multiple pages for different features (Home, Search, Trending, Personalized Feed, etc.)
  • Custom hooks for functionality like debouncing and mobile detection
  • API integration and user management
  • Responsive design with Tailwind CSS

๐Ÿ“ฆ Installation

Prerequisites

  • Node.js 18+
  • Redis 8+ (with RedisJSON and RedisSearch modules)
  • Google Gemini API key
  • NewsAPI.org API key

Quick Start

  1. Clone the repository

    git clone <repository-url>
    cd newshub
  2. Backend Setup

    cd backend
    npm install
    
    # Create .env file
    echo "REDIS_URL=redis://localhost:6379
    GEMINI_API_KEY=your_gemini_api_key
    NEWSAPI_KEY=your_newsapi_key
    PORT=3001
    NODE_ENV=development" > .env
    
    # Start the server
    npm run dev
  3. Frontend Setup

    cd ../frontend
    npm install
    
    # Create environment file (optional - will use fallback if not created)
    cp env.example .env
    
    # Start development server
    npm run dev
  4. Access the Application

๐Ÿ”ง Configuration

Environment Variables

Backend (.env)

# Redis Configuration
REDIS_URL=redis://localhost:6379

# AI Services
GEMINI_API_KEY=your_gemini_api_key

# News API
NEWSAPI_KEY=your_newsapi_key

# Server Configuration
PORT=3001
NODE_ENV=development

Frontend Configuration

The frontend uses environment variables for configuration. Create a .env file in the frontend directory:

# API Configuration
VITE_API_BASE_URL=http://localhost:3001

# Feature Flags
VITE_ENABLE_ANALYTICS=false
VITE_DEBUG_MODE=false

The API base URL is automatically configured with fallback to http://localhost:3001 if not specified.

Redis Requirements

  • Redis 8+ with RedisJSON module
  • RedisSearch module for vector search
  • Minimum 1GB memory recommended

CORS Configuration

The backend is configured to accept requests from:

  • Local development: http://localhost:8080, http://localhost:3000, http://localhost:5173
  • Production: https://newshub-henna.vercel.app and other Vercel domains
  • Custom domains can be added to the CORS configuration in src/app.js

๐Ÿ”Œ API Endpoints

News Management

  • GET /api/news - Get all articles with pagination
  • GET /api/news/:id - Get specific article by ID
  • GET /api/news/:id/similar - Get similar articles
  • GET /api/news/:id/metrics - Get article engagement metrics
  • GET /api/news/search - Search articles with filters
  • GET /api/news/topic/:topic - Get articles by topic
  • GET /api/news/sentiment/:sentiment - Get articles by sentiment
  • GET /api/news/trending - Get trending articles

User Management

  • POST /api/user/generate-id - Generate unique user ID
  • POST /api/user/:userId/preferences - Store user preferences
  • GET /api/user/:userId/preferences - Get user preferences
  • PUT /api/user/:userId/preferences - Update user preferences
  • GET /api/user/:userId/personalized-news - Get personalized feed
  • GET /api/user/:userId/personalized-news/search - Search personalized content
  • GET /api/user/:userId/history - Get user reading history

Metadata & Analytics

  • GET /api/metadata/topics - Get available topics
  • GET /api/metadata/sentiments - Get sentiment options
  • GET /api/metadata/sources - Get news sources

Admin & Health

  • GET /api/admin/similar-stats/:id - Get similarity statistics
  • GET /api/admin/clear-similar-cache/:id - Clear similarity cache
  • GET /api/health - Health check endpoint

๐Ÿ—„๏ธ Redis Features

Data Storage

  • JSON Storage: Article data with full-text search
  • Vector Search: Semantic similarity with embeddings
  • Hash Storage: User preferences and metadata
  • Sorted Sets: Trending articles and metrics

Caching Strategy

  • Multi-layer Caching: Request, query, and result caching
  • LRU Eviction: Intelligent cache management
  • Bloom Filters: Efficient duplicate detection
  • Cache Statistics: Performance monitoring

Search Capabilities

  • Full-text Search: Article content and metadata
  • Vector Similarity: Semantic article matching
  • Faceted Search: Topic, sentiment, source filtering
  • Fuzzy Matching: Typo-tolerant search

๐Ÿ“Š AI Integration

Gemini AI Services

  • Content Summarization: Intelligent article summarization
  • Sentiment Analysis: Positive, negative, neutral classification
  • Keyword Extraction: Relevant topic and entity extraction
  • Vector Embeddings: Semantic similarity generation

News Processing Pipeline

  1. Fetch: Collect news from multiple sources
  2. Analyze: AI-powered content analysis
  3. Store: Redis storage with search indexing
  4. Cache: Multi-layer caching for performance
  5. Serve: RESTful API delivery

๐Ÿš€ Available Scripts

Backend

# Development
npm run dev              # Start development server
npm start                # Start production server

# Cache Management
npm run cache:stats      # Show cache statistics
npm run cache:clear      # Clear cache (with confirmation)
npm run cache:force      # Force clear cache
npm run cache:nuclear    # Clear all Redis data
npm run cache:complete-stats  # Detailed Redis statistics
npm run cache:help       # Show cache management help

Frontend

# Development
npm run dev              # Start development server
npm run build            # Build for production
npm run build:dev        # Build for development
npm run preview          # Preview production build
npm run lint             # Run ESLint

๐ŸŽจ UI Components

The application uses a comprehensive set of UI components built with Shadcn/ui and Radix UI:

  • Cards: Article display and information containers
  • Buttons: Various button styles and states
  • Badges: Topic and sentiment indicators
  • Forms: Search filters and user preferences
  • Navigation: Header and mobile menu
  • Loading States: Spinners and skeleton loaders
  • Toasts: Success and error notifications

๐Ÿ“ฑ Responsive Design

The application is fully responsive with:

  • Mobile-first design approach
  • Collapsible navigation menu
  • Touch-friendly interactions
  • Optimized layouts for different screen sizes
  • Progressive enhancement

๐Ÿ” Search & Filtering

Advanced search capabilities include:

  • Text Search: Search by article title and content
  • Topic Filtering: Filter by news categories
  • Sentiment Filtering: Filter by article sentiment
  • Source Filtering: Filter by news source
  • Date Range: Filter by publication date
  • Combined Filters: Use multiple filters simultaneously

๐Ÿ‘ค Personalization

User personalization features:

  • Topic Preferences: Set preferred news topics
  • Personalized Feed: AI-curated content based on preferences
  • Reading History: Track viewed articles
  • Engagement Metrics: View article popularity and trends

๐Ÿ“ˆ Monitoring & Analytics

Performance Metrics

  • Request/response logging
  • Cache hit/miss ratios
  • API response times
  • Memory usage monitoring
  • Error tracking and reporting

Health Checks

  • Redis connectivity
  • API endpoint availability
  • Service status monitoring
  • Performance benchmarks

๐Ÿš€ Deployment

Backend Deployment

# Local Development
npm run dev

# Production Deployment
npm start

# Vercel Deployment
vercel --prod

Frontend Deployment

# Build for Production
npm run build

# Deploy to Vercel
npm install -g vercel
vercel

# Deploy to Netlify
npm run build
# Upload the dist folder to Netlify

๐Ÿ“š Documentation

๐Ÿ‘จโ€๐Ÿ’ป Author

Varshith V Hegde (@Varshithvhegde)

๐Ÿค Contributing

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

๐Ÿ“„ License

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

๐Ÿ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Check the documentation in the /docs folder
  • Review the API documentation

๐Ÿ”ฎ Roadmap

  • Real-time breaking news notifications
  • Live analytics dashboard
  • AI-powered chatbot
  • Advanced content curation
  • Offline reading capabilities
  • Push notifications for breaking news
  • Social sharing features
  • Advanced analytics dashboard
  • Multi-language support
  • Podcast integration
  • Video news summaries

๐Ÿ† Redis AI Challenge

This project is designed for the Redis AI Challenge and demonstrates:

Real-Time AI Innovators Features

  • AI-Powered Content Analysis: Google Gemini AI integration
  • Vector Search: Redis-based semantic similarity
  • Real-Time Processing: Live news analysis and recommendations
  • Personalized AI: ML-based content curation

Beyond the Cache Features

  • Redis as Primary Database: JSON storage with full-text search
  • Advanced Redis Features: Vector search, streams, pub/sub
  • Performance Optimization: Multi-layer caching strategies
  • Scalable Architecture: Handle thousands of concurrent users

Built with โค๏ธ using React, TypeScript, Node.js, Express, Redis, and Google Gemini AI

About

NewsHub - AI-Powered News Aggregation Platform

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

โšก