A personalized news application that uses AI-powered content recommendation and transparent user profiling to deliver relevant news articles tailored to individual preferences.
- Personalized News Feed: AI-driven article recommendations based on user behavior and preferences
- Multi-Category Support: Business, Entertainment, Health, Science, Sports, Technology, and General news
- Advanced Search: Keyword-based article filtering and discovery
- User Authentication: Secure registration and login system with JWT tokens
- Article Interaction: Save, like, and track reading activity
- Real-time Updates: Scheduled news fetching with background updates
- Transparent User Profiling: Clear visibility into how recommendations are generated
- Interest Profile Building: Dynamic learning from user interactions (reads, likes, saves)
- TF-IDF Content Analysis: Advanced text analysis for better content matching
- Activity-Based Recommendations: Personalization based on reading patterns
- Keyword Extraction: NLP-powered content understanding using NLTK
- Responsive Design: Mobile-friendly interface with modern UI components
- Preference Management: Granular control over content categories and keywords
- Data Transparency: Optional data sharing with clear consent mechanisms
- Saved Articles: Personal article library with easy management
- Location-Based Content: Geographic preference settings
- Framework: Dash (Python web framework)
- Styling: Bootstrap components with custom CSS
- Components: Modular UI components for reusability
- State Management: Session-based authentication storage
- API: FastAPI with automatic documentation
- Authentication: JWT-based secure authentication
- Database: MongoDB for user data and preferences
- Scheduling: APScheduler for automated news fetching
- AI Engine: Custom recommendation system with scikit-learn
- News API: Real-time news data from newsapi.org
- MongoDB: Document-based storage for flexibility
news-app/
βββ frontend/
β βββ app.py # Main Dash application
β βββ components.py # UI components (login, news cards, layouts)
β βββ callbacks.py # Interactive callbacks and event handlers
β βββ api_client.py # Frontend API communication layer
βββ backend/
β βββ main.py # FastAPI server with all endpoints
β βββ ai_model.py # ML recommendation engine
βββ database/
β βββ mongo_handler.py # Database utilities
βββ news/
β βββ news_fetcher.py # News API integration with caching
βββ assets/
β βββ custom.css # Custom styling
β βββ favicon.ico # Application icon
β βββ cache/ # News data caching
βββ requirements.txt # Python dependencies
- Python 3.8+
- MongoDB (local or cloud instance)
- News API key from newsapi.org
-
Clone the repository
git clone <repository-url> cd news-app
-
Install dependencies
pip install -r requirements.txt
-
Environment Setup Create a
.envfile in the root directory:NEWS_API_KEY=your_news_api_key_here MONGO_URI=mongodb://localhost:27017/ SECRET_KEY=your_secret_key_here API_BASE_URL=http://localhost:8000/api
-
Start MongoDB
# For local MongoDB mongod # Or use MongoDB Atlas (cloud) # Update MONGO_URI in .env with your connection string
-
Run the Backend
cd backend python main.py # Backend runs on http://localhost:8000
-
Run the Frontend
cd frontend python app.py # Frontend runs on http://localhost:8050
-
Access the Application Open your browser and navigate to:
http://localhost:8050
NEWS_API_KEY: Your News API key (required)MONGO_URI: MongoDB connection stringSECRET_KEY: JWT secret key for authenticationAPI_BASE_URL: Backend API base URL
- Visit newsapi.org
- Register for a free API key
- Add the key to your
.envfile
- Local: Install MongoDB and run
mongod - Cloud: Use MongoDB Atlas for cloud hosting
- Docker: Run MongoDB in a Docker container
- User Profiling: Tracks interests based on article interactions
- Content Analysis: Extracts keywords and analyzes article content
- Similarity Matching: Uses TF-IDF for content similarity
- Preference Learning: Adapts to user behavior over time
- Clear Explanations: Each recommendation shows why it was suggested
- Interest Visibility: Users can see their extracted interests
- Data Control: Granular privacy settings
- Opt-in Features: Experimental features require explicit consent
POST /api/auth/register- User registrationPOST /api/auth/login- User login
POST /api/news/fetch- Fetch filtered newsGET /api/news/personalized- Get personalized recommendationsGET /api/news/explore- Browse trending articlesGET /api/news/categories- Available news categories
GET /api/user/preferences- Get user preferencesPUT /api/user/preferences- Update preferencesPOST /api/user/save-article/{id}- Save articlePOST /api/user/like-article/{id}- Like articleGET /api/user/saved-articles- Get saved articles
- Modify
assets/custom.cssfor visual customization - Update
components.pyfor layout changes - Customize color schemes and responsive breakpoints
- Adjust recommendation weights in
ai_model.py - Modify keyword extraction parameters
- Fine-tune similarity algorithms
The application includes fallback sample data when the News API is unavailable:
- Automatically switches to cached content
- Provides sample articles for development
- Maintains functionality during API outages
- Enable debug mode for detailed error messages
- Use sample data by setting
ALWAYS_USE_SAMPLE = True - Monitor console logs for troubleshooting
- JWT Authentication: Secure token-based authentication
- Password Hashing: Werkzeug security for password protection
- CORS Protection: Configured for frontend-backend communication
- Input Validation: Pydantic models for API validation
- Privacy Controls: Transparent data usage with user consent
- News Caching: Reduces API calls with intelligent caching
- Session Storage: Efficient frontend state management
- Background Updates: Scheduled news fetching reduces load times
- Pagination: Efficient data loading
- Lazy Loading: Articles loaded as needed
- Database Indexing: Optimized MongoDB queries
- 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 licensed under the MIT License - see the LICENSE file for details.
- API Key Issues: Ensure your News API key is valid and not rate-limited
- MongoDB Connection: Verify MongoDB is running and connection string is correct
- Port Conflicts: Ensure ports 8000 and 8050 are available
- Check the console logs for detailed error messages
- Verify all environment variables are set correctly
- Ensure all dependencies are installed with correct versions
- Real-time Notifications: Push notifications for breaking news
- Social Features: Share articles and see what friends are reading
- Advanced Analytics: Detailed reading statistics and insights
- Mobile App: Native iOS and Android applications
- Multilingual Support: Content in multiple languages
- RSS Integration: Import from custom RSS feeds
Frontend: Dash, Bootstrap, JavaScript
Backend: FastAPI, Python
Database: MongoDB
AI/ML: scikit-learn, NLTK
Authentication: JWT
Deployment: Docker-ready
APIs: News API, RESTful architecture
Built with β€οΈ for transparent and intelligent news consumption