In short

  • LeanFlow is our reference architecture for giving AI agents governed access to company data when the team is small and the budget is smaller.
  • Every layer is open source: Apache Iceberg and Polaris for the lake, Ranger for policies, Gravitino and Jena for context, MetricFlow for metrics, Doris for queries and APISIX for model routing.
  • On three Hetzner servers it runs for about $86 a month. The same stack on AWS EC2 costs $522 to $659, and the managed-service version about $1,344 before anyone runs a query.
  • The trade is that you own patching, backups and uptime. We say where that stops being worth it.

This case study works through LeanFlow for a typical seed-stage AI company: two to five engineers, one product database, a handful of SaaS tools, and agents that need to answer questions about customers and revenue without seeing data they should not. The architecture and the prices are real. The company is a composite, so none of this is a client's data or a client's bill.

The problem: paying for scale you do not have yet

When a small team decides its agents need proper data access, the usual move is to assemble managed services: a Kubernetes control plane, managed Airflow, a managed graph database for the ontology, a catalog, a warehouse. Each one is reasonable. Together they bill around the clock, whether or not an agent asks anything.

On AWS, three of those services alone cost about $685 a month while idle: the EKS control plane at $73, the smallest MWAA environment at $358 and the smallest provisioned Neptune instance at $254. That is before compute, storage, NAT gateway charges or a single query.

The engineering cost is larger than the bill. Every managed service adds its own permissions model, its own way of failing and its own upgrade calendar. A three-person team ends up running the platform instead of the product.

The architecture, one question at a time

Scroll sideways to see the whole diagram.

1 Agent query · step 1 of 8 The agent signs in to Keycloak. Every call after this runs under the agent's own identity, not a shared service account.
The question being played: “What was churn last month for fleet customers in Germany?” Illustration, not client data.Download the editable draw.io file

What each layer does

LayerComponentIts job for the agent
LakeApache Iceberg on S3-compatible storageTables an agent can read with consistent snapshots, cheap enough to keep years of history
CatalogApache PolarisOne list of tables for every engine. It hands out storage keys that expire in minutes, so no agent holds a permanent one
PoliciesApache RangerColumn masks, row filters and an audit trail, written once. Polaris 1.5 can use Ranger as its authorizer (beta) and Doris enforces the same policies at query time
IdentityKeycloakApache-2.0 licence, not an Apache Software Foundation projectEach person and each agent gets its own login, so the audit trail names who asked
MetadataApache GravitinoFederates metadata across Iceberg, Postgres and Kafka, and ships an MCP server so agents can ask what exists and who owns it
Semantic layerMetricFlowApache-2.0 since October 2025, maintained by dbt LabsAgents ask for churn_rate by name and get approved SQL, instead of guessing joins
OntologyApache Jena FusekiThe business vocabulary: what a fleet customer is, and how it relates to orders and vehicles
QueryApache DorisRuns each query as the caller, reads Iceberg through Polaris and applies Ranger's masks and filters
IngestionApache SeaTunnel, Apache AirflowBrings in product data, SaaS data and files, then keeps tables compact
Model routingApache APISIXOne gateway for every model call: picks the cheapest tier that can do the job, falls back on errors and caps tokens per agent

The two semantic and ontology MCP servers are thin wrappers we write for each client, around 200 lines each. Gravitino's MCP server comes with the project.

Model routing does more for the bill than the servers

Most agent calls are small: classify this message, pull a field out of a document, decide which tool to call, look up a metric. A small model handles those well at a fraction of the price. APISIX's ai-proxy-multi plugin sends each route to the cheapest tier first and moves up only on failure, and ai-rate-limiting stops one runaway agent from spending the month's budget in an afternoon.

Small model: 70% of calls, 19% of spendLarge model: 30% of calls, 81% of spend
63%lower token bill than sending every call to the large model
$370for every $1,000 you would have spent on the large model alone

Arithmetic only: blended cost = share × (1 ÷ ratio) + (1 − share). Your real split depends on how your agents are built.

What it costs to run

Monthly run cost, same capabilities, 1 TB in the lake

LeanFlow on Hetzner3 shared-vCPU servers, 28 vCPU
$86 / mo
Same stack on AWS EC21-year savings plan, 14 vCPU
$522 / mo
Same stack on AWS EC2on demand, 14 vCPU
$659 / mo
AWS managed servicesadds EKS, MWAA and Neptune
$1,344 / mo

Public list prices checked in November 2026, before tax. €1 ≈ $1.18. RAM-matched where possible; the Hetzner servers have more vCPU because their shared plans come that way. Not a client bill.

Line itemLeanFlow on HetznerSame stack on AWS
Edge serverCX33, 4 vCPU, 8 GB: €8.49m7i.large, 2 vCPU, 8 GB: $73.58
Control serverCX43, 8 vCPU, 16 GB: €15.99m7i.xlarge, 4 vCPU, 16 GB: $147.17
Query serverCX53, 16 vCPU, 32 GB: €29.49m7i.2xlarge, 8 vCPU, 32 GB: $294.34
Object storage, 1 TB€6.49, includes 1 TB of egressS3 Standard: $23.55
Disks and backupsBackups at 20% of server price: €10.79300 GB gp3 and snapshots: $39
NetworkThree IPv4 addresses: €1.50; 20 TB traffic included per serverNAT gateway with 200 GB processed: $41.85; one IPv4: $3.65; 500 GB egress: $36
Total per month€72.75 ≈ $86$659 on demand, $522 on a 1-year plan

Over a year that is about $1,030 against $6,270 to $7,910 on EC2, or about $16,100 for the managed-service version. For a seed-stage company, the difference is a few months of runway or a contractor.

What we left out on purpose

  • Apache AtlasGood lineage, but it brings HBase, Solr and Kafka with it. Gravitino covers what an agent needs.
  • Apache OzoneRunning your own object store is a job. Rented S3-compatible storage costs €6.49 for the first terabyte.
  • A Kafka clusterAdd it when you have real event streams. Batch and change capture cover most seed-stage data.
  • KubernetesThree servers do not need a scheduler. One Compose file per server is easier to read at 2 a.m.
  • Ranger audit to SolrWrite audit records as JSON to the audit bucket and query them from Doris.

None of these are bad choices. They are choices for a larger team. Leaving them out is what keeps LeanFlow small enough for two engineers to understand completely.

The trade-offs

  • You run it. Patching, backups and restores are yours. Budget about a day a month.
  • One server per role means no high availability. That is fine for internal agents and analysts. It is not fine if you promise customers an uptime figure.
  • Cheap providers raised prices in 2026. Memory costs pushed Hetzner's dedicated-vCPU servers to more than double in June, and EU stock runs short at times. LeanFlow uses the shared CX line, which rose about a third. Check prices and stock before you plan.
  • Some enterprise buyers will ask for a hyperscaler. Because the lake is Iceberg behind a standard REST catalog, moving to AWS later is a migration, not a rewrite.

When to move on from LeanFlow

Treat these as the signals to grow the platform, not as failures of it: more than about 5 TB of data queried every day, a signed uptime commitment to a customer, or a third data engineer who would rather run a managed service than a Compose file. At that point you keep the same open formats and catalog, and swap individual servers for managed equivalents one at a time.