Spaces:
Sleeping
title: Web3 Research Co-Pilot
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: latest
app_file: app.py
pinned: false
Web3 Research Co-Pilot
A professional AI-powered cryptocurrency research assistant that provides real-time market analysis, DeFi intelligence, and blockchain insights through an elegant web interface.
π Live Demo: https://archcoder-web3-copilot.hf.space
β¨ Features
- AI-Powered Research: Advanced LLM analysis using Google Gemini
- Real-Time Data: Live market data from CoinGecko, DeFiLlama, and Etherscan
- Interactive Visualizations: Dynamic charts and graphs powered by Plotly
- Professional UI: Minimalist, responsive web interface
- Multi-Chain Support: Ethereum, DeFi protocols, and Layer 2 solutions
- Comprehensive Analytics: Market trends, yield optimization, and risk assessment
π Quick Start
Prerequisites
- Python 3.11+
- Google Gemini API Key (required)
- Optional: CoinGecko API Key (for higher rate limits)
- Optional: Etherscan API Key (for blockchain data)
Installation
Clone the repository
git clone https://github.com/Transcendental-Programmer/web3-research-agent.git cd web3-research-agent
Install dependencies
pip install -r requirements.txt
Set up environment variables
Create a
.env
file in the project root:cp .env.example .env
Edit
.env
with your API keys:# Required GEMINI_API_KEY=your_gemini_api_key_here # Optional (for enhanced functionality) COINGECKO_API_KEY=your_coingecko_api_key_here ETHERSCAN_API_KEY=your_etherscan_api_key_here
Run the application
python app.py
Access the interface
- Local Development: http://localhost:7860
- Production/Cloud: Check your hosting platform's port forwarding
- Docker: http://localhost:7860
π HuggingFace Spaces Deployment
This project is configured for HuggingFace Spaces deployment with Docker SDK.
Quick Deploy to HF Spaces
Fork/Clone this repository
Create a new HuggingFace Space:
- Go to HuggingFace Spaces
- Click "Create new Space"
- Choose "Docker" as the SDK
- Upload your repository files
Configure Environment Variables: In your Space settings, add:
GEMINI_API_KEY=your_gemini_api_key COINGECKO_API_KEY=your_coingecko_api_key ETHERSCAN_API_KEY=your_etherscan_api_key
Deploy via Git:
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME git push hf main
HF Spaces Configuration
The project includes a proper README.md
header for HF Spaces:
title: Web3 Research Co-Pilot
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
app_file: app.py
π³ Docker Deployment
Local Docker
# Build the image
docker build -t web3-research-copilot .
# Run the container
docker run -p 7860:7860 \
-e GEMINI_API_KEY=your_key_here \
-e COINGECKO_API_KEY=your_key_here \
-e ETHERSCAN_API_KEY=your_key_here \
web3-research-copilot
HuggingFace Spaces
This project is optimized for HuggingFace Spaces deployment:
Create a new Space:
- Go to HuggingFace Spaces
- Click "Create new Space"
- Choose "Docker" as the SDK
- Set visibility to "Public" or "Private"
Configure Environment Variables: In your Space settings, add:
GEMINI_API_KEY=your_gemini_api_key COINGECKO_API_KEY=your_coingecko_api_key ETHERSCAN_API_KEY=your_etherscan_api_key
Deploy:
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME git push hf main
Live Example: https://archcoder-web3-copilot.hf.space
π Development Setup
Adding HuggingFace Remote
To deploy to your HuggingFace Space:
# Add HuggingFace remote
git remote add hf https://huggingface.co/spaces/ArchCoder/web3-copilot
# Or for your own space
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
# Deploy to HF Spaces
git push hf main
π Testing
Run the comprehensive test suite:
python test_suite.py
Expected output: ``` π Web3 Research Co-Pilot - Test Suite
β All imports successful β Configuration validated β Visualizations working β Tools initialized β Service functional β API endpoints healthy β Performance acceptable
Tests passed: 7/7 Success rate: 100.0% π All tests passed!
## ποΈ Project Structure
web3-research-agent/ βββ app.py # Main FastAPI application βββ requirements.txt # Python dependencies βββ pyproject.toml # Project configuration βββ uv.lock # Dependency lock file βββ test_suite.py # Comprehensive test suite βββ .env.example # Environment template βββ src/ # Source code β βββ init.py β βββ research_agent.py # Main agent logic β βββ enhanced_agent.py # Enhanced agent features β βββ config.py # Configuration management β βββ cache_manager.py # Response caching β βββ api_clients.py # External API clients β βββ defillama_client.py # DeFiLlama integration β βββ news_aggregator.py # News and social data β βββ portfolio_analyzer.py # Portfolio analysis β βββ visualizations.py # Chart generation βββ README.md # This file
## π§ Configuration
### Required Environment Variables
| Variable | Description | Required |
|----------|-------------|----------|
| `GEMINI_API_KEY` | Google Gemini API key for AI analysis | β
|
### Optional Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `COINGECKO_API_KEY` | CoinGecko API key for enhanced rate limits | None |
| `ETHERSCAN_API_KEY` | Etherscan API key for blockchain data | None |
| `AIRAA_WEBHOOK_URL` | AIRAA integration webhook URL | None |
| `AIRAA_API_KEY` | AIRAA API authentication key | None |
### Getting API Keys
1. **Google Gemini API**:
- Go to [Google AI Studio](https://aistudio.google.com/)
- Create a new API key
- Copy the key to your `.env` file
2. **CoinGecko API** (optional):
- Sign up at [CoinGecko](https://www.coingecko.com/api)
- Get your free API key
- Provides higher rate limits
3. **Etherscan API** (optional):
- Register at [Etherscan](https://etherscan.io/apis)
- Create a free API key
- Enables blockchain data queries
## π― Usage Examples
### Market Analysis
"Analyze Bitcoin price trends and institutional adoption patterns"
### DeFi Research
"Compare top DeFi protocols by TVL, yield, and risk metrics"
### Layer 2 Analysis
"Evaluate Ethereum Layer 2 scaling solutions and adoption metrics"
### Yield Optimization
"Identify optimal yield farming strategies across multiple chains"
## π API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Web interface |
| `/status` | GET | System status and configuration |
| `/query` | POST | Process research queries |
| `/health` | GET | Health check |
### Query API Example
```bash
curl -X POST "http://localhost:7860/query" \
-H "Content-Type: application/json" \
-d '{"query": "What is the current Bitcoin price?"}'
π Troubleshooting
Port Access Issues
Problem: Can't access the app on http://localhost:7860 or http://0.0.0.0:7860
Solutions:
Check if the app is running:
ps aux | grep "python app.py"
Verify port binding:
netstat -tlnp | grep :7860
For Development Environments (VS Code, etc.):
- Look for port forwarding notifications
- Check your IDE's "Ports" or "Forwarded Ports" tab
- Use the forwarded URL provided by your development environment
For Cloud/Remote Environments:
- The app binds to
0.0.0.0:7860
for external access - Use your platform's provided URL (not localhost)
- Check firewall rules if on a VPS/server
- The app binds to
Local Network Access:
# Find your local IP hostname -I # Access via: http://YOUR_IP:7860
Common Issues
"GEMINI_API_KEY not configured"
- Ensure you've set the API key in your
.env
file - Verify the key is valid and has proper permissions
- Ensure you've set the API key in your
"Connection refused" on port 7860
- Check if another process is using port 7860:
lsof -i :7860
- Ensure the app started successfully:
python app.py
- Check if another process is using port 7860:
Import errors
- Ensure all dependencies are installed:
pip install -r requirements.txt
- Check Python version compatibility (3.11+)
- Ensure all dependencies are installed:
Slow visualization loading
- Check your internet connection
- API rate limits may be affecting data retrieval
Getting Help
- Check the test suite:
python test_suite.py
- Review logs in the terminal output
- Verify API keys are configured correctly
- Open an issue on GitHub with error details
π€ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Google Gemini for AI capabilities
- CoinGecko for comprehensive market data
- DeFiLlama for DeFi protocol analytics
- Etherscan for blockchain data
- FastAPI for the web framework
- Plotly for interactive visualizations
Built with β€οΈ for the Web3 community