This Symfony application enables natural language product search through AI-powered semantic understanding. It imports product data from XML, vectorizes product attributes using OpenAI embeddings, and stores them in Milvus vector database for efficient similarity search.
- Import electronic products from XML files
- Vectorize product properties with OpenAI Embeddings
- Store and search products in Milvus vector database
- Natural language product search via API
- Web interface with DeepChat for intuitive user interaction
- Flexible configuration for API keys and endpoints
- Symfony 6.4: Core application framework
- PHP 8.2+: Required runtime
- OpenAI API: For embeddings and chat completions
- Milvus: Vector database for similarity search
- DDEV: Local development environment
- Gitpod: Cloud development environment
The application follows a service-oriented architecture with key components organized into controllers, services, and entities.
-
Controllers:
ProductFinderController: Handles product search API endpointsWebInterfaceController: Manages the web interface
-
Services:
XmlImportService: Parses XML files and extracts product dataOpenAIEmbeddingGenerator: Generates vector embeddings using OpenAIMilvusVectorStoreService: Manages vector database interactionsOpenAISearchService: Generates natural language recommendationsPromptService: Manages prompts for OpenAI chat models
-
Entities:
Product: Represents products with properties, features, and specifications
- User submits natural language query
- Query is vectorized using OpenAI embeddings
- Vector search finds similar products in Milvus
- Results are filtered by relevance threshold (distance ≤ 0.5)
- OpenAI generates natural language recommendations based on results
- User receives product recommendations and matching products
For detailed architecture diagrams, see the Architecture Documentation.
- PHP 8.2 or higher
- Composer
- DDEV (recommended for local development)
-
Clone the repository:
git clone git@github.com:iGore/symfony-product-finder.git cd symfony-product-finder -
Install dependencies:
ddev composer install -
Configure environment variables in
.env.local:OPENAI_API_KEY=your_openai_api_key OPENAI_EMBEDDING_MODEL=text-embedding-3-small OPENAI_CHAT_MODEL=gpt-3.5-turbo MILVUS_API_KEY=your_milvus_api_key MILVUS_HOST=your_milvus_endpoint MILVUS_PORT=443 MILVUS_COLLECTION=products -
Start the application:
ddev start
For quick development without local setup, use Gitpod:
Gitpod provides a ready-to-use environment with DDEV pre-configured. The application is automatically started and accessible via the URL provided by Gitpod.
Import sample products from XML:
ddev php bin/console app:import-products src/DataFixtures/xml/sample_products.xml
The import process vectorizes both complete products and their individual features/specifications, enabling precise semantic matching.
Try the natural language search:
ddev php bin/console app:test-search "I need a waterproof smartphone with a good camera"
Access the chat interface at https://symfony-product-finder.ddev.site/ to search for products using natural language.
- Custom XML Format: Modify
XmlImportService.phpto support different XML structures - Alternative Embedding Providers: Implement
EmbeddingGeneratorInterfaceto use different vector providers - Vector Database Configuration: Customize
MilvusVectorStoreService.phpfor specific vector storage needs
Run the test suite:
ddev php bin/phpunit
- Controllers:
src/Controller/- API endpoints and web interface - Services:
src/Service/- Business logic and integrations - Entities:
src/Entity/- Data models - DTOs:
src/DTO/- Data transfer objects for API requests/responses
This project is licensed under the MIT License.