Zing Forum

Reading

Building a Multilingual Intelligent Recipe Search System: A Complete Practice from Architecture Design to Deterministic Sorting

This article deeply analyzes a multilingual recipe search API project based on ASP.NET Core, exploring its layered architecture design, AI-driven query understanding mechanism, deterministic sorting algorithm, and cloud-native deployment solution, providing a reference for building predictable and traceable search systems.

食谱搜索多语言APIAzure OpenAI确定性排序ASP.NET Core分层架构智能查询理解云原生部署
Published 2026-04-06 01:18Recent activity 2026-04-06 02:48Estimated read 6 min
Building a Multilingual Intelligent Recipe Search System: A Complete Practice from Architecture Design to Deterministic Sorting
1

Section 01

[Introduction] Core Design and Practical Value of the Multilingual Intelligent Recipe Search System

This article introduces a multilingual recipe search API project based on ASP.NET Core. Its core is to separate AI query understanding from deterministic sorting rules, combining layered architecture and cloud-native deployment to provide a reference for building predictable and traceable search systems. The project uses AI to process multilingual input and extract intents, and a rule system to ensure sorting transparency, balancing intelligence and determinism.

2

Section 02

Project Background and Core Positioning

Traditional keyword search struggles to handle multilingual, colloquial, and complex ingredient requirements. This project provides a solution: a multilingual API based on ASP.NET Core. The core concept is separation of concerns—AI is used for query understanding (translation, extraction, normalization), while retrieval and sorting rely on a deterministic rule system, avoiding the black-box problem of pure vector search and ensuring result predictability and debuggability.

3

Section 03

System Architecture and Search Process

The system adopts a layered architecture:

  1. API Layer: Handles HTTP requests, including controllers, DTOs, validation, rate limiting, etc.
  2. Application Layer: Orchestrates search flow, executes sorting logic, and abstracts query understanding services.
  3. Domain Layer: Core concept models (Recipe, SearchQuery, etc.).
  4. Infrastructure Layer: Dataset loading (local JSON/Azure Blob), in-memory repository, and Azure OpenAI integration. The search process consists of seven steps: Validation → AI Understanding → Retrieval → Deterministic Sorting → Result Return, ensuring debuggability.
4

Section 04

Detailed Explanation of Deterministic Sorting Algorithm

Sorting uses a rule-based scoring system:

  • Ingredient Matching: Exact phrase (+6), strong match (+4), weak match (+1); extra +2 if the ingredient appears in the title.
  • Keyword Matching: Name match (+3), ingredient text match (+2). Results are sorted in descending order of total score; 0-score entries are filtered; entries with the same score retain their original order, ensuring transparency and interpretability.
5

Section 05

AI Query Understanding and Data Storage Strategy

AI is only used for query understanding:

  • Multilingual Support: Detects input language and normalizes it to English (e.g., Swedish 'kyckling' → 'chicken').
  • Intent Extraction: Extracts structured ingredients and keywords from colloquial expressions (e.g., a Swedish query extracts 'fish', 'coconut milk', 'spicy').
  • Noise Filtering: Excludes irrelevant filler words. Data storage uses in-memory loading (loaded at startup). Advantages: Low latency, determinism, simplified deployment; supports local JSON or Azure Blob, suitable for scenarios with controllable scale.
6

Section 06

Testing, Deployment, and Design Trade-offs

Testing covers core behaviors (dataset parsing, sorting, filtering, etc.). Deployment is on Azure App Service, using Blob storage for datasets and OpenAI services; configuration manages sensitive information via key management. Design trade-offs: In-memory storage, rule-based sorting, no synonym dictionary—suitable for scenarios with controllable datasets, need for interpretable results, and mandatory multilingual support. For million-level data, specialized search infrastructure is required.

7

Section 07

Conclusion: Balance Between Intelligence and Determinism

The project demonstrates the design idea of 'AI-enhanced but not over-reliant': AI handles natural language understanding, while the rule system ensures predictable sorting. Value for developers: Provides code references and design philosophy—emphasize determinism and interpretability while embracing intelligence; systems that users can understand and developers can debug have greater practical value.