Skip to content

All articles

AI without the data leaving: the local gateway architecture

When a retailer starts talking about artificial intelligence, two objections arrive at once. IT says “we cannot put one more load on the ERP; the tills will slow down.” Legal says “customer and employee data cannot leave the company.” Both are right. This article describes a setup that accepts both objections from the start: the local gateway architecture our team designed for a multi-store retailer.

The problem: two easy roads, two different risks

The first easy road is to send the data as it is to a model in the cloud. It is quick to set up, but raw sales, customer and staff data leave the company’s control.

The second is to run everything on a single machine inside the company. The data stays in, but large models do not fit on that machine, and the system jams when dozens of people ask questions at the same time.

The setup we propose sits between the two: the data stays inside, and only the question and the table structure go out.

Three zones

Three zones: the data stays inside, only the question goes out

1. The source: the ERP. No AI query ever reaches the ERP. It is only where transaction records come from, and it keeps working exactly as it does today.

2. The local gateway. One machine with plenty of memory, inside the company. It acts as the traffic officer:

  • It copies changes in the ERP to its own database within seconds by reading the database’s transaction log (change data capture). Because it sends no queries to the ERP, it causes no delay at the tills.
  • It turns complex ERP tables into plain views a model can understand: “current stock summary”, “sales by store” and the like.
  • It indexes internal documents (return rules, HR guidelines) locally.
  • It runs a small local language model. That model has one job: to remove personal data from every text that is about to go out.

3. The cloud: reasoning. The large model sits in the company’s own private cloud account. It receives only table structures and a question from which personal data has been removed. The model writes the query that should run and sends it back; the query runs on the local gateway, over the company’s own data. Row-level data never goes to the cloud.

The layers of the architecture, shown for a fictional company (Novaria): the data line, the document index and the question flow. The screen is a demonstration simulation.

How a question is answered

  1. A store manager types a question: “Which products are about to run out this week?”
  2. The local gateway decides whether it is a data question or a document question.
  3. It gathers the relevant table structure and, if any, the relevant document passages.
  4. The local model scans the text and removes personal data such as names, phone numbers and identity numbers.
  5. The cleaned question and the table structure go to the large model over a private link.
  6. The large model writes the query to run.
  7. The query runs locally; the answer is shown to the person who asked, to the extent of their own access.

Three rules that prevent wrong answers

  • No invented stock. The model may use only the prepared plain views. If the view it needs does not exist, it does not guess; it says “I cannot reach this information.”
  • Everyone sees their own store. Access is defined inside the database, not on the screen. The manager of one store cannot see the stock or revenue of another, however the question is phrased.
  • It says when the data is stale. If the stream from the ERP falls more than five minutes behind, the answer starts with a notice: “data is current as of this time.”

The simulation: a stock question, a guideline question and a malicious request stopped by the filter. Figures and store names are invented; the screen text is in Turkish.

The twelve-week plan

Weeks 1–4: infrastructure and data flow. The machine is set up, a read-only data stream from the ERP is started, and the plain views are written. At the end there is a live data line that puts no load on the ERP.

Weeks 5–8: question answering. Documents are indexed, the flow that sends each question down the right road is built, and the cloud link and the personal-data filter go into service. At the end an assistant answers stock and guideline questions.

Weeks 9–12: security and rollout. The user screen, per-store access, the staleness notice, load testing and acceptance testing with staff.

The team runs the system itself

During the same twelve weeks, a training programme of two sessions a week runs for the company’s IT and software teams. Half of each session is explanation; the other half is practice on the system being built.

At the end we expect the team to do three things on its own: restart the whole system without losing data, open a new ERP field to the model, and add a new set of documents to the index. The aim is that the company does not stay dependent on us.

What happens if the machine fails

Nothing stops. The setup only reads; it does not write to the ERP or the tills. If the local gateway goes down, the stores keep working; only the question screen stops answering for a while.

The next step: fully inside

This setup is a beginning. Once its gain has been measured, the large model too can move to a multi-GPU server inside the company. At that point the cloud is no longer needed. The architecture is designed for this from the start; the move does not require rewriting the system.

The tools

The whole setup uses common open-source tools: Apache Kafka and Debezium for the data stream, PostgreSQL and pgvector for the database and the document index, LangGraph for the flow, a small Llama model on Ollama as the local model, and Open WebUI for the user screen. The only licensed part is the large model in the cloud account the company already uses.

Let's work out where to start, in 30 minutes

The call is free and it is not a sales pitch. We listen to the job your team spends the most time on each week; afterwards we send a one-page note on the jobs that would pay off fastest for you.