A production-grade vector database built in Go, designed for high-performance similarity search and hybrid search capabilities.
- Vector Storage: Store and manage high-dimensional vectors with metadata
- Similarity Search: Perform cosine similarity search with filtering
- Hybrid Search: Combine vector similarity with keyword search using BM25
- Document Management: Store and manage documents with tags
- RESTful API: Clean, well-documented REST API
- Production Ready: Structured logging, error handling, middleware, and graceful shutdown
- Persistent Storage: Built on BoltDB for reliable data persistence
- Configurable: Environment-based configuration
- Health Checks: Built-in health monitoring endpoints
├── cmd/ # Application entry points
│ └── vectordbd/ # Main server application
├── internal/ # Private application code
│ ├── api/ # HTTP handlers and routing
│ ├── config/ # Configuration management
│ ├── logger/ # Structured logging
│ ├── middleware/ # HTTP middleware
│ ├── models/ # Data models and DTOs
│ ├── store/ # Data storage interfaces and implementations
│ └── utils/ # Utility functions
├── pkg/ # Public library code
│ ├── errors/ # Error handling
│ └── response/ # HTTP response utilities
├── docs/ # Documentation
├── scripts/ # Build and deployment scripts
├── deployments/ # Deployment configurations
└── tests/ # Test files
- Go 1.24.7 or later
- Make (optional, for using Makefile)
- Clone the repository:
git clone <repository-url>
cd vectra_db- Install dependencies:
go mod tidy- Build the application:
make build
# or
go build -o bin/vectordbd ./cmd/vectordbd- Run the server:
make run
# or
./bin/vectordbdThe server will start on port 8080 by default.
VectraDB can be configured using environment variables:
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
Server port |
DB_PATH |
vectra.db |
Database file path |
LOG_LEVEL |
info |
Log level (debug, info, warn, error) |
LOG_FORMAT |
json |
Log format (json, text) |
READ_TIMEOUT |
30s |
HTTP read timeout |
WRITE_TIMEOUT |
30s |
HTTP write timeout |
IDLE_TIMEOUT |
120s |
HTTP idle timeout |
DB_TIMEOUT |
1s |
Database operation timeout |
http://localhost:8080/api/v1
POST /vectors
Content-Type: application/json
{
"id": "vector-1",
"vector": [0.1, 0.2, 0.3, 0.4],
"text": "Sample text",
"metadata": {
"category": "example",
"source": "test"
}
}GET /vectors/{id}PUT /vectors/{id}
Content-Type: application/json
{
"vector": [0.1, 0.2, 0.3, 0.4],
"text": "Updated text",
"metadata": {
"category": "updated"
}
}DELETE /vectors/{id}GET /vectors?limit=10&offset=0POST /search
Content-Type: application/json
{
"query": [0.1, 0.2, 0.3, 0.4],
"top_k": 10,
"limit": 10,
"page": 1,
"filter": {
"category": "example"
},
"weights": {
"vector": 1.0,
"metadata": 0.0
}
}POST /search/hybrid
Content-Type: application/json
{
"query": "search text",
"query_vector": [0.1, 0.2, 0.3, 0.4],
"vector_weight": 0.5,
"keyword_weight": 0.5,
"limit": 10,
"page": 1
}POST /documents
Content-Type: application/json
{
"id": "doc-1",
"title": "Sample Document",
"content": "Document content here",
"tags": ["tag1", "tag2"]
}GET /documents/{id}PUT /documents/{id}
Content-Type: application/json
{
"title": "Updated Document",
"content": "Updated content",
"tags": ["tag1", "tag3"]
}DELETE /documents/{id}GET /documents?limit=10&offset=0GET /documents/tags/{tag}?limit=10&offset=0GET /healthResponse:
{
"success": true,
"data": {
"status": "healthy"
},
"timestamp": "2024-01-01T00:00:00Z"
}make test
# or
go test ./... -vgo fmt ./...golangci-lint rundocker build -t vectradb .docker run -p 8080:8080 vectradbdocker-compose upSet the following environment variables for production:
export PORT=8080
export DB_PATH=/data/vectra.db
export LOG_LEVEL=info
export LOG_FORMAT=json
export READ_TIMEOUT=30s
export WRITE_TIMEOUT=30s
export IDLE_TIMEOUT=120sThe application provides a health check endpoint at /health that can be used by load balancers and monitoring systems.
The application supports graceful shutdown on SIGINT and SIGTERM signals, allowing up to 30 seconds for ongoing requests to complete.
- Vector Dimensions: Supports vectors up to 10,000 dimensions
- Batch Operations: Use pagination for large result sets
- Memory Usage: Vectors are cached in memory for fast access
- Database: BoltDB provides ACID transactions and crash recovery
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue on GitHub.