This directory contains the source code for the Graphiti Chrome Extension.
src/
├── background/ # Service worker (background script)
├── content/ # Content scripts (injected into web pages)
├── popup/ # Extension popup UI
├── sidepanel/ # Side panel feed UI
├── profile/ # Profile rendering pages
├── styles/ # Global CSS styles
├── utils/ # Shared utility modules
└── test/ # Test setup and mocks
┌─────────────────────────────────────────────────────────┐
│ Background │
│ (Service Worker - background.ts) │
│ - Handles keyboard shortcuts │
│ - Manages side panel │
│ - Coordinates message passing │
└─────────────────┬───────────────────────────────────────┘
│
┌─────────────┴─────────────┬─────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────────┐ ┌──────────────┐
│ Popup │ │ Content │ │ Sidepanel │
│ │ │ │ │ │
│ - Auth │ │ - Drawings │ │ - Feed │
│ - Quick │◄───────────►│ - Annotate │◄─►│ - Posts │
│ actions│ messaging │ - Pubky URLs │ │ - Annotate │
└────┬─────┘ └──────────────┘ └──────────────┘
│
└────────────────────────┐
▼
┌──────────────────┐
│ Utils │
│ │
│ - storage.ts │
│ - crypto.ts │
│ - pubky-api.ts │
│ - logger.ts │
└──────────────────┘
After running npm run build, compiled files are in dist/:
background.js- Service workercontent.js- Content scriptpopup.html+ assetssidepanel.html+ assets
| Entry Point | Source | Purpose |
|---|---|---|
| Background | background/background.ts |
Extension lifecycle, messaging |
| Content | content/content.ts |
Page injection, drawing, annotations |
| Popup | popup/main.tsx |
Extension popup React app |
| Sidepanel | sidepanel/main.tsx |
Feed viewer React app |
| Entry Point | Source File | Purpose |
|---|---|---|
| Background | background/background.ts |
Service worker, extension lifecycle |
| Content | content/content.ts |
Page injection, drawing, annotations |
| Popup | popup/main.tsx |
Extension popup React app |
| Sidepanel | sidepanel/main.tsx |
Feed viewer React app |
| Profile | profile/profile-renderer.ts |
Profile page renderer |
| Offscreen | offscreen/offscreen.ts |
Offscreen document for SDK |
After running npm run build, compiled files are in dist/:
background.js- Service workercontent.js- Content scriptpopup.html+ assets - Popup UIsidepanel.html+ assets - Side panel UIsrc/profile/profile-renderer.html- Profile renderersrc/offscreen/offscreen.js- Offscreen document
New Utility:
- Create file in
utils/ - Export functions/classes
- Add TypeScript types
- Write tests in
utils/__tests__/
New Component:
- Create in
popup/components/orsidepanel/components/ - Use React + TypeScript
- Style with Tailwind CSS
- Import and use in parent component
New Content Script Feature:
- Create manager class in
content/ - Initialize in
content.ts - Handle messages from background
- Use inline styles to avoid conflicts
Tests are located in __tests__/ directories:
- Unit tests for utilities
- Integration tests for API clients
- Component tests for React components
Run tests with:
npm test- Root README - Getting started
- FEATURES.md - Feature documentation
- docs/ - Technical documentation
- CONTRIBUTING.md - Contribution guidelines