Repository Overview
The extension is built with React 17, TypeScript, and Webpack 5, using TensorFlow.js with MoveNet for real-time pose detection.Source Directory (src/)
The src/ directory contains all the source code for the extension:
Directory Structure
Extension Pages
The extension consists of four main components, each with its own entry point:Background Service Worker
The extension uses Manifest V3, which requires a service worker instead of a persistent background page.
src/pages/Background/
Entry Point: src/pages/Background/index.js
Purpose: Handles background tasks and manages extension state. Acts as the service worker for the extension.
Webpack Output: background.bundle.js
Content Script
Location:src/pages/Content/
Entry Point: src/pages/Content/index.tsx
Key Files:
Content.tsx- Main content script componentcontent.styles.css- Injected styles
http://*/* and https://*/*). Applies the blur effect when poor posture is detected.
Webpack Output: contentScript.bundle.js
Options Page
Location:src/pages/Options/
Entry Point: src/pages/Options/index.jsx
Key Files:
Options.tsx- Main options page componentmodules/draw_utils.ts- Canvas drawing utilities for pose visualization
options.bundle.js + options.html
Access: Via browser extension menu or right-click → Options
Browser Action Popup
Location:src/pages/Popup/
Entry Point: src/pages/Popup/index.jsx
Key Files:
Popup.jsx- Main popup component
popup.bundle.js + popup.html
Assets Directory
Location:src/assets/img/
Contents:
icon-128.png- Full-size extension icon (128×128)icon-34.png- Browser toolbar icon (34×34)- Screenshots and promotional images
build/ directory during compilation.
Utilities Directory (utils/)
Contains build and development scripts:
build.js- Production build script (runs Webpack with production config)webserver.js- Development server script (runs Webpack Dev Server with HMR)env.js- Environment variable configuration
Configuration Files
webpack.config.js
Configures the Webpack build process with:
- Multiple entry points: Four separate bundles for different parts of the extension
- Hot reload support: Enabled for Options and Popup pages
- TypeScript compilation: Via
ts-loader - Babel transpilation: Via
babel-loaderwith React preset - Asset copying: Manifest, icons, and CSS files
- HTML generation: Separate HTML files for Options and Popup pages
manifest.json
The manifest uses Chrome Extension Manifest V3 format, compatible with both Chrome and Firefox.
- Extension metadata (name, description, version)
- Service worker configuration
- Content script injection rules
- Permissions and web-accessible resources
- Browser action popup and options page
package.json during build.
tsconfig.json
TypeScript compiler configuration for type checking and compilation.
package.json
Key sections:
- engines: Requires Node.js ≥20.0.0
- scripts: Build, development, and formatting commands
- dependencies: Runtime libraries (React, TensorFlow.js, react-webcam)
- devDependencies: Build tools (Webpack, Babel, TypeScript, loaders)
Technology Stack
The extension is built with:| Technology | Version | Purpose |
|---|---|---|
| React | 17.0.2 | UI framework for Options and Popup pages |
| TypeScript | 4.4.4+ | Type-safe JavaScript development |
| Webpack | 5.76.0+ | Module bundler and build tool |
| TensorFlow.js | 3.11.0+ | Machine learning runtime |
| MoveNet | 0.0.6 | Pose detection model |
| React Webcam | 6.0.0+ | Camera access component |
Build Output (build/)
Generated by Webpack, contains the compiled extension ready for loading:
Development Workflow
- Edit source files in
src/ - Webpack watches for changes (when running
npm start) - Hot reload updates Options and Popup pages automatically
- Content script changes require manual extension reload
- Background changes require manual extension reload
Next Steps
- Learn about Building from Source
- Read the Contributing Guidelines
- Explore the TensorFlow.js MoveNet documentation