Introducing a new way to review your PRs.

Read the announcement

keephq / keep

The open-source AIOps and alert management platform

View on GitHub

22 documents · Updated Nov 23, 2026

docs / web-application

Web application

The web application is Keep's Next.js product surface. It turns authenticated browser activity into alert, incident, provider, dashboard, and workflow experiences while keeping access control, shared UI behavior, client state, and telemetry aligned across the product.

Application surface

Product routes

The application uses Next.js App Router route segments to map product areas to URLs. The (keep) route group holds the authenticated product shell. The (signin) group provides the separate sign-in and error surface. Group names do not appear in URLs.

Pages can load key data on the server before they hand interactive work to client components. The main product areas include:

  • Incidents and alerts for reviewing operational events.
  • Providers and settings for connecting sources and managing the product.
  • Workflows for viewing, testing, and editing automation.
  • Extraction and mapping rule executions for reviewing enrichment runs, logs, fields, and linked alerts.
  • Topology, dashboards, and noise-reduction views.

For alert review and response, see Alert operations UI. For workflow creation and editing, see Workflow authoring UI.

The application also exposes route handlers for health checks, authentication, marketplace callbacks, CopilotKit, and raw workflow downloads. Domain data still crosses the shared API boundary rather than becoming local page data.

References: keep-ui/next.config.js• L115-132 keep-ui/…/page.tsx• L1-8 keep-ui/…/page.tsx• L6-27 keep-ui/…/page.tsx• L10-20 keep-ui/…/page.tsx• L7-29 keep-ui/…/page.tsx• L13-37 keep-ui/…/page.tsx• L13-37 keep-ui/…/route.ts• L1-20 keep-ui/…/route.ts• L3-18

Product shell

The authenticated shell gives product routes one common frame. It supplies navigation, configuration, session, theme, toast, topology polling, workflow modal, and page-view tracking context.

Navigation groups links by operational task. It supports desktop and mobile use. A read-only banner and build marker make deployment state visible without changing the route structure. Incidents and providers add narrower layouts for their own filters and controls.

References: keep-ui/…/layout.tsx• L28-69 keep-ui/…/Navbar.tsx• L13-31 keep-ui/…/Menu.tsx• L31-85 keep-ui/…/layout.tsx• L1-8 keep-ui/…/layout.tsx• L9-33

Request boundary

API access

The API boundary gives server and browser code one way to call the Keep backend. ApiClient selects a server or browser API address. It adds the current bearer token and turns failed responses into typed errors.

The boundary also carries product-wide request rules. Read-only mode blocks write methods before they leave the browser or server client. A 401 response starts the matching sign-out path in the browser. A read-only response becomes a distinct error so the UI can explain why an action did not run.

The request path has two forms. Server code builds a client from the NextAuth session and server configuration. Browser code builds one from the hydrated session and configuration context. A relative browser address can use /backend; middleware rewrites legacy /backend/* requests when needed. Vercel preview branches can instead derive a browser API address when no client address is set.

This diagram shows how a route turns session and configuration into an authenticated backend request.

flowchart LR
    R[Product route] --> S{Execution side}
    S -->|Server| SC[Server API client]
    S -->|Browser| BC[useApi client]
    SC --> C[Shared API client]
    BC --> C
    C --> G[Read-only and error rules]
    G --> B[Keep backend]

References: keep-ui/…/ApiClient.ts• L25-55 keep-ui/…/ApiClient.ts• L72-173 keep-ui/…/createServerApiClient.ts• L38-80 keep-ui/…/useApi.tsx• L7-18 keep-ui/middleware.ts• L34-43 keep-ui/…/getApiUrlFromConfig.ts• L13-15 keep-ui/…/getConfig.ts• L28-35

API-backed page data

Server pages use the same boundary to provide initial data for interactive views. This keeps the first page render close to the live client view. Alert, incident, and workflow pages load initial data on the server. Workflow detail pages can also load raw workflow text before the builder starts.

Client execution detail pages use the same boundary through enrichment-event data. They show execution status and logs, expose extracted or enriched fields, and link the stored alert identifier back to the alert feed. The link accepts both current and older identifier forms so older executions remain useful.

The client then owns interaction and refresh. Shared API types describe the records that cross this boundary, including workflows, providers, and workflow executions.

References: keep-ui/…/page.tsx• L6-25 keep-ui/…/page.tsx• L10-15 keep-ui/…/page.tsx• L9-26 keep-ui/…/page.tsx• L17-36 keep-ui/…/page.tsx• L17-36 keep-ui/…/workflows.ts• L53-74 keep-ui/…/providers.ts• L55-60 keep-ui/…/workflow-executions.ts• L9-35

Authentication

Session lifecycle

NextAuth is the application identity layer. It supports local credentials, no-auth mode, OAuth2 Proxy, and external identity providers. The selected mode creates a JWT-backed session with the backend access token, active tenant, available tenants, and user role.

Providers that issue refresh tokens can renew an expired access token before later API calls use it. The server reads the session during route protection and server data loading. The authenticated layout passes the session into the browser provider, which avoids a blank session during hydration.

Client hooks use the hydrated session to create API clients and react to expired credentials. This gives pages the same session shape regardless of which identity provider produced it.

References: keep-ui/auth.config.ts• L125-289 keep-ui/auth.config.ts• L297-320 keep-ui/auth.config.ts• L320-500 keep-ui/…/auth-provider.tsx• L1-24 keep-ui/…/useHydratedSession.tsx• L15-36 keep-ui/…/route.ts• L1-23

Access control

Middleware makes the first access decision before most application paths run. It redirects unauthenticated users to sign-in with a callback URL. It sends authenticated users away from sign-in. It gives NOC users an alerts-only entry path.

Public exceptions include sign-in, error, mobile, health, authentication, marketplace, static, and other explicitly excluded routes. The backend remains the final authority for API permissions. The frontend passes session and tenant context so backend responses can enforce access.

Tenant switching changes the active tenant carried by the session. Later API calls then use the selected tenant context.

References: keep-ui/middleware.ts• L15-91 keep-ui/middleware.ts• L93-115 keep-ui/auth.ts• L10-80 keep-ui/auth.config.ts• L484-497 keep-ui/…/ApiClient.ts• L42-55

Authentication variants

Authentication mode changes how identity reaches the application. It does not change the page-level API contract. The server configuration also accepts older mode names and uses no-auth mode when the value is missing or unknown.

ModeIdentity source
CredentialBackend validation
External providerIdentity service
No-authControlled guest identity
OAuth2 ProxyTrusted request headers

Keycloak can also supply user organizations when multi-organization mode is enabled. In single-tenant mode, sign-in requires a recognized Keep role from the user profile or access token. A user without one is rejected before a session is created and sees a clear authentication error. Generic OIDC maps group claims to UI roles through the configured role groups. Empty configured group entries do not match empty claim values. Server API clients preserve OAuth2 Proxy identity headers when they call the backend. Pages and hooks use the common access token, tenant, role, and tenant list fields.

References: keep-ui/auth.config.ts• L54-82 keep-ui/auth.config.ts• L432-455 keep-ui/auth.config.ts• L488-562 keep-ui/auth.config.ts• L320-482 keep-ui/…/keycloakRole.ts• L4-24 keep-ui/errors.ts• L11-20 keep-ui/…/error-client.tsx• L24-40 keep-ui/…/oauth2proxy-auth.ts• L27-53 keep-ui/…/createServerApiClient.ts• L7-80 keep-ui/…/auth.d.ts• L1-55 keep-ui/…/getConfig.ts• L10-25

Shared UI architecture

Shared controls

Shared UI components provide the visual and interaction language for product features. They cover forms, tables, navigation, severity labels, empty states, loaders, dialogs, editors, themes, and user feedback.

Feature areas compose these controls with domain data. This keeps alert tables, workflow editors, provider screens, and incident views aligned. Errors, toasts, and theme changes also keep one user-facing shape.

References: keep-ui/…/index.ts• L1-32 keep-ui/…/index.ts• L1-28 keep-ui/…/ErrorComponent.tsx• L18-107

Feature composition

Route pages act as composition points. A page or layout joins domain features with shared controls. Feature components own a product capability. Widgets provide larger interactive surfaces. Entities describe domain models and state. Shared code provides API clients, hooks, UI controls, and cross-cutting utilities.

The alert table joins server data with facets, presets, selection actions, and an alert sidebar. Its menu actions can open note, ticket, dismissal, status, and workflow-run flows. The workflow builder joins graph and YAML views with validation and save controls.

The alert table keeps menu cell identity stable across data refreshes. This preserves an open menu when polling rebuilds the table. The workflow run modal keeps its select components stable for the same reason. A refresh must update current actions without remounting these controls.

References: keep-ui/…/alert-table-server-side.tsx• L120-138 keep-ui/…/alert-table-server-side.tsx• L666-787 keep-ui/…/alert-table-utils.tsx• L243-283 keep-ui/…/manual-run-workflow-modal.tsx• L38-85 keep-ui/…/alert-preset-manager.tsx• L65-93 keep-ui/…/workflow-builder-widget.tsx• L23-43

Workflow authoring surface

Workflow authoring supports two linked views of one workflow. The visual builder helps users arrange triggers and steps. The YAML editor gives direct text control. Both update the workflow definition used for validation and save.

The workflow surface also supports an optional assistant and test-run actions. Existing workflows load their raw definition through the server boundary. New workflows start from an empty definition or imported YAML. Save remains available only when the definition is synchronized and deployable.

For the focused authoring model and route behavior, see Workflow authoring UI.

References: keep-ui/…/page.tsx• L9-17 keep-ui/…/page.tsx• L9-26 keep-ui/…/workflow-builder.tsx• L92-169 keep-ui/…/workflow-builder.tsx• L172-229 keep-ui/…/workflow-builder-widget.tsx• L88-163

Manual workflow runs

The manual run surface lets a user choose an allowed workflow or run a workflow already supplied by its caller. It reads the workflow definition to show input fields. Defaults fill the form. Required inputs gate the Run action.

The surface serves alert and incident context. It can send the run through a caller callback or the shared API boundary. A successful direct run closes the modal and links to the workflow execution. Polling and revalidation can update the parent view without closing the open workflow selector.

References: keep-ui/…/manual-run-workflow-modal.tsx• L87-224 keep-ui/…/manual-run-workflow-modal.tsx• L226-327 keep-ui/…/manual-run-workflow-modal.test.tsx• L33-58

Client state

Local interaction state

The browser keeps short-lived interaction state close to the surface that uses it. React state covers open panels, selected rows, pagination, sorting, and other view choices. Local storage preserves preferences such as menu size, table sizing, viewed alerts, and theme choice across sessions.

URL search parameters carry state that should be shareable or restorable, such as alert filters and time frames. This lets the UI stay responsive without turning every click into a backend write.

References: keep-ui/…/Menu.tsx• L31-45 keep-ui/…/alert-table-server-side.tsx• L139-212 keep-ui/…/alert-table-server-side.tsx• L214-239 keep-ui/…/ThemeScript.tsx• L5-29

Scoped stores

Zustand stores hold state that spans many components in one interactive feature. The workflow store is the central state for the graph, YAML-derived definition, selected editor item, providers, secrets, validation, and save status. The facet store is created per provider so filters stay scoped to their owning page.

These stores connect interaction to product rules. Workflow changes rebuild and validate a definition before save. Facet changes update query state and refresh the matching data view. The workflow builder resets its store when it unmounts. A facet provider owns the lifetime of its scoped store.

References: keep-ui/…/workflow-store.ts• L282-308 keep-ui/…/workflow-store.ts• L435-531 keep-ui/…/workflow-store.ts• L769-790 keep-ui/…/workflow-builder.tsx• L231-236 keep-ui/…/use-store.tsx• L15-58 keep-ui/…/create-facets-store.ts• L67-110

Live updates

Some views react to backend events instead of waiting for a full page reload. The websocket hook creates a tenant-scoped private channel when enabled and authorizes it through the API boundary. Alert polling listens for poll-alerts events and returns fingerprints that the alert view can use to refresh or focus affected rows.

This path is optional. Configuration can disable it. Ordinary API reads remain the source for displayed data.

References: keep-ui/…/usePusher.ts• L8-60 keep-ui/…/usePusher.ts• L102-153 keep-ui/…/useAlertPolling.ts• L43-65 keep-ui/…/internal-config.ts• L3-8

Observability

Error reporting

Sentry covers browser, server, and edge execution. It links failures to the part of the Next.js request that produced them. Instrumentation skips setup in development or when disabled.

The root error boundary works without session, configuration, or API providers because it can replace the root layout. It records the exception, shows the error message and optional reference, and offers a retry action. Authenticated sessions add user and tenant context to Sentry when reporting is enabled.

Production build settings also control browser source maps. An explicit source-inclusion setting keeps them. The default production path blocks .map requests and removes uploaded maps after Sentry receives them.

References: keep-ui/instrumentation.ts• L1-22 keep-ui/sentry.client.config.ts• L5-15 keep-ui/sentry.server.config.ts• L5-15 keep-ui/sentry.edge.config.ts• L6-16 keep-ui/next.config.js• L111-120 keep-ui/next.config.js• L153-170 keep-ui/next.config.js• L177-220 keep-ui/…/useSetSentryUser.ts• L16-36 keep-ui/…/ApiClient.ts• L121-131 keep-ui/…/global-error.tsx• L6-30

Product analytics

PostHog records page views and identifies known users when configured. The page-view tracker follows pathname and search-parameter changes. User identification adds product context such as AI availability. A no-auth placeholder identity is not sent as a real user.

Analytics sits in the authenticated shell. Route changes across product areas therefore use one provider and one tracking policy. Configuration can disable the integration without changing page behavior.

References: keep-ui/…/posthog-provider.tsx• L8-22 keep-ui/…/PostHogPageView.tsx• L11-54 keep-ui/…/layout.tsx• L37-44 keep-ui/…/internal-config.ts• L9-19

Change checklist

When these files or sections are changed, remember to consider these:

  • When route shell or middleware rules change, check public exceptions, sign-in callback URLs, role redirects, and API route access together.
  • When session fields or auth providers change, check JWT callbacks, browser hydration, server API clients, tenant switching, bearer-token requests, and token refresh together.
  • When tenant claims change, check the active tenant, tenant list, tenant-switch flow, and backend request context together.
  • When OIDC role mapping changes, check empty role lists, UI gating, and the backend role mapping together.
  • When Keycloak role claims or accepted client roles change, check sign-in rejection, authentication error messaging, backend role names, and multi-organization group mode together.
  • When execution identifiers change, check alert links from both extraction and mapping detail pages against current and older alert identifier forms.
  • When API URL or read-only rules change, check server and browser base URLs, Vercel preview defaults, plus the legacy /backend rewrite path.
  • When shared UI exports or control identity changes, check feature imports and whether polling can remount open menus or selectors.
  • When alert table columns change, check preset-scoped display settings, row expansion, menu actions, and the stable menu cell contract.
  • When manual workflow-run inputs change, check YAML parsing, default values, required-input gating, callback runs, and direct alert or incident API runs.
  • When workflow definition state changes, check synchronization, validation, YAML conversion, save gating, and store reset behavior together.
  • When analytics or error reporting settings change, check client, server, edge, source-map, and user-identification paths independently.
  • When Next.js, image processing, or browser support packages change, check the Node runtime, platform-specific build dependencies, and production build behavior together.

Important failure modes

TriggerConsequenceGuard
Browser code has no client API URL and the /backend rewrite is unavailableAPI calls target an unusable relative pathKeep API_URL_CLIENT aligned with ingress. For Vercel previews, preserve the fallback to the derived API URL.
A session access token expires during an API requestThe user receives a 401 and the browser signs out or redirects through OAuth2 ProxyKeep session refresh and ApiClient 401 handling aligned with the auth mode
A write runs while read-only mode is activeThe request is blocked and the UI shows a read-only errorEnforce READ_ONLY at the request boundary rather than only in buttons
Active tenant and tenant list claims disagreeThe user sees one tenant while requests use another contextKeep JWT, session, tenant-switch, and API header mappings consistent
A Keycloak user has no recognized Keep role in single-tenant modeSign-in is denied before session creation and the user sees an authentication error instead of a redirect loopKeep accepted role names, Keycloak claims, backend role names, and the AccessDenied message aligned
An OIDC role list is unset but an incoming group claim contains an empty valueThe UI can assign a privileged role from an empty group matchFilter empty configured role groups before matching claims, and keep UI mapping aligned with backend mapping
A polling refresh remounts an open menu or workflow selectorThe control closes and loses its local interaction stateKeep render component identity stable and read current callbacks through refs
An execution stores an older alert identifier formThe detail page opens an empty alert filterKeep both dashed and undashed identifier forms in the extraction and mapping alert links
A workflow has required inputs that are not filledRun stays blocked or sends an incomplete requestDerive inputs from the workflow definition and keep required-input checks aligned with the Run action
Workflow graph and definition state are out of syncSave is refused or a stale definition is sent for deploymentPreserve the builder requirement that state is synchronized and deployable before save
A high-cardinality facet loads all options at page startThe filter view can freeze or become slowKeep lazy facet activation scoped to expanded or selected facets
Production source maps are exposed when source inclusion is not intendedBrowser source details remain available from deployed assetsAlign source-map inclusion, Sentry upload cleanup, and production .map blocking
Sentry or PostHog lacks required runtime configurationEvents or errors are lost, or development produces unwanted eventsGate each integration with its disabled flag and required key
An unknown authentication mode reaches server configurationThe application uses an unintended identity pathKeep legacy aliases and the no-auth default aligned with supported auth modes
The UI build runs with an unsupported Node runtime or native image packageDependency install or the Next.js build fails before the application startsKeep the runtime and platform-specific sharp packages aligned with the locked UI dependencies

Key files

FileWhy to read it
keep-ui/…/layout.tsxShows the authenticated product shell and shared provider order.
keep-ui/middleware.tsDefines the first routing, auth, role, mobile, and backend-rewrite decisions.
keep-ui/auth.config.tsDescribes identity modes, Keycloak role validation, OIDC group-to-role mapping, token refresh, organization discovery, and common session fields.
keep-ui/…/keycloakRole.tsDefines the accepted Keycloak role sources used before single-tenant sign-in.
keep-ui/…/error-client.tsxShows the user-facing authentication errors, including the missing-Keycloak-role case.
keep-ui/…/getConfig.tsDefines server configuration normalization and the browser API URL selected for each deployment context.
keep-ui/…/ApiClient.tsDefines the browser/server API boundary, auth headers, read-only policy, and API errors.
keep-ui/…/createServerApiClient.tsShows how server routes carry sessions and proxy identity to the backend.
keep-ui/…/index.tsShows the shared UI surface used by product features.
keep-ui/…/alert-table-server-side.tsxIllustrates the interactive alert view, filters, table state, and detail actions.
keep-ui/…/alert-table-utils.tsxShows alert column behavior and how menu state survives table refresh.
keep-ui/…/page.tsxShows how extraction execution status, logs, fields, and linked alerts reach the product surface.
keep-ui/…/page.tsxShows the matching mapping execution detail flow and its alert link contract.
keep-ui/…/manual-run-workflow-modal.tsxShows how alert and incident context starts a workflow with validated inputs.
keep-ui/…/workflow-builder.tsxIllustrates workflow authoring from definition loading through validation and save.
keep-ui/…/workflow-store.tsDefines shared workflow editor state and its validity model.
keep-ui/next.config.jsDefines production redirects, source-map handling, runtime flags, and Sentry build integration.
keep-ui/…/global-error.tsxShows the provider-independent root error fallback and retry path.
keep-ui/instrumentation.tsShows how Sentry is enabled across Next.js runtimes.
keep-ui/…/PostHogPageView.tsxShows the page-view and user-identification analytics contract.
keep-ui/package.jsonDefines the Next.js runtime, build commands, and core UI package ranges.
keep-ui/package-lock.jsonLocks the UI runtime and platform-specific build dependency versions.