A semantic search application that allows you to search through website content using vector embeddings. The application fetches HTML content from any URL, processes it into chunks, generates embeddings, and provides semantic search capabilities.
- Frontend: Next.js 15 with React 19, Tailwind CSS, and shadcn/ui components
- Backend: Django REST Framework with Python
- Vector Database: Weaviate for storing and querying embeddings
- Embeddings: OpenAI embeddings for semantic search
Before setting up the project, ensure you have the following installed:
- Node.js (v18 or higher)
- npm or yarn
- Python (v3.8 or higher)
- pip (Python package manager)
- Docker and Docker Compose
- Git
git clone https://github.com/sandeshapparala/site-search.git
cd site-searchStart the Weaviate vector database using Docker:
cd vector-db
docker-compose up -dThis will start Weaviate on http://localhost:8080. You can verify it's running by visiting the URL in your browser.
cd s_s_backendpython -m venv venvWindows:
venv\Scripts\activatemacOS/Linux:
source venv/bin/activatepip install django djangorestframework requests weaviate-client openai python-dotenv beautifulsoup4 nltk# Create .env file with the following content:
OPENAI_API_KEY=your_openai_api_key_here
WEAVIATE_URL=http://localhost:8080
CHUNK_SIZE=500
CHUNK_OVERLAP=50
RESULTS_TOPK=10Note: You'll need to obtain an OpenAI API key from OpenAI's platform.
python manage.py migratepython manage.py runserverThe backend API will be available at http://localhost:8000.
cd s_s_frontendnpm installnpm run devThe frontend will be available at http://localhost:3000.
OPENAI_API_KEY: Your OpenAI API key for generating embeddingsWEAVIATE_URL: URL of your Weaviate instance (default:http://localhost:8080)CHUNK_SIZE: Size of text chunks for processing (default:500)CHUNK_OVERLAP: Overlap between chunks (default:50)RESULTS_TOPK: Default number of results to return (default:10)
The Weaviate configuration is defined in vector-db/docker-compose.yml:
- Port: 8080 (HTTP) and 50051 (gRPC)
- Authentication: Anonymous access enabled for development
- Vectorizer: Disabled (we provide our own embeddings)
- Persistence: Data persisted in Docker volume
- Start all services (Weaviate, Django backend, Next.js frontend)
- Open the application at
http://localhost:3000 - Enter a website URL you want to search (e.g.,
https://example.com) - Enter your search query
- Select the number of results you want to see (3, 5, 10, or 15)
- Click Search to get semantic search results
The application will:
- Fetch the HTML content from the provided URL
- Parse and clean the HTML
- Split the content into chunks
- Generate embeddings for each chunk
- Store everything in Weaviate
- Perform semantic search and return ranked results
Search for content within a specific URL.
Request Body:
{
"url": "https://example.com",
"query": "your search query",
"count": 5
}Response:
{
"url": "https://example.com",
"query": "your search query",
"count": 5,
"results": [
{
"ordinal": 1,
"score": 0.95,
"html_snippet": "<p>Content chunk...</p>",
"text_preview": "Text preview...",
"tokens": 150
}
]
}site-search/
βββ s_s_backend/ # Django backend
β βββ search/ # Search app
β β βββ services/ # Business logic
β β βββ views.py # API endpoints
β β βββ models.py # Data models
β βββ s_s_backend/ # Django settings
βββ s_s_frontend/ # Next.js frontend
β βββ src/
β β βββ app/ # App router pages
β β βββ components/ # React components
β β βββ lib/ # Utilities
β βββ package.json
βββ vector-db/ # Weaviate configuration
β βββ docker-compose.yml
βββ README.md
search/services/fetch_html.py: Fetches HTML content from URLssearch/services/parse_html.py: Cleans and extracts text from HTMLsearch/services/tokenise.py: Splits text into chunkssearch/services/embeddings.py: Generates OpenAI embeddingssearch/services/vector_store.py: Manages Weaviate operationssearch/services/search_flow.py: Orchestrates the search pipeline
-
Weaviate connection errors:
- Ensure Docker is running
- Check if port 8080 is available
- Restart Weaviate:
docker-compose restart
-
OpenAI API errors:
- Verify your API key is correct
- Check your OpenAI account has credits
- Ensure the API key has the necessary permissions
-
403 Forbidden errors when fetching URLs:
- Some websites block automated requests
- The application includes browser-like headers to bypass basic bot detection
- Try different URLs if some are blocked
-
CORS issues:
- Ensure the Django backend is running on port 8000
- Check that CORS settings allow localhost:3000
- Django logs: Check the console where you ran
python manage.py runserver - Next.js logs: Check the console where you ran
npm run dev - Weaviate logs:
docker-compose logs weaviate
For production deployment:
- Set up a production Weaviate instance
- Configure Django for production (settings, database, static files)
- Build and deploy the Next.js app
- Set up proper environment variables
- Configure reverse proxy (nginx/Apache)
- Set up SSL certificates
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the troubleshooting section
- Search existing issues
- Create a new issue with detailed information
Built with β€οΈ using Django, Next.js, and Weaviate.