A modern news aggregator built with React that pulls articles from multiple trusted sources and displays them in a clean, easy-to-read format. Features include article search, filtering, personalized feeds, and mobile responsiveness.
- Multi-source News Integration: Aggregates news from The Guardian, The New York Times, and NewsAPI
- Advanced Search & Filtering: Search articles by keyword and filter by date, category, and source
- Personalized Feed: Customize your news feed with preferred sources and categories
- Responsive Design: Optimized for all device sizes
- Dark/Light Theme: Support for both light and dark modes
- Performance Optimized: Includes caching and rate limiting mechanisms
Before you begin, ensure you have:
- Node.js (v16 or higher)
- Yarn package manager
- Docker and Docker Compose (for containerized deployment)
- API keys from:
- The Guardian API
- The New York Times API
- NewsAPI
You can run NewsHub either locally or using Docker. Choose the method that best suits your needs.
- Clone the repository:
git clone https://github.com/yourusername/newshub.git
cd newshub
- Install dependencies:
yarn install
- Create a
.env
file in the root directory:
VITE_GUARDIAN_API_KEY=your_guardian_api_key
VITE_NYTIMES_API_KEY=your_nytimes_api_key
VITE_NEWSAPI_API_KEY=your_newsapi_api_key
- Start the development server:
yarn dev
- Build and start the container:
docker compose up newshub-dev
The application will be available at http://localhost:5173
The project includes two services in docker-compose.yml:
-
Development Service (newshub-dev)
- Hot-reloading enabled
- Source code mounted as volume
- Port 5173 exposed
- Development environment variables
-
Test Service (newshub-test)
- Dedicated service for running tests
- Same source code mounting
- Test-specific environment variables
# Start development environment
docker compose up newshub-dev
# Start in detached mode
docker compose up -d newshub-dev
# Run tests
docker compose run --rm newshub-test
# Run tests in watch mode
docker compose run --rm newshub-test yarn test:watch
# Stop services
docker compose down
# Rebuild without cache
docker compose build --no-cache newshub-dev
- Port Conflict
# If port 5173 is already in use, modify in docker-compose.yml:
ports:
- "3000:5173" # Change left number to any available port
- Node Modules Issues
# Rebuild node_modules in container
docker compose run --rm newshub-dev yarn install
yarn dev
- Start development serveryarn build
- Build for productionyarn preview
- Preview production buildyarn test
- Run testsyarn test:watch
- Run tests in watch modeyarn test:coverage
- Generate test coverage reportyarn lint
- Run ESLint
newshub/
├── src/
│ ├── components/ # React components
│ ├── hooks/ # Custom React hooks
│ ├── services/ # API and service integrations
│ ├── store/ # Redux store configuration
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── __tests__/ # Test files
├── public/ # Static assets
└── docker/ # Docker configuration files
Variable | Description | Required |
---|---|---|
VITE_GUARDIAN_API_KEY | The Guardian API Key | Yes |
VITE_NYTIMES_API_KEY | NY Times API Key | Yes |
VITE_NEWSAPI_API_KEY | NewsAPI Key | Yes |
The project includes a comprehensive test suite:
- Unit tests for components
- Integration tests for API services
- State management tests
- Custom hooks tests
Run tests using:
# Local
yarn test
# Docker
docker compose run --rm newshub-test
- React + TypeScript
- Vite
- Redux Toolkit
- TailwindCSS
- Jest + Testing Library
- Docker
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details