Ahmed Lotfy MahfouzTechnical Team Lead, Dubai

Case study

Production AI, on-premises

How my team runs four AI workloads in production (code review, security code review, grounded RAG chat, and code generation) on self-hosted LLMs served by Ollama on NVIDIA DGX, behind one .NET abstraction, with sensitive data never leaving the organization.

  • Role Technical Team Lead, owner
  • Team 5 engineers
  • Stack .NET, MEAI, Ollama, DGX
  • Outcome In production, used daily

The problem

Hosted LLM APIs are the fastest way to ship AI features, and a non-starter for a large part of enterprise work. Our source code, internal policies, incident history, and operational documents are exactly the inputs that make AI useful for engineering teams, and exactly the data that cannot cross the organization's boundary.

The naive answers both fail. "Just use the API" fails compliance. "Ban AI" fails the team: engineers were already losing hours to manual code review passes, repetitive security checklists, and hunting through documentation. The real requirement was: bring the model to the data, not the data to the model.

The architecture

Every consumer (CI pipelines, the chat UI, IDE tooling) talks to one .NET gateway built on Microsoft.Extensions.AI's IChatClient abstraction. The gateway routes each request by data sensitivity: workloads touching internal code or documents go to open models served by Ollama on NVIDIA DGX hardware, fully on-premises; general-purpose requests can route to hosted models. Sensitivity is a per-request decision, not a per-project rewrite.

Architecture: one .NET AI gateway routing by data sensitivity CI/CD pipelines, the chat UI and engineering tools call a .NET AI gateway built on IChatClient. Sensitive requests go to open models on Ollama on NVIDIA DGX and to a vector store, both inside the organization's boundary; general requests can go to hosted APIs. An offline ingestion pipeline chunks docs and repos, embeds them on-premises and indexes them in the vector store. CI/CD pipelinescode + security review Chat UIgrounded RAG assistant Engineering toolscode generation .NET AI gateway IChatClient (MEAI) auth, rate limits, telemetry structured output, retries route by data sensitivity org boundary: data stays inside Ollama on NVIDIA DGXopen models, quantized, queued Vector storeembeddings of code + docs Hosted APIs (Claude / OpenAI)non-sensitive workloads only ingestion (offline) Docs + repos → chunksembed on-prem → index sensitive general
One gateway, two worlds: routing by sensitivity makes on-prem vs hosted a configuration decision.

Four workloads in production

CI-integrated

AI code review

Every merge request gets a model pass before human review: correctness risks, N+1 queries, missing cancellation tokens, convention drift. Findings post as structured review comments. Humans stay the approvers; the model clears the underbrush.

in
diff + surrounding context
out
typed findings → MR comments

CI-integrated

Security code review

A separate pass with a security-specific prompt and ruleset: injection risks, authZ gaps, secret leakage, unsafe deserialization. Runs on-prem by necessity: the code being audited is exactly what can't be sent to an external API.

in
diff + dependency manifest
out
severity-ranked findings

Interactive

Grounded RAG chat

An assistant answering from our own knowledge: internal docs and repos are chunked, embedded on-prem, and retrieved per question. Answers cite their sources; "grounded" means the model is constrained to retrieved context, not free to improvise policy.

in
question + top-k retrieved chunks
out
cited answer

Tooling

Code generation

Scaffolding, tests, migrations, and boilerplate generated against our conventions, with repository context retrieved the same way the chat is grounded. Output is a starting point that compiles against our patterns, not generic samples from the internet.

in
spec + retrieved repo context
out
code, reviewed like any code

Decisions and trade-offs

DecisionWhyThe trade-off we accepted
Self-host on DGXData boundary is non-negotiable for code and internal docsWe own ops, upgrades, and capacity planning; models trail frontier quality
MEAI abstractionRouting is config, not rewrites; providers are swappableA thin layer to maintain; occasional provider-specific features need escape hatches
Structured output everywhereCI can't parse prose, so findings must be typed and validatedStricter prompts; a retry-with-error loop for schema violations
Humans stay approversModel findings advise, never gate a merge aloneSlower than full automation, by design
Eval set before every swapModel/quantization changes are deploys, not experimentsMaintaining golden datasets takes real time

What it changed

  • Review depth without review delay. Every merge request now gets a consistent automated pass for both quality and security before a human ever looks, so human reviewers spend their attention on design instead of lint-level findings.
  • Institutional knowledge became queryable. Questions that used to mean finding-the-right-person now get cited answers from the docs themselves.
  • AI adoption without a compliance fight. The boundary question was answered by architecture, not by policy exceptions.
  • A reusable platform, not a feature. New workloads onboard by writing a prompt and a typed contract against the same gateway.

The unlock wasn't the model. It was treating AI infrastructure like any other production system: one abstraction, routed by data sensitivity, observable, and evaluated before every change.