A modern React-based news aggregator application built with TypeScript, Redux, and SASS. Browse the latest news articles from around the world with support for multiple countries and themes.
- π° Real-time news feed from NewsAPI
- π Multi-country support (US, UK)
- π¨ Light/Dark theme support
- π Internationalization (i18next)
- π± Responsive design
- β‘ Built with TypeScript for type safety
- π§ͺ Component testing with Jest & React Testing Library
- π Component documentation with Storybook
- πΎ Redis caching for improved performance (30-minute TTL)
- Frontend: React 18, TypeScript
- State Management: Redux with Redux Thunk
- Routing: React Router v6
- Styling: SASS with theme system
- HTTP Client: Axios
- Testing: Jest, React Testing Library
- Build Tool: Create React App
- Documentation: Storybook
- Backend: Express.js proxy server
- Caching: Redis with 30-minute TTL
- Node.js 16+
- npm or yarn
- NewsAPI key from newsapi.org
-
Clone the repository
git clone <repository-url> cd news-feed
-
Install dependencies
npm install --legacy-peer-deps
Note: Use
--legacy-peer-depsto resolve TypeScript version conflicts -
Environment setup
Create a
.envfile in the project root:SASS_PATH=./node_modules;./src HTTPS=true PORT=8443 REACT_APP_API_KEY=your_newsapi_key_here
-
Start development server
npm start
Open https://localhost:8443 in your browser.
| Command | Description |
|---|---|
npm start |
Start development server on port 8443 with HTTPS |
npm run build |
Create production build |
npm test |
Run tests in watch mode |
npm run test:coverage |
Generate test coverage report |
npm run lint |
Run ESLint with caching |
npm run lint-fix |
Auto-fix linting issues |
npm run storybook |
Start Storybook on port 6006 |
npm run build-storybook |
Build Storybook for deployment |
The application supports both light and dark themes. Currently, theme switching is manual:
- Open
public/index.html - Change the body class:
- Light theme:
<body class="theme-light"> - Dark theme:
<body class="theme-dark">
- Light theme:
π§ TODO: Implement dynamic theme switching in the UI
The app fetches news from NewsAPI.org. Due to CORS restrictions in development:
- Development: Uses CORS proxy (
cors-anywhere.citadel.red) - Production: Direct API calls
- Authentication: API key automatically added to requests
- Country Support: Automatically filters news by selected country
- πΊπΈ United States (
US) - π¬π§ United Kingdom (
GB)
The application includes a Redis-based caching system to improve performance and reduce API calls:
- Cache Duration: 30 minutes TTL
- Cache Strategy: GET requests are cached based on endpoint and parameters
- Performance: Cache hits are 10-50x faster than API calls
- Fallback: Graceful degradation if Redis is unavailable
# View cache statistics
curl http://localhost:3001/cache/stats
# Clear cache
curl -X DELETE http://localhost:3001/cache/clear
# Test caching functionality
npm run proxy:test-cacheFor detailed caching documentation, see CACHING.md.
- Redux Store: Centralized state management
- Reducers:
newsPreviewReducer: Article data and loading statesnewsCountrySourceReducer: Country selection and localization
src/
βββ components/ # Reusable UI components
βββ pages/ # Route-level components
βββ services/ # API, actions, reducers
βββ style/ # SASS themes and variables
βββ i18n/ # Internationalization files
Run the full test suite:
npm testGenerate coverage report:
npm run test:coverageRun specific test:
npm test -- --testNamePattern="ComponentName"Start Storybook to view component documentation:
npm run storybookBuild Storybook for deployment:
npm run build-storybook-
Build the application
npm run build
-
Deploy the
buildfolder to your hosting service -
Environment variables: Ensure
REACT_APP_API_KEYis set in production
- Development server may fail due to ajv dependency conflicts
- Use
npm install --legacy-peer-depswhen installing packages - SASS deprecation warnings are expected (legacy API usage)
- Non-strict mode for easier migration
- Supports both
.tsand.tsxfiles - Type definitions included for all major dependencies
This project is licensed under the MIT License.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Built with β€οΈ using React and TypeScript