Skip to content

Architecture Overview

System Architecture

HQ is a monorepo that ships five packages, a documentation site, and cloud infrastructure. The user interacts with HQ through Claude Code locally, and optionally through a PWA dashboard on mobile. Cloud sync bridges the two.

Runtime Flow

Data Flow

HQ follows a linear progression from install to daily use:

1. Install

Terminal window
npx create-hq

create-hq scaffolds a new HQ directory from template/, installs dependencies, and optionally runs /setup for interactive configuration.

2. Setup

The /setup command walks through:

  • Company configuration (names, settings)
  • API credentials (per company)
  • Worker selection and activation
  • Knowledge base initialization
  • Cloud sync credentials (optional)

3. Work

Daily workflow happens entirely through Claude Code:

All state lives in the filesystem. Workers read knowledge, write reports, update threads, and commit to git repos.

4. Sync

hq-cloud synchronizes the local HQ directory to S3:

Sync is selective — only workspace state, reports, and social drafts are synced. Git repos, node_modules, and credentials are excluded.

5. Mobile

The PWA dashboard (apps/web) provides read access to:

  • Active threads and checkpoints
  • Reports and social drafts
  • Worker status and project progress
  • Quick actions (approve posts, review reports)

Authentication flows through AWS Cognito. Content is served from S3 via CloudFront.

Package Graph

Dependency Direction

Packages are loosely coupled. create-hq only touches template/ at install time and has no runtime dependency on other packages. hq-cli is the primary user-facing package and depends on hq-cloud for sync operations.

Technology Stack

Core

TechnologyPurposeRationale
Node.js 18+RuntimeUniversal JS runtime, native in Claude Code environments
TypeScriptLanguageType safety across all packages, better IDE support
npm workspacesMonorepoZero-config workspace management, native to npm

Packages

TechnologyPackageRationale
Commander.jscreate-hq, hq-cliStandard Node.js CLI framework
AWS SDK v3hq-cloudModular AWS client, tree-shakeable
zodhq-cli, hq-cloudRuntime schema validation for configs

Frontend (apps/web)

TechnologyPurposeRationale
React 19UI frameworkLatest React with concurrent features
ViteBuild toolFast HMR, native ESM, minimal config
Tailwind CSSStylingUtility-first, consistent design system
PWAMobile accessInstallable on any device, no app store required

Documentation (apps/docs)

TechnologyPurposeRationale
AstroFrameworkStatic-first, fast builds, content-focused
StarlightThemePurpose-built for documentation, search included
MDXContentMarkdown with component support

Infrastructure (infra/)

TechnologyPurposeRationale
SSTIaC frameworkTypeScript-native, live Lambda debugging
AWS CognitoAuthManaged user pools, JWT tokens
AWS S3StorageEncrypted file storage, per-user prefixes
API GatewayAPI layerRESTful endpoints for PWA
LambdaComputeServerless functions for API handlers
CloudFrontCDNGlobal edge caching for PWA assets and API

Why These Choices

npm workspaces over Turborepo/Nx: HQ is a modest monorepo (5 packages). npm workspaces provide native workspace linking and script orchestration without adding a build system dependency. If the repo grows significantly, Turborepo can be layered on top without migration.

SST over CDK/Terraform: SST wraps AWS CDK with TypeScript-native constructs and provides live Lambda debugging during development. This aligns with the all-TypeScript stack and reduces the feedback loop for infrastructure changes.

Astro Starlight over Docusaurus/Nextra: Starlight is purpose-built for documentation. It ships with search, navigation, and i18n out of the box. Astro’s partial hydration means zero JS ships to the client by default.

PWA over native app: HQ’s mobile needs are read-heavy (view reports, approve posts). A PWA provides installable mobile access without app store overhead, and shares the same React codebase.