2-Tier Architecture

Deterministic data.
LLM reasoning. Never mixed up.

Data lookup goes through traditional, 100% reliable database queries — SQL, JSONB, NoSQL, or a Rule Engine. The LLM only ever reasons over that verified data. No hallucinated facts, no vector database required.

app.totalapp.app/ai/two-tier
Facts from Data. Reasoning from AI.
TotalApp
AskSourcesRulesAudit
Overdue invoices assistant0 unverified claims
Which overdue invoices over $5,000 belong to EU customers?
Tier 1 · Deterministic lookupSQL
SELECT id, customer, amount, days_late FROM invoices WHERE status = 'overdue' AND amount > 5000 AND region = 'EU'
IDCustomerAmountLate
INV-7781Orion Labs$9,80014 d
INV-7774Northwind GmbH$24,5909 d
INV-7790Bright SAS$6,12021 d
3 rows · 12 ms · no model involved
Verified data only
Tier 2 · LLM reasoningLlama 3 · local
Three EU invoices are overdue by more than $5,000, totalling $40,510.
The largest is Northwind GmbH at $24,590 [INV-7774], nine days late.
Bright SAS is the most delayed at 21 days [INV-7790] — I suggest escalating it first.
Every number traced to a rowNo facts from model memoryNo vector database used
Grounded in 3 records · 1.4 s
Data sources
PostgreSQLSQL
JSONB documentsJSONB
NoSQL storeNoSQL
Rule EngineRules
Audit trail
Question received09:14:02
Tier 1 query executed09:14:02
3 records returned09:14:02
Tier 2 answer generated09:14:04
No vector DB needed
Retrieval is exact, not approximate — so answers never drift from your data.
Answer verified3 of 3 claims linked to records
How It Works

Two tiers, one clean
separation of concerns

Data lookup and reasoning are two different jobs. TotalApp never lets an LLM do both at once — Tier 1 finds the exact data, Tier 2 reasons over what Tier 1 already verified.

  • ✓
    Tier 1 — filters records by exact match using SQL, PostgreSQL JSONB, NoSQL, or a Rule Engine
  • ✓
    Tier 2 — the exact JSON from Tier 1 is passed to the LLM as context
  • ✓
    The LLM interprets, audits (like a linter), or decides — never invents facts
  • ✓
    Zero chance of wrong data retrieval — nothing is fetched by approximation
Read the guide
Tier 1 · DeterministicExact match only
SQL filter
Exact JSON
LLM
Reply
invoices WHERE status = overdue3 exact rows
Verified JSON passed as contextTier 2
Invoice #4021 late fee off by $12Recalculated
Why it is reliable
Facts come fromTier 1
LLM roleReason only
Vector searchNot involved
No approximationNothing is fetched by similarity.
Where It Applies

Structured data, not
free-text search

This architecture is built for data with a defined schema and clear rules — an invoice, a tax calculation, a permission check. For unstructured documents and open-ended text, Semantic Search is the right tool instead.

  • ✓
    Best fit: ERP/CRM modules, invoice & tax calculations, RBAC permission checks
  • ✓
    Not a fit alone: free-text search over documents with no fixed schema
  • ✓
    Vector search isn't required for Tier 2 — structured JSON goes straight to the LLM as context
  • ✓
    Combine with Semantic Search when a workflow needs both an exact check and similarity search
See Semantic Search
2-Tier vs. Semantic SearchPick by question
Question2-TierSemantic
"Show overdue invoices"Exact match---
"Find contracts like this one"---Similarity
Invoice and tax figuresExact match---
Best fit
ERP / CRM modulesStructured records
2-Tier
Invoice and tax calculationsExact figures
2-Tier
Free-text document searchNo fixed schema
Semantic
Combine when needed
Exact control plus similarity
A workflow can use both
Pick by the shape of the question
Same platformDifferent tool for the job.
Works Without a Local Model

No local model or GPU?
The screen still works

If a user's machine has no local model (Ollama or similar) and no GPU available, no screen locks up, crashes, or becomes unusable. Three architectural guarantees make that true.

  • ✓
    Graceful fallback — no local model found means an automatic switch to keyword search, never a stopped system
  • ✓
    Core operations are AI-independent — listing, filtering, forms, and saving are standard CRUD
  • ✓
    The AI layer is flexible — falls back to a cloud service, or the screen just runs without the AI buttons
Read the guide
No local model detectedFallback active
Fully available1
CORETable, forms and CRUDAI-independent
Rerouted1
AIDiagnostic buttonsRouted to a cloud service
Hidden1
AIAI buttonsNo cloud service either
Fallback order
Local modelUsed when detected
1st
Cloud serviceIf no local model
2nd
No AIScreen stays usable
3rd
Core operations
Listing, filtering, forms
Never depend on a model being present
Hide AI buttons when nothing is available
Graceful fallbackThe core screen keeps working.
Why It Matters

A hybrid approach built for reliability

Traditional queries own the facts. The LLM owns the reasoning. Neither one does the other's job.

Zero Wrong-Data Risk

Tier 1 uses exact-match queries against your real schema — there is no approximate or "close enough" result to get wrong.

Hallucination Blocked at the Data Level

The LLM only ever reasons over data already verified correct by Tier 1 — it cannot introduce facts that aren't there.

No Vector Database Complexity

No embedding pipeline, similarity index, or vector store to build, tune, or keep in sync for this class of query.

SQL, JSONB, NoSQL, or Rule Engine

Tier 1 works with whichever deterministic store fits the data — no lock-in to a single database technology.

Reasoning, Review, or Decisioning

Tier 2 can interpret data in plain language, audit it like a linter, or support a decision — always from verified facts.

Built for ERP/CRM Workflows

Invoice and tax calculations, RBAC permission checks — any operational workflow with a fixed schema and firm rules.

Complements Semantic Search

Use this architecture for structured records, Semantic Search for free-text discovery — combine both in one workflow.

No Local Model? No Problem

Core CRUD operations never depend on AI. Missing a local model just routes Tier 2 to a cloud service, or disables only the AI buttons.