A Reference Architecture
Most teams adopt AI by bolting a model call onto an existing app. That works for a demo and collapses under real load, real security review, and real change requests. A reference architecture gives a .NET shop a default shape β a set of named layers with clear responsibilities β so every new AI feature starts from the same defensible blueprint. LyraLearn is that blueprint, so we'll use it as the running example.

The layered AI stack, made concrete
For a .NET / SQL Server / Azure shop, the stack has seven layers. Each maps to a real component:
- Data & system-of-record β SQL Server 2025 holds both the business data (lessons, users, knowledge-base documents) and the vector embeddings. One database is the source of truth and the vector store, so retrieval joins against live business data with no second system to keep in sync.
- Ingestion service β a background worker that pulls approved content in, chunks it, embeds each chunk, and writes the vectors back. It runs continuously, not as a one-off.
- Retrieval β given a query, find the most relevant chunks via SQL Server native vector search, optionally blended with keyword filters.
- Inference β embedding and generation calls, each behind an interface so the provider (local model, Azure OpenAI, etc.) is a configuration choice, not a code rewrite.
- Orchestration β the use-case logic that sequences retrieve β ground β validate β answer. This is where the AI Tutor lives.
- API & UI β the ASP.NET Core endpoints and Razor/Blazor pages the user touches.
- Cross-cutting β security, observability, audit, and governance, threaded through every layer rather than added at the edge.
Why the boundaries pay off
Each boundary is a place to enforce one quality goal and to swap an implementation without disturbing its neighbors. Cost is contained at inference (local embeddings cost nothing per call). Correctness is enforced at retrieval and orchestration (grounding, validation). Security is enforced at the data and inference layers (what the AI may see; where data travels). When a hallucination, a leaked record, or a runaway bill appears, the architect's first question is which layer failed β and a layered system always has an answer.
LyraLearn as the worked example
- Data: SQL Server 2025 β lessons, KB documents, and embeddings in one store.
- Ingestion: an outbox-driven importer that chunks and embeds lesson content.
- Retrieval: SQL Server native vector search over those chunks.
- Inference: local embeddings plus local/cloud generation, all behind interfaces.
- Orchestration: the AI Tutor (retrieve β grade β ground β answer).
- API & UI: this ASP.NET Core web app.
- Cross-cutting: an audit and evaluation record for every AI call.
The rest of this module zooms into each concern β Clean Architecture, integration, scaling β using exactly this stack.