Guide Home 1. Solution Topology 2. Aspire as 3. Shared Configuration 4. Metadata with 5. Upload API 6. Object Storage 7. Worker Ingestion 8. Extracting and 9. Literary Artifacts 10. AI Provider 11. Qdrant Vector 12. Ask Flow 13. Prompting and 14. Testing the 15. Local Development All Guides
Guide navigationIndex and chapters
Chapter 3

Shared Configuration and Contracts

How shared options and interfaces keep model providers and storage details out of workflow code.

Decorative chapter image for Shared Configuration and Contracts
The contracts keep model vendors out of workflow code
public interface IEmbeddingProvider
{
    Task<float[]> GenerateEmbeddingAsync(string input, CancellationToken cancellationToken);
}

public interface IChatCompletionProvider
{
    Task<string> GenerateAnswerAsync(string question, IReadOnlyList<RetrievedChunk> chunks, CancellationToken cancellationToken);
}

RAG.Core/Configuration/RagOptions.cs defines strongly typed settings:

This keeps configuration access consistent. Instead of reading raw strings throughout the app, services receive IOptions&lt;RagOptions&gt;.

The key interfaces live in RAG.Core/Services/Contracts.cs.

Important contracts:

These interfaces are the main teaching point of the project. The application workflow depends on stable capabilities, not on a specific vendor SDK.

Request Guardrails

RequestOptions adds limits around the ask path: maximum question characters, maximum selected documents, maximum generated retrieval queries, and provider timeout seconds. Those limits are deliberately configuration-backed because RAG cost and latency are operational concerns, not only code concerns.

public sealed class RequestOptions
{
    public int MaxQuestionCharacters { get; set; } = 2000;
    public int MaxSelectedDocuments { get; set; } = 20;
    public int MaxRetrievalQueries { get; set; } = 12;
    public int ProviderTimeoutSeconds { get; set; } = 90;
}

This is a small but important shift: the sample no longer treats user questions as harmless strings. The application validates request shape before it starts embedding queries, searching vectors, or calling a paid/remote model.