System overview
PassAgent is a monorepo application built on Next.js with three companion microservices, browser extensions for Chrome/Firefox/Safari, and a native iOS app. All vault operations happen client-side — the server never sees plaintext credentials.Technology stack
Frontend
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 16.1 | Full-stack React framework with App Router, Turbopack dev server, standalone output |
| React | 19 | UI library with React Compiler enabled (reactCompiler: true) |
| TypeScript | 5.9 | Strict mode, bundler module resolution, incremental builds |
| Tailwind CSS | 4.1 | Utility-first CSS with class-based dark mode and CSS variable color tokens |
| Radix UI | Latest | 25+ accessible, unstyled primitives (Dialog, Dropdown, Accordion, Toast, etc.) |
| shadcn/ui | — | Pre-built component library on top of Radix with Tailwind styling |
| Untitled UI | 0.1.52 | Icon system (@untitledui/icons, @untitledui/file-icons) |
| Motion (Framer) | 12.29 | Layout animations, page transitions, gesture handling |
| Recharts | 3.7 | Dashboard charts and security analytics visualizations |
| Three.js / R3F | 0.182 | 3D elements on the marketing site (@react-three/fiber, @react-three/drei) |
| Tiptap | 3.18 | Rich text editor for secure notes (with image, placeholder, text align extensions) |
| React Hook Form | 7.71 | Form management with Zod schema validation |
| React Aria | 3.45 | Accessible UI primitives from Adobe for complex interactive components |
| cmdk | 1.0.4 | Command palette (⌘K) for quick vault search |
| Sonner | 2.0.7 | Toast notifications |
| Vaul | 1.1.2 | Drawer component for mobile UI |
| Embla Carousel | 8.6 | Touch-friendly carousels |
| Shiki | 3.22 | Syntax highlighting in secure notes code blocks |
Backend
| Technology | Version | Purpose |
|---|---|---|
| Supabase | 2.95 | PostgreSQL 15 database, Auth (JWT + cookies), Row-Level Security, Realtime subscriptions |
| Redis (ioredis) | 5.6 | Session state, rate limiting (sliding window), alert counters, OPRF rate limits, agent state caching. In-memory fallback with TTL for environments without Redis |
| BullMQ | 5.67 | Background job queue for async password resets (orchestrator → worker pattern) |
| Express | 4.22 | HTTP server for microservices (orchestrator, worker, mailbox reader) |
| Stripe | 20.3 | Subscription billing, checkout, customer portal, webhook processing, promo codes |
| Nodemailer | 8.0 | Transactional email (sign-in notifications, family invites, dead man’s switch alerts) |
| React Email | 0.4 | Email template rendering with Tailwind + Handlebars |
| googleapis | 148.0 | Gmail OAuth2 for reading password reset emails and account discovery |
| jose | 5.9 | JWT signing, verification, and token management |
| Zod | 3.25 | Runtime schema validation for all API inputs |
| Cheerio | 1.0 | HTML parsing for email content extraction and link scraping |
| TypeORM | 0.3.20 | ORM for orchestrator service database operations |
| postgres | 3.4 | Lightweight PostgreSQL client for direct queries |
| Twilio | 5.12 | SMS delivery for 2FA codes |
| rate-limiter-flexible | 7.2 | Redis-backed rate limiting with sliding window counters |
AI & browser automation
| Technology | Version | Purpose |
|---|---|---|
| Anthropic Claude SDK | 0.73 | Vision AI (screenshot analysis), reasoning (page state classification), chat routing (tool_use with 20+ vault tools) |
| Vercel AI SDK | 3.4 | Streaming chat responses (StreamingTextResponse), tool routing abstraction |
| LangChain | 0.3.19 | Agent orchestration framework, LangGraph state machines for multi-step reset flows |
| Hyperbrowser Agent | 1.1.2 | Cloud browser with AI sub-goal execution, live preview URLs, session sharing infrastructure |
| Playwright | 1.58 | Local headless browser automation, E2E testing, screenshot capture |
| Puppeteer | 24.17 | Chromium automation fallback for specific provider integrations |
| Browserless | — | Cloud browser service; BQL (Browserless Query Language) for scripted reset flows |
| OpenAI SDK | 3.0 | Alternative LLM provider for specific automation tasks via @ai-sdk/openai |
Cryptography & security
| Technology | Purpose | |
|---|---|---|
| Web Crypto API | All client-side encryption: AES-256-GCM, RSA-OAEP, HKDF-SHA256, HMAC-SHA256, P-256 ECDSA. Non-extractable CryptoKey objects | |
| Argon2id (hash-wasm) | Master password KDF — 64 MiB memory, 3 iterations, 4 threads. Fallback: 32 MiB for low-memory devices | |
| SimpleWebAuthn | 13.2 | WebAuthn server-side verification for passkeys and biometric unlock |
| AWS KMS | Server-side DEK envelope encryption — KMS wraps the data encryption key; key never in plaintext on disk | |
| HashiCorp Vault | Key wrapping and secret management for the orchestrator microservice | |
| AWS Secrets Manager | Runtime secret retrieval for microservices (DB passwords, API keys) | |
| Cloudflare Turnstile | Bot protection on authentication endpoints | |
| GF(256) Shamir | Custom implementation of Shamir’s Secret Sharing over Galois Field 256 for threshold vault recovery |
Cloud infrastructure
| Service | Purpose |
|---|---|
| AWS ECS | Container orchestration for all services (Next.js app, orchestrator, worker, mailbox reader) |
| AWS S3 / MinIO | Evidence storage (screenshots, DOM snapshots) and vault attachments |
| AWS SQS | Message queue between orchestrator and worker services |
| AWS KMS | Hardware security module for data encryption key management |
| Supabase Cloud | Managed PostgreSQL, Auth, Realtime, and Storage |
| Sentry | Error tracking, performance monitoring, custom metrics. Tunnel via /monitoring to bypass ad blockers |
| Have I Been Pwned | Breach monitoring API with k-anonymity (SHA-1 prefix) |
DevOps & CI/CD
| Tool | Purpose | |
|---|---|---|
| GitHub Actions | 8 workflows: CI (lint, type-check, test, security gates, perf smoke), deploy (staging auto, production canary), CodeQL, Semgrep, secret rotation, incident drills, monthly evidence rollups | |
| Docker | 3-stage build (deps → builder → runner). Alpine Node 20, non-root user. Worker uses ghcr.io/microsoft/playwright:focal | |
| docker-compose | Local dev: app + PostgreSQL 16 + Redis 7 + MinIO + HashiCorp Vault + MailHog | |
| pnpm | 9.15 | Package manager with workspace monorepo support |
| Husky | Pre-commit (lint-staged) and pre-push (test + coverage) hooks | |
| lint-staged | Prettier + ESLint on staged .ts/.tsx files | |
| Jest | 30.0 | 2715+ unit tests, 108 test suites, jsdom environment, coverage thresholds (84% statements, 75% branches, 88% lines, 80% functions) |
| Playwright Test | E2E tests, sequential execution, trace/screenshot/video on failure | |
| Semgrep | SAST with OWASP Top 10 + Next.js + JWT + custom rules | |
| CodeQL | GitHub-native code analysis with security-extended queries | |
| Gitleaks | Secret scanning in CI | |
| Socket.dev | Supply chain security analysis on PRs | |
| CycloneDX | SBOM (Software Bill of Materials) generation |
Testing & quality
| Category | Details |
|---|---|
| Unit tests | 2715 tests across 108 suites — crypto roundtrips, API routes, security controls, AI guard, anomaly detection |
| Security tests | Dedicated test:security suite — phishing detection, spray detection, anomaly detection, AI guard (input/output/semantic), invariant checks |
| E2E tests | Playwright-based auth flow, vault operations, reset flows |
| Performance gates | CI smoke test: 60 requests, concurrency 6, p95 must be under 1200ms |
| Security CI scripts | 12 static analysis scripts: auth guard coverage, rate limit coverage, plaintext leak detection, fail-closed verification, privileged audit coverage, security claims validation |
| Property-based testing | fast-check for fuzzing crypto operations |
| Coverage thresholds | Enforced in CI: 84% statements, 75% branches, 88% lines, 80% functions |
Database schema
PassAgent uses Supabase (PostgreSQL 15) with Row-Level Security on every table. The schema evolved over 53 migrations.Every table with user data has RLS policies scoped to
auth.uid(). The server cannot query across users even with a database connection. Service-role access is used only for system operations (cron jobs, admin endpoints).Deployment architecture
Production (AWS ECS)
Deployment pipeline
CI gates
Lint → Type check → 2715 unit tests → 12 security scripts → CodeQL + Semgrep → Performance smoke (p95 < 1200ms) → Production readiness gate
Docker build
3-stage Alpine build. Multi-arch (amd64). SHA-tagged +
latest. GitHub Actions cache for layer reuse.Staging deploy
Auto-deploys to
staging.passagent.app on push to main. ECS update-service --force-new-deployment. Smoke test verifies HTTP 200.Local development (docker-compose)
| Service | Image | Port | Purpose |
|---|---|---|---|
app | Dockerfile | 3000 | Next.js with Turbopack |
postgres | postgres:16 | 5432 | Local database |
redis | redis:7-alpine | 6379 | Sessions, rate limits |
minio | minio/minio | 9000, 9001 | S3-compatible object storage |
vault | hashicorp/vault:1.15 | 8200 | Key wrapping |
mailhog | mailhog:v1.0.1 | 1025, 8025 | SMTP trap for email testing |
Security middleware
Every page request passes through Next.js middleware that:- Generates a per-request UUID nonce for Content Security Policy
- Sets
Content-Security-Policywithstrict-dynamic+ nonce-based script loading - Sets
X-Frame-Options: DENY,X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-origin - Restricts
Permissions-Policy(no camera, microphone, geolocation) - Reports CSP violations to
/api/csp-report - Allows
frame-srconly for Stripe.js and Cloudflare Turnstile - Blocks all framing via
frame-ancestors 'none'
Monorepo structure
Browser extension architecture
- Chrome (MV3)
- Firefox (MV3)
- Safari
Manifest V3 with service worker background script and side panel UI.Key capabilities:
- Autofill via content script injection (domain-matched blind indexes)
- WebAuthn proxy (
webAuthenticationProxypermission) — extension acts as a software passkey authenticator - Side panel embeds the full AI chat interface
- Action cache client prefetches golden scripts for fast resets
- 4-layer phishing detection runs before every autofill
storage, activeTab, scripting, contextMenus, notifications, tabs, alarms, cookies, sidePanel, webAuthenticationProxy, tabGroupsKeyboard shortcuts: ⌘⇧P (open), ⌘⇧L (autofill), ⌘⇧G (generate)CSP: script-src 'self' 'wasm-unsafe-eval' (required for Argon2id WASM)iOS app architecture
| Component | Technology |
|---|---|
| UI framework | SwiftUI (iOS 17.0+, Swift 5.10) |
| AutoFill | Credential Provider Extension (shares vault crypto code via App Group) |
| Widgets | WidgetKit extension |
| Keychain | KeychainAccess library for secure storage |
| QR scanning | CodeScanner library for TOTP setup |
| KDF | Argon2Swift (native Argon2id implementation) |
| Build system | XcodeGen (project.yml) with 5 targets |
| App Group | group.com.passagent.shared for data sharing between app, AutoFill, and widget |
Observability
Sentry integration
Sentry integration
- Client + Server + Edge Sentry SDKs (v10.38)
- 100% trace sampling in dev, 10% in production
- Custom metrics:
http.request.duration,reset_flow.success,auth.failure,security.spray_detected - CSP violation reporting at
/api/csp-report - Tunnel route
/monitoringto bypass ad blockers - Filtered: 4xx errors (except 429),
ResizeObserver,ChunkLoadError,AbortError
SLO tracking
SLO tracking
- Availability target: 99.9% (43 minutes/month error budget)
- Latency targets: p95 < 1200ms, p99 < 3000ms
- Google SRE multi-window burn rate alerting: >14x = critical (~2h budget exhaust), >6x = warning (~5h), >1x + <50% remaining = info
- Cron:
POST /api/cron/slo-burn-rate-check
Alerting rules
Alerting rules
Redis-backed counter alerting with sliding windows and cooldown deduplication:
| Severity | Alert | Threshold | Window |
|---|---|---|---|
| P1 | 5xx errors | >10 | 5 min |
| P1 | Webhook failure | >3 | 1 hour |
| P1 | Critical DB write failure | >1 | 5 min |
| P1 | Redis failure | >5 | 5 min |
| P2 | Auth failures | >50 | 10 min |
| P2 | Rate limit hits | >100 | 10 min |
| P2 | Spray detected | >3 | 30 min |
| P3 | Access anomaly | >5 | 1 hour |