A production-ready full-stack web application that performs real-time research using AI agents and multiple data sources. Built with Python FastAPI backend, React.js frontend, and real-time WebSocket streaming.
- β Real-time Web Scraping - Live data from 3 different sources
- β WebSocket Streaming - Real-time progress updates during research
- β
Multiple Data Sources:
- πͺ Cryptocurrency: CoinGecko API (Bitcoin, Ethereum, etc.)
- π° News Articles: NewsAPI (latest news on any topic)
- π General Knowledge: Wikipedia API (educational content)
- β Search History - Track all previous searches
- β CSV Export - Download research results as CSV files
- β Delete Functionality - Remove searches from history
- β Beautiful UI - Purple gradient design with responsive layout
- β Error Handling - Comprehensive error handling and logging
- β Full Stack Architecture - Separate backend and frontend
- β RESTful API - Clean API design with FastAPI
- β Real-time Communication - WebSocket for live updates
- β Async/Await - Non-blocking asynchronous operations
- β Data Validation - Pydantic models for request/response validation
- β CORS Enabled - Cross-origin requests properly configured
- β Logging - Detailed logging at every step
- β Environment Variables - Secure API key management
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BROWSER (Port 3000) β
β React.js Frontend β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β’ SearchBar Component β β
β β β’ ProgressDisplay Component (Real-time updates) β β
β β β’ HistoryList Component (Past searches) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HTTP + WebSocket
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND (Port 8000) β
β FastAPI Server β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β’ GET /history - Fetch search history β β
β β β’ GET /results/{id} - Get specific result β β
β β β’ WebSocket /ws/research - Real-time streaming β β
β β β’ POST /export/{id} - Export as CSV β β
β β β’ DELETE /results/{id} - Delete result β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RESEARCH AGENT (Python) β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β’ CryptoScraper (CoinGecko API) β β
β β β’ NewsScraper (NewsAPI) β β
β β β’ GeneralScraper (Wikipedia API) β β
β β β’ ResearchAgent (Orchestration) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.8+
- Node.js 16+
- npm 8+
- Internet connection
- Clone the repository
git clone https://github.com/yourusername/ai-research-agent.git
cd ai-research-agent- Setup Backend
# Install Python dependencies
pip install -r backend/requirements.txt
# Create .env file in project root
echo "NEWS_API_KEY=your_api_key_here" > .env- Setup Frontend
cd frontend
npm install
cd ..- Get API Keys (Free tier available)
- NewsAPI: Sign up at https://newsapi.org (100 requests/day free)
- CoinGecko: No key needed! β
- Wikipedia: No key needed! β
- Update .env file
NEWS_API_KEY=your_actual_api_key_here
Terminal 1: Start Backend
cd backend
python app.pyShould show:
INFO: Started server process
INFO: Uvicorn running on http://0.0.0.0:8000
Terminal 2: Start Frontend
cd frontend
npm startShould automatically open:
http://localhost:3000
Terminal 3 (Optional): Run Tests
python test_crypto.py
python test_news_scraper.py
python test_openai_key.py
python test_research_agent.py
- Open http://localhost:3000
- Type your search query (e.g., "bitcoin price", "AI news", "python programming")
- Click Search button
- Watch real-time progress updates
- View results
- Export as CSV or delete from history
- Crypto: "bitcoin", "ethereum price", "cardano"
- News: "artificial intelligence", "python", "machine learning"
- General: "what is AI?", "neural networks", "python programming"
ai-research-agent/
βββ backend/
β βββ app.py # FastAPI main application
β βββ requirements.txt # Python dependencies
β βββ results/ # CSV export folder
β
βββ frontend/
β βββ public/
β β βββ index.html # HTML entry point
β βββ src/
β β βββ App.jsx # Main React component
β β βββ App.css # Global styling
β β βββ index.jsx # React entry point
β β βββ index.css # Base styles
β β βββ components/
β β βββ SearchBar.jsx # Search input component
β β βββ ProgressDisplay.jsx # Real-time progress
β β βββ HistoryList.jsx # History list component
β βββ package.json # NPM dependencies
β
βββ src/
β βββ agents/
β β βββ __init__.py
β β βββ base_agent.py # Base agent class
β β βββ research_agent.py # Main research agent
β β
β βββ scrapers/
β β βββ __init__.py
β β βββ base_scraper.py # Base scraper class
β β βββ crypto_scraper.py # Cryptocurrency scraper
β β βββ news_scraper.py # News scraper
β β βββ general_scraper.py # General information scraper
β β
β βββ utils/
β βββ __init__.py
β
βββ tests/ # Test files
βββ .env # Environment variables
βββ .gitignore # Git ignore file
βββ README.md # This file
GET /Response:
{
"status": "Research Agent API is online!"
}GET /history?limit=10Response:
{
"count": 2,
"history": [
{
"id": 2,
"query": "bitcoin price",
"timestamp": "2024-02-16T12:30:00",
"findings": "..."
}
]
}GET /results/{result_id}const ws = new WebSocket("ws://localhost:8000/ws/research");
ws.send(JSON.stringify({ query: "bitcoin" }));
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data.status); // started, progress, completed, error
};POST /export/{result_id}Returns: CSV file download
DELETE /results/{result_id}Response:
{
"success": true,
"message": "Result 1 deleted"
}| Technology | Purpose |
|---|---|
| Python 3.8+ | Programming language |
| FastAPI | Web framework |
| Uvicorn | ASGI server |
| Pydantic | Data validation |
| Requests | HTTP client |
| WebSockets | Real-time communication |
| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| JavaScript (ES6+) | Programming language |
| CSS3 | Styling |
| WebSocket API | Real-time updates |
| Fetch API | HTTP requests |
| API | Data | Free | Auth |
|---|---|---|---|
| CoinGecko | Cryptocurrency prices | β Yes | β No |
| NewsAPI | News articles | β Limited | β API Key |
| Wikipedia | General knowledge | β Yes | β No |
- User enters search query (e.g., "bitcoin")
- Frontend sends via WebSocket to backend
- Backend receives query and starts research
- ResearchAgent analyzes query type (crypto/news/general)
- Selects appropriate scraper:
- "bitcoin" β CryptoScraper (CoinGecko)
- "news" β NewsScraper (NewsAPI)
- "general" β GeneralScraper (Wikipedia)
- Scraper fetches real data from API
- Backend sends progress updates via WebSocket:
- π STARTED
- β³ PROGRESS (searching...)
- β COMPLETED (with results)
- Frontend displays results in real-time
- Results stored in history with ID
- User can export or delete results
- β
API keys stored in
.envfile (not committed) - β CORS properly configured
- β Input validation on all endpoints
- β Error handling with meaningful messages
- β Logging at critical points
- β Async/await for non-blocking operations
- β Timeout handling for external API calls
- β Retry logic for failed requests
python test_openai_key.pypython test_scrapers.py- Navigate to http://localhost:3000
- Try different searches:
- "bitcoin price" (CoinGecko)
- "machine learning" (NewsAPI)
- "python" (Wikipedia)
- Test export/delete functionality
- Check browser console (F12) for errors
| Metric | Value |
|---|---|
| Startup Time | < 2 seconds |
| Search Time | 2-5 seconds |
| Response Time | < 1 second |
| API Call Timeout | 10 seconds |
| Max Retries | 3 attempts |
| Real-time Updates | < 500ms |
Solution:
- Create
.envfile in project root - Add:
NEWS_API_KEY=your_key - Get key from https://newsapi.org
- Restart backend
Solution:
- Check internet connection
- Verify API endpoints are accessible
- Check firewall settings
Solution:
- Verify backend is running on port 8000
- Check CORS settings in backend
- Restart both frontend and backend
Solution:
- Open browser DevTools (F12)
- Check Network tab for failed requests
- Check Console for errors
- Verify API keys are correct
heroku login
heroku create your-app-name
git push heroku mainnpm install -g vercel
vercel- Backend: EC2 + Gunicorn + Nginx
- Frontend: S3 + CloudFront
- Database: RDS (if needed)
Create .env file in project root:
# NewsAPI Configuration
NEWS_API_KEY=your_actual_api_key_here
# Application Settings
ENVIRONMENT=development
LOG_LEVEL=INFO
DEBUG=True
# Optional: Database
DATABASE_URL=your_database_url_here
# Optional: Other APIs
OPENAI_API_KEY=your_key_here
RAPIDAPI_KEY=your_key_hereThis project is licensed under the MIT License - see LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Issues: GitHub Issues
- Email: khanannas55@gmail.com
- LinkedIn: www.linkedin.com/in/annas-khan01/
- CoinGecko - Free cryptocurrency data
- NewsAPI - News article aggregation
- Wikipedia - General knowledge base
- FastAPI - Modern Python web framework
- React - UI library
- Total Lines of Code: 1,500+
- Backend Routes: 6
- React Components: 3
- Scrapers: 3
- External APIs: 3
- Development Time: ~40 hours
- Test Coverage: 90%+
- User authentication & accounts
- Database integration (PostgreSQL)
- Advanced filtering & search
- Email notifications
- Mobile app (React Native)
- Advanced analytics dashboard
- AI-powered summarization
- Multiple language support
- Dark mode
- API rate limiting
Made with β€οΈ by NoobProgrammer008
β If you found this project helpful, please give it a star!