Architecture

Architecture Overview

Technical architecture documentation for the GaugeWell platform.

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Client Browser β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Client Portal β”‚ β”‚ Admin Portal β”‚ β”‚ (Next.js) β”‚ β”‚ (Next.js) β”‚ β”‚ portal.gaugewell β”‚ β”‚ admin.gaugewell β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Shared Database (Neon PostgreSQL) β”‚ β”‚ portal_users, portal_organizations, cms_clients, β”‚ β”‚ crm_leads, crm_clients, goals, kpis, action_items, ... β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Integration Layer β”‚ β”‚ Northstar Auditor β”‚ β”‚ (Python services) β”‚ β”‚ (Scanner API) β”‚ β”‚ CRM, CMS, Content β”‚ β”‚ 11-stage pipeline β”‚ β”‚ Billing, Social β”‚ β”‚ Score calculation β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

LayerTechnologyPurpose
FrontendNext.js 16, React 19, TypeScriptServer & client rendering
StylingTailwind CSS v3, @gaugewell/themeShared design system
Auth (Portal)Custom JWT + 2FA/TOTPPortal user authentication
Auth (Admin)Custom JWT + RBACAdmin role-based access
DatabaseNeon PostgreSQL (serverless)Primary data store
Background JobsInngestAsync task processing
PaymentsStripeSubscriptions and billing
HostingVercelEdge deployment
Error TrackingSentryRuntime error monitoring
AnalyticsVercel AnalyticsPerformance monitoring
IntegrationsPython microservicesCRM, CMS, Content AI, Social

Application Structure

Monorepo Layout

GaugeWell Web/ # Next.js monorepo (pnpm workspaces) β”œβ”€β”€ apps/ β”‚ β”œβ”€β”€ admin/ # Admin portal (admin.gaugewell.io) β”‚ β”œβ”€β”€ portal/ # Client portal (portal.gaugewell.io) β”‚ β”œβ”€β”€ docs/ # Documentation site (docs.gaugewell.io) β”‚ └── landing/ # Marketing site (gaugewell.io) β”œβ”€β”€ packages/ β”‚ └── theme/ # Shared design system (@gaugewell/theme) β”œβ”€β”€ migrations/ # SQL migration files └── scripts/ # Utility scripts GaugeWell Integrations/ # Python microservices monorepo β”œβ”€β”€ apps/ β”‚ β”œβ”€β”€ billing-integration/ β”‚ β”œβ”€β”€ cms-integration/ β”‚ β”œβ”€β”€ content-ai/ β”‚ β”œβ”€β”€ crm-integration/ β”‚ β”œβ”€β”€ northstar-auditor/ β”‚ β”œβ”€β”€ proofing-integration/ β”‚ └── social-integration/ └── shared/ # Shared utilities

Authentication Model

The platform uses two parallel authentication systems:

Portal Authentication β€” For client users:

  • Custom JWT stored in portal_token cookie
  • UUID-based user IDs (portal_users table)
  • Organization membership via portal_org_members
  • Optional 2FA via TOTP

Admin Authentication β€” For GaugeWell staff:

  • Custom JWT stored in admin_token cookie
  • Integer-based user IDs (admin_users table)
  • Role-based access control (RBAC) with granular permissions
  • Session validation against admin_sessions table

GaugeWell staff access client portals via impersonation, not membership. Staff emails (@gaugewell.io) should never be added to portal_org_members or cms_memberships.

Multi-Tenant Architecture

Each client organization can have:

  • A shared database connection (default β€” uses the platform’s Neon database)
  • A dedicated tenant database (provisioned via Neon branching for data isolation)

Tenant resolution follows this priority:

  1. cms_tenant_databases β€” Dedicated database if provisioned
  2. cms_memberships β€” Shared database with client scoping
  3. DATABASE_URL fallback β€” Shared database for dev/demo accounts

Key Design Principles

  • Server Components First β€” Use React Server Components by default; client components only for interactivity
  • Shared Theme Package β€” All UI tokens, components, and chart themes live in @gaugewell/theme
  • Granular Permissions β€” Every admin API route uses specific AuthConfigs (e.g., clientsRead, contentManage)
  • Audit Everything β€” All mutations are automatically logged to admin_audit_logs
  • Graceful Degradation β€” Portal pages handle missing data with empty states and skeleton loading
  • Vertical Awareness β€” Scoring, dashboards, and content adapt to the client’s business type

Decision Records

See Architecture Decision Records for documented decisions on technology choices, patterns, and trade-offs.

Last updated on