AI-COMPETE & SMART platform · system design

One Platform, Many Partners, and No Way to See Each Other’s Data

The AI tools on this site (plant knowledge assistant, robot-cell copilot, data analyst agent, planning copilot and maintenance language model) only matter if people at the partner companies can sign in and use them. This is the multi-tenant GenAI platform that hosts them. It gives each partner an isolated workspace with its own sign-in, streaming chat and tools, API keys for its own systems, and a usage meter that shows exactly what each partner consumed. The partners include competitors, so isolation between tenants is the first requirement, not a feature.

ContextUniversity of Skövde · AI-COMPETE (Vinnova) & SMART (KK-stiftelsen) · 2026 · system design
Analytics stages
QualitativeDescriptiveDiagnosticPredictivePrescriptiveSoftware
Technology
Next.js (App Router, SSR)React + TypeScriptServer-sent eventsFastAPIPostgreSQL (row-level security) + pgvectorRedisAzure API ManagementMicrosoft Entra ID (OIDC)Azure OpenAIAzure Container AppsOpenTelemetryPlaywright
ResultSystem design — product scope, tenancy model, gateway, metering and hosting. No usage figures are claimed yet.
What this page is. A system design for the platform layer of AI-COMPETE and SMART. It is not a report of a deployment at any partner. Figures marked target are release gates. They are not measured results.
Stakeholder engagement · product scope

A research prototype that partners can actually log into

Most programme software dies as a notebook on one researcher’s laptop.

Industry–academia programmes often end with working models that no partner employee ever used, because running them needed the researcher. The platform closes that gap. Engineers at each partner sign in with their own company account, use the AI tools in a browser, and connect their own systems through an API. The programme can also see who used what, so the partners’ in-kind hours and the cloud bill can be tied to actual use.

Sign-inSingle sign-on with each partner’s own Entra ID tenant, with no new passwords.
WorkspacesOne per partner, and optionally per plant, with its own documents, data connections and members.
Streaming chatToken-by-token answers, tool steps shown live, and sessions that persist across devices.
API keysWorkspace-scoped keys so a partner’s MES or BI tool can call the agents directly.
UsageTokens, tool calls and GPU seconds per workspace, user and tool, shown on a live dashboard.
Architecture

Every request crosses the same four checkpoints

Identity, gateway, tenant-scoped data and the metering ledger.
Two ways in, one gateway, tenant-scoped everything Browser · Next.jsSSR, SSE streaming Partner systemsMES / BI via API key API gatewayEntra ID / key auth,tiered rate limits OrchestratorFastAPI, sessions,context, streaming AI toolsRAG · copilots · data agent · fine-tuned model Model endpointsAzure OpenAI · vLLM (in-tenant) PostgreSQLrow-level security per tenant, pgvector Redisrate buckets, stream resume Metering ledgerappend-only usage events → dashboards, budgets The tenant ID comes from the verified token or key, never from the request body. The database enforces it again with row-level security.
The gateway decides who you are, the database decides what you can see, and the ledger records what you used.
Front end

Fast to first paint, and fast to first token

Next.js with server rendering for the frame and streaming for the answer.
Multi-tenancy · security

Isolation enforced in three layers, and tested on every deploy

If one layer has a bug, the next one still stops the leak.
LayerHow tenancy is enforced
IdentityA multi-tenant Entra ID app. The partner’s tenant ID in the signed token maps to a platform tenant, and there is no self-registration.
ApplicationEvery service call carries a tenant context taken from the verified identity. Queries without one fail closed.
DatabasePostgreSQL row-level security on every tenant table, including the pgvector embeddings, so a missing WHERE clause returns nothing rather than someone else’s rows.
Retrieval & cachesVector search, Redis keys and prompt caches are all namespaced by tenant, so a cached answer can never cross companies.
API keysShown once, then stored only as a hash. Each key has a visible prefix, workspace and scope limits, an expiry and one-click rotation, and every use is logged.

An automated isolation suite runs on every deploy. It creates two tenants, seeds each with marked data, then tries every endpoint, search and cache path from one tenant to read the other. Any hit blocks the release.

Gateway, rate limits & metering

Know who used what, and stop anyone using too much

Model calls are metered precisely, because shared cloud credit is shared money.

Rate limiting

  • Azure API Management handles authentication and coarse per-key limits at the edge.
  • Redis token buckets in FastAPI apply tiered limits per workspace and per user, counted in model tokens rather than requests, since one long analysis costs as much as a hundred short questions.
  • Limits return 429 with a Retry-After header and show in the UI as a friendly countdown, not an error.

Token metering

  • Before a call, a tokenizer-based estimate is checked against the workspace’s remaining budget.
  • After the call, the provider’s reported usage is authoritative. It is written as an idempotent, append-only ledger event: tenant, user, tool, model, tokens in and out, GPU seconds and cost.
  • An outbox pattern guarantees every completed call is metered exactly once, even if a worker crashes mid-stream.
  • The ledger is billing-ready. The same events could drive Stripe usage-based billing through a webhook if the platform is commercialised after the programme.
Context engineering across sessions

Long conversations, bounded context

A session can run for weeks. The prompt cannot grow with it.
Session storeEvery message, tool call and result is kept in PostgreSQL, so a session opens exactly where it was left, on any device.
Rolling summaryOlder turns are compressed into a summary. Facts the user confirmed and decisions they approved are pinned word for word.
Workspace memoryPlant names, line codes and preferred units are stored per workspace, so every new session starts already knowing them.
Prompt cachingStable system prompts and workspace context come first, so the provider’s prompt cache cuts cost and time to first token on repeat turns.
Hosting & release gates

Hosted where the partners’ data is allowed to be

Azure in Sweden Central, defined in Bicep and deployed by GitHub Actions.

Next.js and FastAPI run as containers on Azure Container Apps, next to managed PostgreSQL, Azure Cache for Redis and the API gateway, all in the Sweden Central region. Partners’ data stays in the EU, and they already trust Azure. A Vercel-style edge platform would be simpler to host, but it would put a third party between the partners and their data. OpenTelemetry traces follow one request from the browser to the model and back, with a tenant ID on every span.

MetricHow it is measuredRelease gate (target)
Cross-tenant readsIsolation suite on every deploy0 (hard gate)
Metering completenessLedger events compared with provider usage, reconciled daily100%
Time to first tokenp95, from send to first streamed token, chat without tools< 1.5 s
UI interaction latencyp95, from click to visual update, measured in the browser< 100 ms
Gateway overheadp95 added by authentication, rate limiting and metering< 30 ms

The tools it hosts: plant knowledge assistant · robot-cell copilot · data analyst agent · planning copilot · maintenance language model.