An intelligent lead enrichment system that combines web scraping, AI-powered data extraction, and microservices architecture to automatically gather and process business information.
- Automated Lead Enrichment: Searches and enriches business leads with data from multiple sources
- AI-Powered Extraction: Uses Ollama LLM to intelligently extract structured data (CNPJ, company names, contacts) from unstructured web content
- Microservices Architecture: Distributed system with specialized services for different tasks
- Real-time Processing: RabbitMQ-based message queue for asynchronous processing
- Multiple Data Sources: Integrates with Tavily, Serper, and CNPJ.BIZ APIs
- Data Lake Storage: Elasticsearch for storing and querying enriched lead data
- Web Interface: React-based frontend for searching and viewing leads
┌─────────────┐ ┌─────────────┐ ┌──────────────┐
│ Front-Web │────▶│ API │────▶│ PostgreSQL │
└─────────────┘ └──────┬──────┘ └──────────────┘
│
┌──────▼──────┐
│ RabbitMQ │
│ (Fanout) │
└──────┬──────┘
│
┌──────────────────┼──────────────────┐
│ │ │
┌───────▼──────┐ ┌────────▼────────┐ ┌─────▼──────┐
│Data Collector│ │ Forwarder │ │ DataLake │
│ │ │ (Ollama AI) │ │ │
└───────┬──────┘ └────────┬────────┘ └─────┬──────┘
│ │ │
┌───────▼──────┐ ┌────────▼────────┐ ┌─────▼──────┐
│ Tavily/Serper│ │ Ollama │ │Elasticsearch│
└──────────────┘ └─────────────────┘ └────────────┘
- REST API for lead management
- PostgreSQL integration
- RabbitMQ producer for lead processing
- Enriches leads with external data sources
- Integrates with Tavily, Serper, and CNPJ.BIZ APIs
- Publishes enriched data to RabbitMQ fanout exchange
- Consumes enriched lead data
- Uses Ollama AI (qwen2.5:14b model) to extract structured information
- Updates lead records with extracted CNPJ, company names, and other details
- Stores enriched lead data in Elasticsearch
- Provides searchable archive of all processed leads
- User interface for searching and viewing leads
- Real-time updates of lead processing status
- Google Places integration for initial lead discovery
- Google Places API integration
- Initial lead discovery service
- Docker and Docker Compose
- Ollama installed locally with qwen2.5:14b model
- API Keys for:
- Google Places API
- Tavily API
- Serper API
- CNPJ.BIZ API (optional)
- Clone the repository
git clone https://github.com/yourusername/lead-search-super.git
cd lead-search-super- Set up environment variables
# Create .env files in each service directory with required API keys
cp .env.example .env- Install Ollama and pull the model
ollama pull qwen2.5:14b- Start the services
docker-compose up -d- Access the application
- Frontend: http://localhost:5173
- API: http://localhost:8085
- RabbitMQ Management: http://localhost:15672 (guest/guest)
- Elasticsearch: http://localhost:9200
RABBITMQ_URL: RabbitMQ connection stringOLHAMA_URL: Ollama API endpoint (usehttp://host.docker.internal:11434/api/chatfor local Ollama)ELASTICSEARCH_URL: Elasticsearch connection URLDB_HOST,DB_USER,DB_PASSWORD: PostgreSQL credentials
Each service requires specific API keys in their .env files:
- search-google:
GOOGLE_PLACES_API_KEY - data-collector:
TAVILY_API_KEY,SERPER_API_KEY - forwarder:
INVERTEXTO_API_TOKEN(optional)
- User searches for a business in the frontend
- Search-Google service queries Google Places API
- API service saves the lead and publishes to RabbitMQ
- Data Collector enriches the lead with Tavily and Serper data
- Enriched data is published to fanout exchange
- Forwarder uses Ollama AI to extract structured data (CNPJ, company details)
- DataLake stores the complete enriched data in Elasticsearch
- Frontend displays updated lead information
# Use the provided script to manually publish a lead
./publish_lead.sh# View RabbitMQ queue status
docker exec rabbitmq rabbitmqctl list_queues
# Check forwarder logs
docker logs forwarder --tail 100
# Query processed leads
docker exec db-leads psql -U leads_user -d leads_db -c "SELECT * FROM leads;"- Ensure Ollama is running locally:
ollama serve - Verify the model is installed:
ollama list - Check Docker can reach host:
http://host.docker.internal:11434
- Check RabbitMQ for unacknowledged messages
- Restart the forwarder service:
docker restart forwarder - Check logs for errors:
docker logs forwarder
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
- Bruno Vieira
- Ollama for providing local LLM capabilities
- Tavily and Serper for search APIs
- The Go and React communities for excellent tools and libraries