How briehq/brie-extension works
Project type and purpose
• This is a monorepo-driven Chrome Extension (“Brie”) built with Turborepo and pnpm.
• It captures screenshots, DOM events, console/Network errors, and user actions in real-time, storing them and surfacing them through various React-powered UIs (popup, in-page annotation overlay, and a runtime page).
File structure
• Top-level workflows and lint/build scripts under .github/workflows, bash-scripts, husky, etc.
• A chrome-extension folder with manifest.ts, background code, plugins, and build config.
• A packages workspace containing reusable libraries:
• shared (constants, interfaces, utils, HOCs)
• ui (design system, Tailwind config, React primitives)
• store (state management, API services, Redux slices)
• storage (Chrome storage adapters)
• i18n (localization engine)
• env, dev-utils, hmr, tailwindcss-config, vite-config, zipper.
• Three “pages” apps under /pages:
• content-runtime – embedded React runtime page
• content-ui – in-page overlay/annotation UI
• E2E tests under tests/e2e for each page.
Key README insights
• Core use case: “Capture & Share Instantly” for bug reporting.
• Tech stack: React, Vite, Turborepo, Chrome Extension API.
A. Browser Extension Host
• Manifest
• Background script (singleton event/message router)
• Content Script + Injected Scripts (DOM/event interceptors, network/console interceptors)
B. Client UIs (all React + Vite)
• Popup UI (pages/popup)
• In-page Annotation UI (pages/content-ui)
• Runtime Page UI (pages/content-runtime)
C. Monorepo Packages (compiled & bundled into the above)
1. shared – types, constants, utils, HOCs
2. ui – design system components + Tailwind config
3. store – Redux slices + API services + React hooks
4. storage – Chrome storage layer for persisting history, tokens, theming, etc.
5. i18n – locale loaders & codegen for multi-language support
6. build tools – env, dev-utils, hmr, vite-config, zipper, tailwindcss-config
D. External Services
• Brie backend API (for submitting/syncing bug reports)
• OAuth / Identity provider (for user authentication)
Relationships and data flow
• User action in browser → Content Script / Injected Scripts capture event → sendMessage → Background
• Background → persists data with storage package (Chrome.storage)
• UIs (Popup or In-page) → dispatch Redux actions via store → may fetch remote data via API services
• Shared UI components & i18n used across all pages
• Build time: vite-config, hmr, dev-utils, zipper produce individual bundles for each page + extension bundle
Architectural patterns & principles
• Monorepo with reusable, versioned packages → enforce DRY and consistency
• Clear separation of concerns:
• Content layer (data capture)
• Background layer (coordination & persistence)
• Presentation layer (React UIs)
• Pub/Sub via Chrome messaging for loose coupling
• State management with Redux slices exposed via React hooks
• Build‐time code generation and HMR for rapid iteration
Detailed checklist
[ ] Browser Extension Host
– manifest.json → background.js
– background ↔ contentScript / injectedScript messaging
– background → chrome.storage (via storage lib)
[ ] React UIs (Popup, Content UI, Runtime UI)
– load via extension (popup.html) or injected DOM
– connect to store (Redux + hooks) and background messaging
– render via ui & shared components; localize via i18n
[ ] Packages & Build Tooling
– show hmr, vite-config, dev-utils, zipper, tailwindcss-config feeding into each page’s build
[ ] External Services
– Brie API endpoint for report submission
– Identity provider / OAuth flows