Pinter
ENID
Architecture
View as Markdown

Frontend architecture

Review the Pinter frontend route tree, feature modules, and shared interfaces.

The frontend uses React, TanStack Router, TanStack Query, Zustand, shadcn/ui, and Rsbuild.

Route tree

Routes live in pinter-fe/src/routes.

Route areaFilesPurpose
App shell_app.tsx, __root.tsxProviders, app layout, protected shell.
Auth_auth/login.tsx, _auth/register.tsx, _auth/mfa.tsxSign in, registration, MFA.
Chat_app/chat/*, _app/embedded/*Conversations and embedded chat.
Builder_app/builder/*Agent builder index and agent detail canvas.
Workspace_app/tools, _app/documents, _app/integrations, _app/mcp-servers, _app/evaluations, _app/marketplace, _app/api-studioAgent support workflows.
Admin_app/admin/*Users, models, quotas, usage, applications, approvals.

The app sidebar is the main navigation interface:

pinter-fe/src/shared/components/app-sidebar.tsx

It exposes:

  • New chat.
  • Claim code redemption.
  • My usage.
  • Workspace items filtered by role level.
  • Conversation history.
  • User menu.

Data access seam

Frontend API access goes through one seam:

pinter-fe/src/shared/auth/authenticated.ts

Use these exported functions instead of calling fetch directly:

ExportUse for
api.get, api.post, api.put, api.deleteJSON API calls.
streamAuthenticated SSE chat runs.
uploadMultipart file uploads.
fetchObjectUrlAuthenticated private attachments.
AuthErrorUser-facing API errors.

This module handles token refresh, 401 retry, logout on terminal auth failure, JSON errors, uploads, and streaming.

Conversation streaming

useAgentStream sends POST /api/conversations/{conversationId}/send through stream() with stream: true:

{
  "message": "Ringkas risiko bulan ini",
  "agent_id": "<agent_id>",
  "attachments": [],
  "stream": true
}

The backend defaults stream to false; the frontend opts in so it can consume SSE chunks with ReadableStream.getReader(). thinking events update the trace panel; text events update the answer bubble.

The frontend also sends X-Pinter-Response-Format: blocks,openui. It renders block events for complete one-line JSON blocks: html, flint_chart, image, and followup. Ordinary prose remains delta text. Do not split block JSON across SSE chunks or lines. The openui token lets the model emit openui-lang fences as plain text inside delta; message-content.tsx swaps the fence for an OpenUIBlock renderer, and clients that do not render it should strip the fence.

Domain packages

The canonical API is split into eight domains: identity, agents, conversations, knowledge, integrations, evaluations, governance, and content. Frontend domain code lives under src/apps; knowledge screens currently remain route-owned.

A domain may import its own internals. Any other consumer must import from @/apps/<domain>, never @/apps/<domain>/...; ESLint enforces this boundary.

DomainPublic API prefix
Identity/api/identity
Agents/api/agents
Conversations/api/conversations
Knowledge/api/knowledge
Integrations/api/integrations
Evaluations/api/evaluations
Governance/api/governance
Content/api/content

State modules

StatePathPurpose
Authsrc/shared/stores/auth-store.tsJWT, refresh token, current user, persistence.
Query cachesrc/shared/lib/query-client.tsServer state cache.
Buildersrc/apps/agentsAgent canvas and workflow editing.
Chatsrc/apps/conversationsConversation list, messages, streaming feed.

Role-aware UI

Workspace navigation uses role_level:

Role levelMeaning in UI
1Super Admin.
2Admin-level access.
3Builder/workspace access.
4Regular user.

Route guards live in:

pinter-fe/src/shared/auth/route-guards.ts