|
1 | | -# Architecture |
| 1 | +# Search Architecture |
2 | 2 |
|
3 | | -TODO: Document service architecture |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Search service is a Kubernetes-native API built on the aggregated |
| 6 | +API server framework that provides advanced resource discovery capabilities |
| 7 | +through field filtering and full-text search. It enables platform users to |
| 8 | +efficiently query and locate resources across the cluster using powerful |
| 9 | +indexing and real-time event processing. |
| 10 | + |
| 11 | +## Architecture Diagram |
| 12 | + |
| 13 | +> [!NOTE] |
| 14 | +> |
| 15 | +> Below is a [C4 container diagram][c4] of the service and it's dependencies. |
| 16 | +> This is meant to model individual components in the system and their |
| 17 | +> responsibilities. It does not aim to provide visibility into external system |
| 18 | +> components that may be a dependency of this system. |
| 19 | +
|
| 20 | +<p align="center"> |
| 21 | + <img src="./diagrams/SearchServiceContainers.png" alt="Search service component software architecture diagram"> |
| 22 | +</p> |
| 23 | + |
| 24 | +[c4]: https://c4model.com |
| 25 | + |
| 26 | +## Components |
| 27 | + |
| 28 | +### Search API Server |
| 29 | + |
| 30 | +**Purpose**: Expose search capabilities as native Kubernetes APIs |
| 31 | + |
| 32 | +**Responsibilities**: |
| 33 | +- Register custom API endpoints under `search.miloapis.com/v1alpha1` |
| 34 | +- Handle authentication and authorization via Kubernetes RBAC |
| 35 | +- Provide RESTful API for search queries |
| 36 | +- Manage custom resource definitions for the search service |
| 37 | + |
| 38 | +**Query Types**: |
| 39 | +- **Field Filtering**: Exact match, prefix, range queries on structured fields |
| 40 | +- **Full-Text Search**: Fuzzy matching, phrase queries, relevance scoring |
| 41 | + |
| 42 | +### Resource Indexer |
| 43 | + |
| 44 | +**Purpose**: Real-time indexing of platform resources from audit logs |
| 45 | + |
| 46 | +**Responsibilities**: |
| 47 | +- Subscribe to NATS JetStream audit log topic |
| 48 | +- Filter events based on active index policies |
| 49 | +- Evaluate CEL expressions for conditional indexing |
| 50 | +- Extract and transform resource data for indexing |
| 51 | +- Write to index backend with proper error handling and retries |
| 52 | +- Manage index lifecycle (creation, updates, deletion) |
| 53 | +- Bootstrap indexes from existing state |
| 54 | + |
| 55 | +### Controller Manager |
| 56 | + |
| 57 | +**Purpose**: Manages and validates resources for the search service |
| 58 | + |
| 59 | +**Responsibilities**: |
| 60 | +- Validates and activates index policies |
| 61 | + |
| 62 | +### Index Backend Storage |
| 63 | + |
| 64 | +**Purpose**: High-performance full-text search and indexing |
| 65 | + |
| 66 | +**Responsibilities**: |
| 67 | +- Structured metadata (namespace, name, labels, annotations) filtering |
| 68 | +- Full-text searchable content |
| 69 | + |
| 70 | +> [!NOTE] |
| 71 | +> |
| 72 | +> We're targeting [Meilisearch] as our first integration backend for indexed |
| 73 | +> storage. |
| 74 | +
|
| 75 | +[Meilisearch]: https://www.meilisearch.com |
0 commit comments