# thariqs/ai-newtab architecture

> Architecture diagram of the GitHub repository thariqs/ai-newtab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thariqs/ai-newtab
- Repository: https://github.com/thariqs/ai-newtab

## Overview

AI Homepage is a Chromium new-tab extension that uses a background agent to turn a user's browsing into a personalized, rendered homepage. The user enters a key and optional instructions, then starts or resumes a build; the worker summarizes history, requests pages through the signed-in browser, and runs the agent to extract content and write a React component. The new tab displays progress and the result, while settings, privacy filters, and automatic rebuilds support the workflow. The main agent, browser, and UI paths are evidenced by excerpts and README; unsampled subsystem links are omitted where their call direction is not shown.

Main entry points: [`packages/agent-core/orchestrator.ts`](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/orchestrator.ts) (Agent orchestrator), [`apps/extension/entrypoints/newtab/App.tsx`](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/App.tsx) (New-tab UI), [`apps/extension/lib/build-manager.ts`](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/build-manager.ts) (Build manager), [`apps/extension/lib/browser-bridge.ts`](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/browser-bridge.ts) (Browser bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["New-tab experience"]
  node_newtab["New-tab UI<br/>[App.tsx]"]
  node_keysetup["API key setup<br/>[ApiKeySetup.tsx]"]
  node_progress["Build progress<br/>[BuildProgress.tsx]"]
  node_preview["Homepage preview"]
  node_settingsui["Settings UI<br/>[SettingsModal.tsx]"]
  node_buildclient["Build port client"]
  node_transpile["Homepage transpiler<br/>[transpile.ts]"]
end

subgraph group_worker["Build lifecycle"]
  node_worker["Background worker<br/>[background.ts]"]
  node_buildmanager["Build manager<br/>[build-manager.ts]"]
  node_autobuild["Auto rebuild policy<br/>[auto-rebuild.ts]"]
end

subgraph group_agent["Agent pipeline"]
  node_agent["Agent orchestrator<br/>[orchestrator.ts]"]
  node_agentsetup["Agent provisioning<br/>[setup.ts]"]
  node_prompt["Agent instructions<br/>[prompt.ts]"]
  node_digest["History digest<br/>[history-digest.ts]"]
  node_filters["URL privacy filters<br/>[site-filter.ts]"]
  node_schemas["Tool schemas<br/>[schemas.ts]"]
end

subgraph group_browser["Browser data access"]
  node_bridge["Browser bridge<br/>[browser-bridge.ts]"]
  node_history["History reader<br/>[history.ts]"]
  node_scraper["Page scraper<br/>[scraper.ts]"]
  node_scrapercontent["Scraper content script<br/>[scraper.content.ts]"]
end

subgraph group_state["Settings and state"]
  node_store[("Extension storage<br/>[storage.ts]")]
end

node_user(("Browser user"))
node_anthropic["Anthropic Managed Agents"]

node_user -->|"opens and configures"| node_newtab
node_newtab -->|"shows when key missing"| node_keysetup
node_newtab -->|"renders settings"| node_settingsui
node_newtab -->|"shows build status"| node_progress
node_newtab -->|"renders homepage"| node_preview
node_newtab -->|"starts build"| node_buildclient
node_newtab -->|"loads and saves settings"| node_store
node_newtab -->|"prepares homepage code"| node_transpile
node_buildclient -->|"sends build messages"| node_worker
node_worker -.->|"hosts build manager"| node_buildmanager
node_buildmanager -->|"runs build"| node_agent
node_buildmanager -->|"loads settings and homepage"| node_store
node_buildmanager -->|"checks rebuild eligibility"| node_autobuild
node_buildmanager -->|"supplies browser capabilities"| node_bridge
node_buildmanager -.->|"creates agent client"| node_anthropic
node_agent -->|"ensures agent and environment"| node_agentsetup
node_agent -->|"builds kickoff instructions"| node_prompt
node_agent -->|"checks requested URLs"| node_filters
node_agent -->|"reduces history"| node_digest
node_agent -->|"requests history and pages"| node_bridge
node_agent -->|"runs managed session"| node_anthropic
node_agent -.->|"registers custom tools"| node_schemas
node_bridge -->|"reads browser history"| node_history
node_bridge -->|"loads requested pages"| node_scraper
node_scraper -.->|"uses content script"| node_scrapercontent
node_agent -->|"persists session identifiers"| node_store
node_settingsui -->|"saves settings and rebuilds"| node_newtab
node_user -.->|"provides API key"| node_anthropic

click node_newtab "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/App.tsx"
click node_keysetup "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/ApiKeySetup.tsx"
click node_progress "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/BuildProgress.tsx"
click node_preview "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/HomepagePreview.tsx"
click node_settingsui "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/SettingsModal.tsx"
click node_buildclient "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/useHomepageBuild.ts"
click node_worker "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/background.ts"
click node_buildmanager "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/build-manager.ts"
click node_autobuild "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/auto-rebuild.ts"
click node_agent "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/orchestrator.ts"
click node_agentsetup "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/setup.ts"
click node_prompt "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/prompt.ts"
click node_digest "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/history-digest.ts"
click node_filters "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/site-filter.ts"
click node_schemas "https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/schemas.ts"
click node_bridge "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/browser-bridge.ts"
click node_history "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/history.ts"
click node_scraper "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/scraper.ts"
click node_scrapercontent "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/scraper.content.ts"
click node_store "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/storage.ts"
click node_transpile "https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/transpile.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_newtab,node_keysetup,node_progress,node_preview,node_settingsui,node_buildclient,node_transpile,node_user toneBlue
class node_worker,node_buildmanager,node_autobuild toneAmber
class node_agent,node_agentsetup,node_prompt,node_digest,node_filters,node_schemas toneMint
class node_bridge,node_history,node_scraper,node_scrapercontent toneRose
class node_store,node_anthropic toneIndigo
```

## Components

### New-tab experience

- [New-tab UI](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/App.tsx): `apps/extension/entrypoints/newtab/App.tsx`
- [API key setup](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/ApiKeySetup.tsx): `apps/extension/entrypoints/newtab/components/ApiKeySetup.tsx`
- [Build progress](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/BuildProgress.tsx): `apps/extension/entrypoints/newtab/components/BuildProgress.tsx`
- [Homepage preview](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/HomepagePreview.tsx): `apps/extension/entrypoints/newtab/components/HomepagePreview.tsx`
- [Settings UI](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/components/SettingsModal.tsx): `apps/extension/entrypoints/newtab/components/SettingsModal.tsx`
- [Build port client](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/newtab/useHomepageBuild.ts): `apps/extension/entrypoints/newtab/useHomepageBuild.ts`
- [Homepage transpiler](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/transpile.ts): `apps/extension/lib/transpile.ts`

### Build lifecycle

- [Background worker](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/background.ts): `apps/extension/entrypoints/background.ts`
- [Build manager](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/build-manager.ts): `apps/extension/lib/build-manager.ts`
- [Auto rebuild policy](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/auto-rebuild.ts): `apps/extension/lib/auto-rebuild.ts`

### Agent pipeline

- [Agent orchestrator](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/orchestrator.ts): `packages/agent-core/orchestrator.ts`
- [Agent provisioning](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/setup.ts): `packages/agent-core/setup.ts`
- [Agent instructions](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/prompt.ts): `packages/agent-core/prompt.ts`
- [History digest](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/history-digest.ts): `packages/agent-core/history-digest.ts`
- [URL privacy filters](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/site-filter.ts): `packages/agent-core/site-filter.ts`
- [Tool schemas](https://github.com/thariqs/ai-newtab/blob/main/packages/agent-core/schemas.ts): `packages/agent-core/schemas.ts`

### Browser data access

- [Browser bridge](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/browser-bridge.ts): `apps/extension/lib/browser-bridge.ts`
- [History reader](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/history.ts): `apps/extension/lib/history.ts`
- [Page scraper](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/scraper.ts): `apps/extension/lib/scraper.ts`
- [Scraper content script](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/entrypoints/scraper.content.ts): `apps/extension/entrypoints/scraper.content.ts`

### Settings and state

- [Extension storage](https://github.com/thariqs/ai-newtab/blob/main/apps/extension/lib/storage.ts): `apps/extension/lib/storage.ts`

### Other components

- **Browser user**
- **Anthropic Managed Agents**

## Connections

- Browser user → New-tab UI: opens and configures (evidence: `README.md`)
- New-tab UI → API key setup: shows when key missing (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Settings UI: renders settings (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Build progress: shows build status (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Homepage preview: renders homepage (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Build port client: starts build (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Extension storage: loads and saves settings (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- New-tab UI → Homepage transpiler: prepares homepage code (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- Build port client → Background worker: sends build messages (evidence: `apps/extension/entrypoints/newtab/useHomepageBuild.ts`)
- Background worker → Build manager: hosts build manager
- Build manager → Agent orchestrator: runs build (evidence: `apps/extension/lib/build-manager.ts`)
- Build manager → Extension storage: loads settings and homepage (evidence: `apps/extension/lib/build-manager.ts`)
- Build manager → Auto rebuild policy: checks rebuild eligibility (evidence: `apps/extension/lib/build-manager.ts`)
- Build manager → Browser bridge: supplies browser capabilities (evidence: `apps/extension/lib/build-manager.ts`)
- Build manager → Anthropic Managed Agents: creates agent client
- Agent orchestrator → Agent provisioning: ensures agent and environment (evidence: `packages/agent-core/orchestrator.ts`)
- Agent orchestrator → Agent instructions: builds kickoff instructions (evidence: `packages/agent-core/orchestrator.ts`)
- Agent orchestrator → URL privacy filters: checks requested URLs (evidence: `packages/agent-core/orchestrator.ts`)
- Agent orchestrator → History digest: reduces history (evidence: `packages/agent-core/orchestrator.ts`)
- Agent orchestrator → Browser bridge: requests history and pages (evidence: `README.md`)
- Agent orchestrator → Anthropic Managed Agents: runs managed session (evidence: `README.md`)
- Agent orchestrator → Tool schemas: registers custom tools (evidence: `packages/agent-core/orchestrator.ts`)
- Browser bridge → History reader: reads browser history (evidence: `apps/extension/lib/browser-bridge.ts`)
- Browser bridge → Page scraper: loads requested pages (evidence: `apps/extension/lib/browser-bridge.ts`)
- Page scraper → Scraper content script: uses content script
- Agent orchestrator → Extension storage: persists session identifiers
- Settings UI → New-tab UI: saves settings and rebuilds (evidence: `apps/extension/entrypoints/newtab/App.tsx`)
- Browser user → Anthropic Managed Agents: provides API key
