Skip to main content
Back to examples
AI/AI semantic search
Source

This example runs from source. Open the repository to clone, build, and run it locally.

Open on GitHub
AI

AI semantic search

Search Gantt tasks by meaning instead of keywords, using locally generated embeddings from an Ollama model matched against precomputed task vectors.

# DHTMLX Gantt - Semantic Search Demo

AI-powered semantic search inside a [DHTMLX Gantt](https://dhtmlx.com/docs/products/dhtmlxGantt/) chart. Type natural-language queries and find relevant tasks by meaning, not just keywords.

For a step-by-step implementation guide, see the [Semantic Search tutorial](https://docs.dhtmlx.com/gantt/integrations/ai-tools/semantic-search/) in the DHTMLX Gantt documentation.

## Quick Start

```bash
docker compose up --build
```

Then open **http://localhost:11436** in your browser.

On first launch, the Ollama container downloads the embedding model and warms it up before semantic search becomes available. This can take a little while depending on your machine and network connection.

The sample uses Ollama as a local embedding runtime for simplicity and reproducibility.

## How It Works

1. The Gantt chart loads about 60 tasks from the backend.
2. When you search, the backend generates an embedding for your query using a local model (`all-minilm` via [Ollama](https://ollama.com/)).
3. The backend compares the query embedding with stored task embeddings and returns matches sorted by relevance score. Embeddings for the initial dataset are precomputed, while new or updated tasks are embedded during runtime.
4. Matching tasks are highlighted in the Gantt chart and non-matches are dimmed.

All processing runs locally. No external AI API is called while you use the demo.

## Runtime Notes

- CRUD changes are stored in memory only and are reset when the backend container restarts.
- Semantic search may be temporarily unavailable during initial model download or model warm-up.
- To test with a different embedding model, change `MODEL_NAME` in `backend/main.py`, restart the backend, and call `GET /api/embeddings/recalculate` to regenerate all task embeddings.

## Example Queries

- `"authentication and security"` - finds tasks about auth modules, security assessment, and social login
- `"deployment pipeline"` - finds CI/CD configuration, production setup, and monitoring tasks
- `"user interface"` - finds UI prototyping, responsive design, and onboarding flow tasks
- `"database and storage"` - finds schema design, ORM setup, and data migration tasks

## Architecture

```text
Browser (port 11436)
-> nginx (reverse proxy)
-> / -> static frontend (index.html)
-> /api/* -> FastAPI backend (port 11435)
-> /api/embeddings/* -> FastAPI backend (port 11435)
-> /search -> FastAPI backend (port 11435)
-> Ollama (port 11434)
```

| Service | Port | Description |
|----------|-------|-------------|
| Frontend | 11436 | nginx serving the Gantt UI |
| Backend | 11435 | FastAPI - CRUD plus semantic search |
| Ollama | 11434 | Local embedding runtime used by the demo |

## Project Structure

```text
frontend/
index.html # HTML shell and search toolbar
main.js # Gantt init, search logic, DataProcessor
styles.css # Dark theme, search highlight styling
nginx.conf # Reverse proxy config
Dockerfile
backend/
main.py # FastAPI server
data.json # Task data plus precomputed embeddings
requirements.txt
Dockerfile
ollama/
init.sh # Model pull script
Dockerfile
docker-compose.yml
```

## Requirements

- [Docker](https://docs.docker.com/get-docker/) and Docker Compose

## License

Source code in this repo is released under the **MIT License**.

**DHTMLX Gantt** is a commercial library - use under a valid [DHTMLX license](https://dhtmlx.com/docs/products/licenses.shtml) or evaluation agreement.

## Useful links

- [Semantic Search Tutorial](https://docs.dhtmlx.com/gantt/integrations/ai-tools/semantic-search/) - step-by-step implementation guide
- [DHTMLX Gantt Product Page](https://dhtmlx.com/docs/products/dhtmlxGantt/)
- [DHTMLX Gantt Documentation](https://docs.dhtmlx.com/gantt/)
- [Ollama](https://ollama.com/) - local embedding runtime used by this demo
- [all-minilm Model](https://ollama.com/library/all-minilm) - embedding model used for semantic search
- [DHTMLX Technical Support Forum](https://forum.dhtmlx.com/)