A powerful tool for automatically scraping websites, processing PDFs, and generating FAQs using AI.
- Overview
- Features
- Prerequisites
- Configuration
- System Requirements
- Usage
- Technical Details
- Development
- Best Practices
- Troubleshooting
- Maintenance
- Security Considerations
- Tech Stack and Dependencies
Insight Forge is a Rust-based application that automates the process of scraping web content, processing PDFs, and generating FAQs. It uses headless Chrome for reliable web scraping, OCR capabilities for PDF text extraction, and AI APIs for intelligent FAQ generation.
- π Automated website scraping with JavaScript rendering support
- π PDF processing with OCR capabilities
- π Conversion of HTML content to Markdown
- β AI-powered FAQ generation using GROQ
- π Intelligent content processing and cleaning
- π Organized content storage structure
- π³ Containerized deployment with Docker
- Docker and Docker Compose
- Chrome WebDriver (running on port 9515)
- GROQ API key
- Tesseract OCR (for PDF processing)
- poppler-utils (for PDF to image conversion)
Copy .env.example to .env and fill in your values:
cp .env.example .env| Variable | Description |
|---|---|
API_KEY |
Secret key for authenticating API requests to Insight Forge |
OPENAI_COMPATIBLE_API_URL |
Base URL for your OpenAI-compatible API endpoint (e.g. https://api.openai.com/v1/chat/completions) |
OPENAI_COMPATIBLE_API_URL |
Router endpoint for parallel/batched LLM requests |
GROQ_API_KEY |
Groq API key for FAQ generation |
DATABASE_URL |
PostgreSQL connection string |
LANGFUSE_PUBLIC_KEY |
Langfuse public key for observability |
LANGFUSE_SECRET_KEY |
Langfuse secret key for observability |
LANGFUSE_BASE_URL |
Langfuse instance URL (default: https://cloud.langfuse.com) |
| Variable | Default | Description |
|---|---|---|
MODE |
cli |
Run mode: cli or api |
APP_PORT |
11111 |
Server port |
IF_UI_BASE_URL |
http://localhost:3000 |
UI base URL for CORS |
OPENAI_COMPATIBLE_MODEL |
openrouter/qwen/qwen3.6-plus |
Primary model for AI tasks |
OPENAI_COMPATIBLE_MODEL_FALLBACK |
openrouter/qwen/qwen3.5-plus-02-15 |
Fallback model |
OPENAI_COMPATIBLE_STREAM_ENABLED |
true |
Enable streaming responses |
VISION_EXTRACTION_ENABLED |
false |
Enable vision-based PDF extraction |
VISION_PDF_TO_IMG_TTL |
1440000 |
Cache TTL for PDF-to-image conversion (ms) |
FAQ_ENABLED |
true |
Enable FAQ generation |
CONTAINER_NAME |
insight-forge-server:v0.3.4 |
Docker container image name |
The Docker container is configured with the following resource limits:
- CPU: 0.8 cores
- Memory: 2GB
- Build and start the container:
docker-compose up -dWhen running the application, you'll be prompted to:
- Specify the number of FAQs you want per page
- Enter URLs to scrape or paths to PDF files (one per line)
- Press Enter twice when done entering URLs/paths
For each scraped URL or processed PDF, the system generates files with sanitized filenames (spaces replaced with underscores, punctuation removed) in separate directories:
raw_html/{sanitized_filename}.md: Complete raw HTML content or PDF textraw_text_cleaned/{sanitized_filename}.md: Cleaned HTML content or processed PDF textstructured_markdown/{sanitized_filename}.md: Converted Markdown contentfaq/faq_{sanitized_filename}.md: Generated FAQs
Note: Filenames are automatically sanitized to remove special characters and replace spaces with underscores for cross-platform compatibility.
- Uses Chrome WebDriver with custom user agent
- Implements scroll-to-bottom functionality
- Waits for content loading (1.5s delay)
- Processes and cleans HTML content
- Extracts embedded text from PDF using lopdf
- Performs OCR on PDF content using Tesseract
- Combines extracted text and OCR results
- Utilizes GROQ API for intelligent FAQ generation
- Customizable number of FAQs per page
- Markdown format output
- Docker volumes for persistent storage:
./server/data/scraped_content:/usr/server/app/server/data/scraped_content./server/data/faq:/usr/server/app/server/data/faq
- Comprehensive error handling with detailed messages
- Automatic retry mechanism for failed requests
- Graceful handling of existing files
main.rs: Application entry point and orchestrationscraper.rs: Web scraping functionalitypdf_handler.rs: PDF processing and OCRfaq_writer.rs: FAQ file managementcompose.yml: Docker configuration
- Clone the repository
- Install Rust and required dependencies
- Run with cargo:
cargo rundocker build -t insight-forge .- Monitor resource usage, especially for large-scale scraping and PDF processing
- Respect websites' robots.txt and rate limiting
- Regular backup of the data directories
- Monitor GROQ API usage and costs
-
WebDriver Connection Issues
- Ensure Chrome WebDriver is running on port 9515
- Check network connectivity
-
Memory Issues
- Monitor Docker memory usage
- Adjust memory limits in compose.yml if needed
-
FAQ Generation Failures
- Verify GROQ API key validity
- Check API rate limits
- Review input content size
-
PDF Processing Issues
- Ensure Tesseract OCR is properly installed
- Check PDF file integrity
- Install required dependencies:
sudo apt-get update sudo apt-get install tesseract-ocr libtesseract-dev libleptonica-dev poppler-utils
-
Dependency Installation
- If building outside of Docker, ensure all required dependencies are installed:
sudo apt-get update sudo apt-get install tesseract-ocr libtesseract-dev libleptonica-dev poppler-utils
- If building outside of Docker, ensure all required dependencies are installed:
The application is configured to restart automatically (restart: always) and includes resource limits to prevent system overload.
- Store API keys securely using environment variables
- Regular security updates for dependencies
- Monitor and log access patterns
- Implement rate limiting for production deployments
-
Rust: The core programming language used for building the application.
- Provides high performance and memory safety.
-
Selenium WebDriver: Used for web scraping with JavaScript support.
- Allows interaction with web browsers for dynamic content scraping.
-
lopdf: A Rust library for parsing and manipulating PDF files.
- Used for extracting embedded text from PDFs.
-
Tesseract: An OCR engine used for extracting text from images in PDFs.
- Enables text extraction from scanned documents or image-based PDFs.
-
GROQ API: Used for generating FAQs from the extracted content.
- Provides AI-powered question generation and answering capabilities.
-
anyhow: A Rust library for flexible error handling.
- Simplifies error management across the application.
-
tokio: An asynchronous runtime for Rust.
- Enables efficient handling of concurrent operations.
-
reqwest: An HTTP client for Rust.
- Used for making API requests to GROQ.
-
serde: A framework for serializing and deserializing Rust data structures.
- Facilitates working with JSON data from APIs.
-
log: A logging facade for Rust.
- Provides a flexible logging system for the application.
-
dotenvy: A Rust library for loading environment variables from a file with multiline support.
- Manages configuration and sensitive data.
-
Docker: Used for containerization and deployment.
- Ensures consistent runtime environment across different systems.
This tech stack combines powerful libraries and tools to create a robust, efficient, and versatile web scraping and FAQ generation system, now with added support for PDF processing and OCR capabilities.