Skip to content

Architecture Overview

VaultLens is a unified full-stack application with a React SPA frontend served by an Express backend from the same Node.js process.

Stack

LayerTechnology
RuntimeNode.js 22
BackendExpress 4
FrontendReact 19 + Vite
LanguageTypeScript 5
StylingTailwindCSS 4
StateZustand + TanStack Query
Routingreact-router-dom 7
Graphs@xyflow/react
EncryptionOpenPGP.js

Request Flow

Browser

  ├─ GET /  → Vite-built React SPA (static from dist/client/)

  └─ /api/* → Express routes

               ├─ authMiddleware  (validates vault_token cookie via /auth/token/lookup-self)
               ├─ csrfMiddleware  (double-submit cookie)

               └─ Route handler

                    └─ vaultClient (proxies to Vault using req.vaultToken)

Authentication Model

VaultLens is a thin proxy — it does not maintain its own user database. Every authenticated request uses the logged-in user's Vault token to call Vault. Vault's own ACL engine controls what each user can see and do.

The only time a different token is used is for background services and restricted-access fallbacks, which use the system token.

Backend Route Modules

ModuleMountDescription
auth.ts/api/authLogin, logout, session, OIDC
secrets.ts/api/secretsKV CRUD, merge, restricted access
policies.ts/api/policiesACL policy list and read
authMethods.ts/api/auth-methodsAuth method config and roles
identity.ts/api/identityEntities and groups
graph.ts/api/graphReact Flow graph data
permissions.ts/api/permissionsPermission testing
audit.ts/api/auditAudit log and devices
sys.ts/api/sysHealth, seal status
rotation.ts/api/rotationSecret rotation config
backup.ts/api/backupBackup and restore
hooks.ts/api/hooksWebhook CRUD
branding.ts/api/brandingApp branding
sharing.ts/api/sharingEncrypted secret sharing

Middleware Stack

#MiddlewarePurpose
1Request IDUUID per request for log correlation
2Permissions-PolicyDenies all browser feature APIs
3HelmetCSP, HSTS, X-Frame-Options
4CORSOnly active when CORS_ORIGIN is set
5MorganHTTP request logging
6Cookie Parservault_token and csrf_token cookies
7JSON Body1 MB limit
8Rate LimiterGlobal on /api/*
9HPPHTTP parameter pollution protection
10Health CheckGET /api/health (always public)
11Auth RoutesMounted before CSRF (login creates sessions)
12CSRFDouble-submit cookie
13Branding + SharingMixed public/protected
14Protected RoutesAll other /api/* routes
15Error HandlerGeneric messages, no stack traces

Background Services

Three services start automatically at server boot (when system token is available):

ServiceIntervalPurpose
Rotation Scheduler60 sRotates secrets with rotate-interval metadata
Audit Watcher5 sPolls audit log, fires webhooks on matches
Backup SchedulerConfigurableCreates full KV backups on schedule

Config Storage

VaultLens stores its own configuration in a pluggable backend:

  • File mode (default) — INI file + blob directory on disk
  • Vault mode — Vault KV v2 engine vaultlens-conf

See Configuration for details.

Frontend State Management

StorePurpose
authStoreAuthentication state, current user token info
brandingStoreCurrent branding config (app name, colors, logo)
vaultStoreCached Vault metadata (engines, auth methods)

Server state (secret lists, policy details, etc.) is managed by TanStack Query with automatic caching and background refetching.

Released under the GPL-3.0 License.