A modern full-stack news application built with Go backend and React frontend, featuring infinite scroll pagination and real-time news fetching from NewsData.io API.
This is a monorepo containing:
news-app/- Go backend service with Gin frameworknews-frontend/- React TypeScript frontend with Tailwind CSSweb-service-gin/- Additional Go web service
- π RESTful API with NewsData.io integration
- π Paginated news fetching (10 articles per request)
- π CORS enabled for frontend integration
- π Advanced filtering (language, country, category)
- π Structured logging with Logrus
- β‘ High-performance HTTP server
- π¨ Modern, responsive UI with Tailwind CSS
- βΎοΈ Infinite scroll pagination - seamlessly load more articles
- π Advanced search with multiple filters
- π± Mobile-first responsive design
- π Offline detection and handling
- β‘ Optimized performance with React hooks
- π― TypeScript for type safety
- Go 1.24+
- Node.js 16+
- NewsData.io API key
-
Get NewsData.io API Key
- Sign up at NewsData.io
- Get your free API key
-
Set Environment Variables
export NEWS_API_KEY=your_newsdata_io_api_key -
Start Development Servers
# Option 1: Use the convenient startup script ./start-dev.sh # Option 2: Start manually # Terminal 1 - Backend cd news-app && go run main.go # Terminal 2 - Frontend cd news-frontend && npm install && npm start
-
Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080 (local) or https://news-monk-p2dt.onrender.com (hosted)
Health check endpoint
{
"status": "ok"
}Fetch news articles with pagination and filtering
Query Parameters:
query(required) - Search termlanguage(optional) - Language code (default: "en")country(optional) - Country code (e.g., "us", "gb")category(optional) - Category (e.g., "technology", "sports")page(optional) - Pagination token for next page
Example:
# Local development
curl "http://localhost:8080/news?query=technology&language=en&country=us"
# Hosted on Render
curl "https://news-monk-p2dt.onrender.com/news?query=technology&language=en&country=us"Response:
{
"status": "success",
"totalResults": 1000,
"nextPage": "next_page_token",
"results": [
{
"article_id": "unique_id",
"title": "Article Title",
"description": "Article description...",
"link": "https://example.com/article",
"image_url": "https://example.com/image.jpg",
"source_name": "Source Name",
"pubDate": "2024-01-01T12:00:00Z",
"category": ["technology"],
"country": ["us"],
"creator": ["Author Name"]
}
]
}- Enter a search term (e.g., "artificial intelligence", "climate change")
- Optionally apply filters:
- Language: Choose from 10+ languages
- Country: Filter by specific countries
- Category: Select from business, tech, sports, etc.
- Click "Search" to fetch articles
- Scroll down to automatically load more articles (infinite scroll)
- Articles load automatically as you scroll near the bottom
- Loading indicator shows when fetching more content
- Seamlessly appends new articles to the existing list
- Handles end-of-results gracefully
cd news-app
go mod tidy
go run main.gocd news-frontend
npm install
npm start # Development server
npm run build # Production build
npm test # Run testsGoLang/
βββ news-app/ # Go backend
β βββ main.go # Main server file
β βββ go.mod # Go dependencies
β βββ go.sum # Go checksums
βββ news-frontend/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom hooks (including infinite scroll)
β β βββ services/ # API services
β β βββ types/ # TypeScript types
β βββ package.json # Node dependencies
β βββ tailwind.config.js # Tailwind configuration
βββ start-dev.sh # Development startup script
βββ README.md # This file
- Port: Set
PORTenvironment variable (default: 8080) - API Key: Set
NEWS_API_KEYenvironment variable - CORS: Configured to allow all origins for development
- API URL: Set
REACT_APP_API_URL(default: http://localhost:8080) - Build: Optimized production builds with code splitting
The backend is already deployed on Render at: https://news-monk-p2dt.onrender.com
For your own deployment:
cd news-app
go build -o news-server main.go
./news-server-
Build the application:
cd news-frontend npm run build -
Deploy to Render:
- Connect your GitHub repository to Render
- Set build command:
cd news-frontend && npm install && npm run build - Set publish directory:
news-frontend/build - Add environment variable:
REACT_APP_API_URL=https://news-monk-p2dt.onrender.com
-
Alternative static hosting:
# Serve the build/ directory with any static server npm install -g serve serve -s news-frontend/build
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
- NewsData.io for providing the news API
- Gin for the Go web framework
- React for the frontend framework
- Tailwind CSS for styling