Architecture
How SLAP is built, and why each piece is there. Written to be read by someone who has never seen the project, including another organization trying to reproduce it (sponsor must-have M-5).
Last updated: 2026-12-01.
1. The problem being solved#
An organization has documents it cannot send to a public AI service. The information may be sensitive, proprietary, export-controlled, security-related or privacy-protected. They still want what AI assistance offers: ask a question in plain language, get an answer grounded in their own material.
Every part of the design follows from one constraint: the documents and the questions asked about them must never leave hardware the organization controls.
That single constraint rules out the entire mainstream approach. No API keys, no cloud inference, no hosted vector database, no telemetry. Everything that would normally be somebody else's server has to run on this machine.
2. The five components#
WHAT THE USER TOUCHES WHAT MAKES IT WORK
───────────────────── ──────────────────
┌───────────────┐ ┌───────────────┐
│ nginx │ │ Ollama │
│ front door │ │ runs the AI │
└───────────────┘ └───────────────┘
┌───────────────┐ ┌───────────────┐
│ Open WebUI │ │ Qdrant │
│ the chat app │ │ document index│
└───────────────┘ └───────────────┘
┌───────────────┐
│ Apache Tika │
│ reads files │
└───────────────┘
nginx - the front door#
A reverse proxy. Every request from every browser arrives here first, and it passes them to the application behind it.
Why have it at all, when there is only one application behind it? Three reasons that only matter later, which is exactly when it is too late to add:
- One clean address. Users get
http://ai.internalinstead of a host-and-port. Non-technical people should never see a port number. - One place to add security. TLS, rate limiting, IP restrictions and audit logging all belong at the edge. Adding them here never requires touching the application container.
- Room to grow. Gary suggested chaining specialised bots. Each becomes a new route in this file rather than a new system.
It is also, deliberately, the only container allowed to touch a routable network. Section 4 explains why that matters.
Open WebUI - the application#
Everything the user sees: login, conversation history, the chat itself, document upload, and the admin panel. It is a mature open-source project, not something we wrote, and it looks and behaves like the commercial chat tools people already know.
Why not build our own interface? Because the sponsor was explicit that the deliverable is not the AI and not the UI. Rebuilding a chat interface would consume the semester and produce something worse than what already exists. Configuring an excellent one to present well is a better use of the time.
It also handles document processing, which saves us writing an ingestion service (see D-08). It hands the reading of each file to Tika.
Ollama - the inference engine#
Loads a language model into memory and generates text from it. This is the part people think of as "the AI".
It is deliberately the most replaceable component in the system. Swapping
llama3.2:3b for a larger model, or for a domain-specific one like Nuclearn
SPARK, is a configuration change. The platform is model-agnostic on
purpose, because the sponsor said the interesting question is not which
model is best.
Qdrant - the document index#
A vector database. It stores documents in a form that can be searched by meaning rather than by keyword, so "what is the procedure for a coolant leak" finds the right passage even when the document says "loss of coolant event".
This is the component holding the organization's actual content, so it is the one locked down hardest.
Apache Tika - the document reader#
Pulls the text out of uploaded files (PDF, Word and other office formats) before they are split and indexed. The image includes Tesseract, so it also reads text from scanned pages and from pictures inside a PDF (OCR), with no downloads at runtime (D-14, D-19).
It sits on the sealed ai_data network with a read-only filesystem, and only
Open WebUI can reach it. It stores nothing.
3. How a question actually gets answered#
This is the part worth understanding properly, because "the AI reads your documents" hides several steps.
First, documents get indexed (happens once, at upload)#
┌──────────┐ ┌───────────┐ ┌───────────┐ ┌──────────────┐ ┌──────────┐
│ user │ │ Tika pulls│ │ split into│ │ each chunk │ │ store in │
│ uploads │───▶│ out the │───▶│ ~1200 char│───▶│ converted to │───▶│ Qdrant │
│ a PDF │ │ text, OCR │ │ chunks │ │ a number list│ │ │
└──────────┘ └───────────┘ └───────────┘ └──────────────┘ └──────────┘
scanned pages 150 char by the model searchable
and pictures overlap so nomic-embed-text by meaning
included sentences are
not cut in half
That "number list" is an embedding: roughly 768 numbers describing what the text means. Passages about similar topics get similar numbers, which is what makes meaning-based search possible.
Then, questions get answered (happens every time)#
USER ASKS
"What is the coolant leak procedure?"
│
▼
┌─────────────────────────────────────────────┐
│ 1. RETRIEVE │
│ Convert the question to an embedding, │
│ ask Qdrant for the 5 closest chunks. │ ← Qdrant
└─────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 2. AUGMENT │
│ Build a prompt: │
│ "Using this context: <the 5 chunks> │ ← Open WebUI
│ answer: <the question>" │
└─────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 3. GENERATE │
│ The model writes an answer from the │ ← Ollama
│ supplied text. The chunks it was given │
│ are listed with the answer as sources. │
└─────────────────────────────────────────────┘
│
▼
ANSWER STREAMS BACK, WORD BY WORD
That is RAG - Retrieval Augmented Generation. The three letters map exactly onto the three boxes.
Why this matters for a safety-critical setting: the model is not recalling facts from training. It is being handed specific passages and asked to answer from them, and the passages it was handed are shown with the answer. That makes an answer checkable, which is the beginning of an argument for trustworthiness.
The source list comes from the search, not from the model, so it appears even
when the answer text cites nothing. Small models often leave the citation out:
in a Dec 1, 2026 test with Open WebUI's own prompt, llama3.2:3b put an inline
citation in 3 of 17 answers. Point users at the source list, not at the answer
text.
Why that is not yet enough: nothing forces the model to stay within the
supplied text. Measurement has started but is small. On 2026-12-01 the team
wrote a 62-question set (56 answerable, 6 not answerable from the documents)
for two test documents. The app's search, replayed outside Open WebUI with the
stack's own Tika, embedding model and Qdrant, found the right passage in its
top 3 for 28 of the 28 questions run, and ranked it first for 19. A sample of
17 answers from llama3.2:3b, scored against a written rubric, had one wrong
answer: a value read from the wrong column of a table, the known failure in
TODO item 1. Seventeen answers is too few for a rate. How trustworthy is
trustworthy enough is still stretch goal S-4 (NB-05). Do not describe this
system as hallucination-resistant.
4. The network design - the security argument#
This is the part to scrutinize, and the part most worth presenting.
The question#
How much of the system can be denied internet access outright, while still serving users?
How it was answered#
By testing, not by reading documentation. Two facts were established on real Docker:
- A container on an
internalnetwork cannot reach an external address. Confirmed by attempting a connection to1.1.1.1and having it fail. - A published port does not work on an
internalnetwork. The port is simply unreachable from the host.
Fact 2 is the constraint that shapes everything. Something has to accept connections, and that something cannot be sealed.
The resulting design#
ROUTABLE │ SEALED
│ no route off this host, enforced by Docker
│
Browser │
│ │
▼ │
┌───────┐ │ ┌─────────────┐ ┌──────────┐
│ nginx │────────┼──▶│ Open WebUI │───────▶│ Ollama │
└───────┘ │ └─────────────┘ └──────────┘
ai_public │ ai_ui │ ai_infer
│ │ ╳ blocked
│ ▼ ↑
│ ┌──────────┐ ┌──────────┐ Internet
│ │ Qdrant │ │ Tika │
│ └──────────┘ └──────────┘
│ ai_data
| Network | Internal | Who is on it | Why |
|---|---|---|---|
ai_public |
no | nginx only | Carries the published port. Cannot be sealed. |
ai_ui |
yes | nginx, Open WebUI | Lets the proxy reach the app, nothing more. |
ai_data |
yes | Open WebUI, Qdrant, Tika | The document store and reader, sealed. |
ai_infer |
yes | Open WebUI, Ollama | The model, sealed. |
The result: Ollama, Qdrant, Tika and Open WebUI have no path to the internet at any time. This is not a setting that can be forgotten or a policy someone must follow. There is no route.
nginx is on two networks: ai_public to receive connections, ai_ui to reach
the application. It is the seam between the outside and the sealed interior.
Getting models in#
Models have to be downloaded at least once. That is the one moment the seal must open, so it is made explicit, narrow and temporary:
./start_mvp.sh --online
│
├─ 1. attach a temporary network to Ollama ONLY
├─ 2. download the models
├─ 3. delete that network
└─ 4. restart sealed
Open WebUI, Qdrant and Tika stay sealed even during this. Only Ollama is exposed, only while downloading, and the same command closes it again.
./start_mvp.sh --window does the same for a timed window, 30 minutes by
default, so an admin can pull models from the admin panel. It re-seals when the
time is up or on Ctrl+C. A pull from the admin panel during a window has not
yet been tested. ALLOW_ONLINE=false in .env makes both commands refuse, and
an offline install writes that value (D-21).
The alternative is the offline bundle, where the models arrive on a flash
drive and the seal never opens at all. See DEPLOYMENT.md.
What this design does NOT do#
Stated plainly, because an overstated security claim is worse than an acknowledged gap:
- nginx can still reach the internet. It is a passive proxy that never initiates outbound connections, but the capability exists. Removing it needs host firewall rules, which is a different control.
- Traffic is unencrypted HTTP. Anyone able to capture packets on the site network can read questions and retrieved documents. TLS is deliberately deferred (NB-03).
- Nothing has been independently assessed. The design is deliberate; it has not been reviewed by anyone qualified to sign off on it (NB-06).
5. Where the data lives#
Four Docker volumes. Everything else in the system is disposable and can be recreated from the repository.
| Volume | Contains | If you lose it |
|---|---|---|
slap_open_webui_data |
user accounts, chat history, uploaded documents | Irreplaceable |
slap_qdrant_storage |
document embeddings | Rebuildable by re-uploading, slowly |
slap_ollama_models |
downloaded models | Re-downloadable, or restore from a bundle |
slap_nginx_logs |
access and error logs | Audit trail lost |
The first two are what a backup procedure must protect, together with .env,
which holds the keys. A cold backup and restore was tested on 2026-12-01 on one
machine: the restored data matched the original file for file and row for row,
and the apps started on it. The procedure is in
DEPLOYMENT.md, Backups. Not yet done: a restore on a
second machine, and any scheduled backup. For a system meant to run for years,
the missing schedule is still a real gap.
Note: docker compose down -v destroys all four. This is why stop_mvp.sh
--wipe makes you type WIPE.
6. Access model#
Private by default, like any normal chatbot:
┌──────────────────────────────────────────────────┐
│ ADMIN │
│ publishes shared libraries, approves accounts │
└──────────────────────────────────────────────────┘
│ publishes
▼
┌──────────────────────────────────────────────────┐
│ SHARED KNOWLEDGE │
│ "Plant Procedures v3" · "Safety Bulletins" │
│ everyone can query · only admin can change │
└──────────────────────────────────────────────────┘
│ queried by
┌────────┴────────┬─────────────────┐
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│ User A │ │ User B │ │ User C │
│ own │ │ own │ │ own │
│ chats │ │ chats │ │ chats │
│ own │ │ own │ │ own │
│ docs │ │ docs │ │ docs │
└────────┘ └────────┘ └────────┘
private private private
- Every user has their own chats and their own uploaded documents. No user can see another user content.
- Administrators can publish shared collections on top, which is what makes a single curated, updatable source of truth possible.
- New accounts land in
pendingand an administrator must approve them. - Signup is closed by default (
ENABLE_SIGNUP=false, D-20), and admins add people in the admin panel. The first account on a fresh install is still allowed in and becomes administrator, so whoever reaches a new install first owns it. This is why the default binding is loopback (D-06).
What this is not: true role-based access control. We cannot currently grant one role access to one collection and deny another. That is stretch goal S-5 and is only partially met.
7. Hardware and performance#
Measured on a Windows development machine, CPU only, 2026-09-03:
| Model | Size | Generation speed | Tool support |
|---|---|---|---|
llama3.2:3b |
2.0 GB | 6.45 tok/s | yes |
llama3:8b |
4.7 GB | 2.94 tok/s | no |
The smaller model is 2.2x faster on this hardware and supports tool calling, which is why it is the default (D-04 amendment). These two rows are the beginning of the hardware matrix the advisors asked for.
Later measurements on the demo PC (2026-11-19), with memory per model and waits when several people ask at once, are in sizing/README.md.
A slower machine was measured on 2026-12-01: a 2019 laptop (Intel Core
i7-10510U, no usable GPU, Docker given 4 CPUs and 8 GB, on battery and shared
with other containers). With llama3.2:3b, six document questions took 73 to
273 s to the first word. The same model on the demo PC takes 6.5 s. The
processor decides the wait as much as the model does.
Things that matter for a hardware recommendation:
- An NVIDIA GPU changes everything.
docker-compose.gpu.ymlenables it and the launcher applies it automatically. Expect an order of magnitude. - Docker on macOS cannot use the Apple GPU. This is an Apple hypervisor limitation, not a configuration problem. A Mac is CPU-only and slow.
- RAM is the hard floor. A 3B model needs roughly 8 GB of system memory, an 8B model roughly 16 GB. Below that it will not load at all.
- Model size is a real trade-off, not a straight upgrade. For an organization with modest hardware, a 3B model answering in fifteen seconds is more useful than an 8B model answering in a minute.
8. Why containers#
Every component runs in Docker, including Ollama. The alternative - installing Ollama natively for GPU access - was considered and rejected (D-01).
- The deployment is identical on Windows, macOS and Linux. One procedure to document, one to test, one to reproduce. That is must-have M-5.
- Components are isolated from each other and from the host.
- The network segmentation in section 4 is only possible because of it. That security property does not exist in a native install.
- The whole system can be saved to files and carried to an air-gapped machine.
The cost is real: no GPU acceleration on macOS, and a small performance overhead elsewhere. Accepted, because the target is a Linux server where the GPU passthrough works.
9. What is deliberately not here#
Recorded so that absences read as decisions rather than oversights. Full
reasoning in SCOPE.md.
| Absent | Why |
|---|---|
| TLS | Needs an internal CA and a client distribution plan (NB-03) |
| Custom ingestion service | Native processing works; no measurement yet says otherwise (D-08) |
| Hallucination evaluation | A first question set exists (2026-12-01); "trustworthy enough" is not defined (NB-05) |
| True RBAC | Needs a specification of what the roles are (S-5) |
| Continuous security monitoring | The offline check is point-in-time (S-2) |
| Bundle signing | Checksums detect corruption, not provenance (NB-02) |
| Docker in the offline bundle | The runtime must arrive separately (NB-02) |
10. Reading the code#
| File | What it defines |
|---|---|
docker-compose.yml |
Every service, every network, every volume. The whole architecture is in this one file. |
docker-compose.provision.yml |
The temporary network that lets Ollama download models |
docker-compose.gpu.yml |
NVIDIA passthrough |
nginx/nginx.conf |
Routing, streaming, timeouts, and the commented TLS block |
start_mvp.sh |
The deployment procedure, executable |
scripts/verify_offline.sh |
The security claim, testable |
The compose file is commented for someone learning the architecture, not for
someone who already knows it. If you change the design, change those comments
and add a DECISIONS.md entry.
Open WebUI's settings come from docker-compose.yml and .env on every start
(ENABLE_PERSISTENT_CONFIG=false, D-20). A change made on an admin panel
settings page lasts only until the next restart. The compose file and .env
are therefore the configuration another organization reproduces. Users, chats,
documents, Knowledge and model on/off switches are database records, and they
persist.
Source: docs/ARCHITECTURE.md in the CapstoneLocalAI repository (local working copy). Built Dec 3, 2026.