Skip to main content

Data Flow

This document describes how data flows through Sercha Core for the two primary operations: search and sync.

Search Flow

When a user submits a search query:

Search Modes

ModeWhen UsedQuery Path
hybridEmbedding service availableBM25 + Vector ANN
text_onlyNo embedding or fallbackBM25 only
semantic_onlyExplicit requestVector ANN only

Sync Flow

When documents are synchronized from a source:

Sync Stages

StageComponentAction
1. FetchConnectorPull documents from source
2. NormalizeNormalizerConvert to standard format
3. ChunkChunkServiceSplit into searchable units
4. StoreDocumentStorePersist metadata
5. IndexIndexServiceAdd to search engine

Authentication Flow

Token-based authentication for API requests:

Error Handling

Errors flow up through the layers with context:

Adapter Error → Domain Error → Service Error → HTTP Error
LayerError TypeExample
AdapterInfrastructure errorsql.ErrNoRows
DomainBusiness errorErrUserNotFound
ServiceWrapped with context"failed to get user: not found"
HTTPStatus code + message404 {"error": "user not found"}

Next