# josueluna/linkedin_to_sheets architecture

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

- Interactive diagram: https://gitdiagram.com/josueluna/linkedin_to_sheets
- Repository: https://github.com/josueluna/linkedin_to_sheets

## Overview

1. **Overall shape**
   - This is a **Chrome Extension (Manifest V3)** built with **React + Vite**.
   - The product flow is “read data from a LinkedIn profile page, then write it into Google Sheets.”
   - The architecture is split into three main runtimes: the **LinkedIn page content script**, the **extension popup UI**, and the **background script** that coordinates privileged browser/API work.

2. **User-facing entry point: popup UI**
   - `src/App.tsx`, `src/main.tsx`, and `src/components/ExtensionPopup.tsx` make up the popup experience the user opens from the extension icon.
   - `SpreadsheetSelector.tsx` suggests the popup lets the user choose a target Google Spreadsheet and tab before saving.
   - This UI is the control plane for the workflow, not the data source itself.

3. **Page-level data extraction**
   - `src/content.ts` is the content script injected into LinkedIn pages.
   - Its job is to inspect the current LinkedIn profile DOM and extract structured profile fields such as name, company, title, location, and profile URL.
   - This creates the boundary between the public webpage environment and the extension’s trusted logic.

4. **Background orchestration**
   - `src/background.ts` is the central service worker for extension-side coordination.
   - It likely receives messages from the popup and content script, handles auth state, and performs actions that require extension privileges.
   - This is the main integration point between UI, extracted profile data, and Google APIs.

5. **Google integration boundary**
   - `src/lib/google.ts` encapsulates Google OAuth and API interaction.
   - Based on the README, it likely covers both **Google Sheets API** writes and **Google Drive API** listing/discovery of spreadsheets.
   - This module is the external-service boundary for all Google-related behavior.

6. **Persistence and local state**
   - `src/lib/storage.ts` is the local persistence layer, likely backed by extension storage.
   - It probably stores things like the selected spreadsheet/tab, auth tokens or session markers, and possibly deduplication metadata.
   - The repo emphasizes “no data stored externally,” so persistence appears to be local to the browser extension.

7. **Data flow: LinkedIn → Sheets**
   - The intended flow is: user opens a LinkedIn profile, the **content script** extracts profile data, the **popup UI** lets the user choose where to send it, and the **background script + Google lib** append the row to Sheets.
   - The README’s “Paste Current Profile” action maps directly to this pipeline.
   - The data shape is intentionally small and structured, which keeps the write path simple.

8. **Spreadsheet and tab selection**
   - The presence of `SpreadsheetSelector.tsx` implies the extension supports selecting both a workbook and a specific worksheet tab.
   - That selection is part of the user workflow before insertion, which means the extension is not hardcoded to a single destination.
   - This is an important architectural boundary: destination selection happens in the UI, while actual listing/writing happens in the Google integration layer.

9. **Duplicate avoidance**
   - The README explicitly says duplicate entries are avoided.
   - That suggests the extension compares the current LinkedIn profile URL or another stable identifier against existing local or sheet state before writing.
   - Architecturally, deduplication likely lives near the Sheets write path or in the local storage layer, not in the content script.

10. **Build and runtime tooling**
   - `vite.config.ts`, `tailwind.config.ts`, `postcss.config.js`, and `src/index.css` indicate a Vite-based frontend build with Tailwind styling.
   - `public/manifest.json` is the extension manifest that defines MV3 entry points and permissions.
   - `index.html` is the popup/page shell used by Vite to bundle the React app for the extension UI.

11. **Static pages and documentation surfaces**
   - `privacy.html` and `wiki.html` are separate static pages, likely for policy/documentation rather than runtime extension behavior.
   - These are outside the main data path, but they matter for the repository’s deployment surface and compliance/documentation story.

12. **Architecture summary for diagramming**
   - Draw three zones: **LinkedIn page context**, **Extension UI/background**, and **Google services**.
   - Show the content script extracting profile data from LinkedIn, the popup collecting user destination choices, and the background script invoking Google OAuth/Sheets/Drive operations.
   - Keep storage as a local supporting boundary, not a primary system of record.

Main entry points: [`src/background.ts`](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/background.ts) (Background worker), [`src/lib/google.ts`](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/google.ts) (Google client), [`public/manifest.json`](https://github.com/josueluna/linkedin_to_sheets/blob/main/public/manifest.json) (Manifest), [`src/content.ts`](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/content.ts) (Content script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_linkedin["LinkedIn page"]
  node_node_content["Content script<br/>[content.ts]"]
  node_node_profile_data["Profile data<br/>extracted model"]
end

subgraph group_group_extension["Extension runtime"]
  node_node_popup_app["Popup app<br/>React entry<br/>[App.tsx]"]
  node_node_main["UI mount<br/>React bootstrap<br/>[main.tsx]"]
  node_node_popup["Extension popup<br/>UI panel<br/>[ExtensionPopup.tsx]"]
  node_node_selector["Spreadsheet selector<br/>UI component"]
  node_node_background{{"Background worker<br/>service worker<br/>[background.ts]"}}
  node_node_storage[("Local storage<br/>persistence<br/>[storage.ts]")]
  node_node_utils["UI utils<br/>helpers<br/>[utils.ts]"]
end

subgraph group_group_google["Google services"]
  node_node_google["Google client<br/>api adapter<br/>[google.ts]"]
  node_node_sheets[("Sheets write<br/>api boundary")]
  node_node_drive[("Drive lookup<br/>api boundary")]
  node_node_oauth(("Google OAuth<br/>auth flow"))
end

subgraph group_group_build["Build & docs"]
  node_node_manifest["Manifest<br/>mv3 config<br/>[manifest.json]"]
  node_node_vite["Vite config<br/>build config<br/>[vite.config.ts]"]
  node_node_styles["Tailwind styles<br/>style config<br/>[tailwind.config.ts]"]
  node_node_docs["Docs pages<br/>static pages<br/>[privacy.html]"]
end

node_node_main -->|"mounts"| node_node_popup
node_node_popup_app -->|"uses"| node_node_selector
node_node_popup -->|"sends actions"| node_node_background
node_node_content -->|"extracts"| node_node_profile_data
node_node_content -->|"posts data"| node_node_background
node_node_background -->|"reads/writes"| node_node_storage
node_node_background -->|"delegates"| node_node_google
node_node_google -->|"authenticates"| node_node_oauth
node_node_google -->|"lists"| node_node_drive
node_node_google -->|"writes"| node_node_sheets
node_node_selector -->|"persists choice"| node_node_storage
node_node_background -->|"dedupes before write"| node_node_sheets
node_node_manifest -->|"registers"| node_node_content
node_node_manifest -->|"registers"| node_node_background
node_node_manifest -->|"registers"| node_node_main
node_node_vite -->|"bundles"| node_node_popup_app
node_node_styles -->|"styles"| node_node_popup
node_node_docs -.->|"separate surface"| node_node_manifest

click node_node_content "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/content.ts"
click node_node_popup_app "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/App.tsx"
click node_node_main "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/main.tsx"
click node_node_popup "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/components/ExtensionPopup.tsx"
click node_node_selector "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/components/SpreadsheetSelector.tsx"
click node_node_background "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/background.ts"
click node_node_storage "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/storage.ts"
click node_node_utils "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/utils.ts"
click node_node_google "https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/google.ts"
click node_node_manifest "https://github.com/josueluna/linkedin_to_sheets/blob/main/public/manifest.json"
click node_node_vite "https://github.com/josueluna/linkedin_to_sheets/blob/main/vite.config.ts"
click node_node_styles "https://github.com/josueluna/linkedin_to_sheets/blob/main/tailwind.config.ts"
click node_node_docs "https://github.com/josueluna/linkedin_to_sheets/blob/main/privacy.html"

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_node_content,node_node_profile_data toneBlue
class node_node_popup_app,node_node_main,node_node_popup,node_node_selector,node_node_background,node_node_storage,node_node_utils toneAmber
class node_node_google,node_node_sheets,node_node_drive,node_node_oauth toneMint
class node_node_manifest,node_node_vite,node_node_styles,node_node_docs toneRose
```

## Components

### LinkedIn page

The untrusted page context where profile data is read from the DOM.

- [Content script](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/content.ts): content script · Injected into LinkedIn pages to extract profile fields from the DOM. · `src/content.ts`
- **Profile data**: extracted model · Structured LinkedIn profile details passed from the page context.

### Extension runtime

Popup UI, background worker, and local state that coordinate the workflow.

- [Popup app](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/App.tsx): React entry · Top-level popup shell shown when the extension icon is opened. · `src/App.tsx`
- [UI mount](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/main.tsx): React bootstrap · Bootstraps the popup React app into the extension page. · `src/main.tsx`
- [Extension popup](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/components/ExtensionPopup.tsx): UI panel · User-facing control plane for choosing destinations and triggering saves. · `src/components/ExtensionPopup.tsx`
- [Spreadsheet selector](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/components/SpreadsheetSelector.tsx): UI component · Lets the user choose a spreadsheet and worksheet tab. · `src/components/SpreadsheetSelector.tsx`
- [Background worker](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/background.ts): service worker · Coordinates messages, privileged browser actions, and save orchestration. · `src/background.ts`
- [Local storage](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/storage.ts): persistence · Extension-local state for selections, session markers, and dedupe support. · `src/lib/storage.ts`
- [UI utils](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/utils.ts): helpers · Shared utility helpers used by the React UI components. · `src/lib/utils.ts`

### Google services

External OAuth and API boundary for spreadsheets and drive discovery.

- [Google client](https://github.com/josueluna/linkedin_to_sheets/blob/main/src/lib/google.ts): api adapter · Encapsulates Google OAuth plus Sheets and Drive API interactions. · `src/lib/google.ts`
- **Sheets write**: api boundary · Appends profile rows into the selected Google Sheet tab.
- **Drive lookup**: api boundary · Lists or discovers available spreadsheets for selection.
- **Google OAuth**: auth flow · Handles user authorization for Google APIs.

### Build & docs

Bundle configuration, manifest, and standalone documentation pages.

- [Manifest](https://github.com/josueluna/linkedin_to_sheets/blob/main/public/manifest.json): mv3 config · Defines extension permissions, entry points, and runtime wiring. · `public/manifest.json`
- [Vite config](https://github.com/josueluna/linkedin_to_sheets/blob/main/vite.config.ts): build config · Build configuration for the extension UI bundle. · `vite.config.ts`
- [Tailwind styles](https://github.com/josueluna/linkedin_to_sheets/blob/main/tailwind.config.ts): style config · Styling pipeline for the popup and related UI. · `tailwind.config.ts`
- [Docs pages](https://github.com/josueluna/linkedin_to_sheets/blob/main/privacy.html): static pages · Standalone privacy and wiki pages outside the main extension flow. · `privacy.html`

## Connections

- UI mount → Extension popup: mounts · Bootstraps the popup experience into the UI shell.
- Popup app → Spreadsheet selector: uses · Renders destination selection inside the popup workflow.
- Extension popup → Background worker: sends actions · Requests auth, selection, and save operations.
- Content script → Profile data: extracts · Reads the LinkedIn profile DOM and builds structured data.
- Content script → Background worker: posts data · Hands extracted profile data to extension-side logic.
- Background worker → Local storage: reads/writes · Persists selections and local state needed for dedupe and resume.
- Background worker → Google client: delegates · Routes privileged Google operations through the API adapter.
- Google client → Google OAuth: authenticates · Obtains or refreshes Google authorization.
- Google client → Drive lookup: lists · Discovers spreadsheets available to the user.
- Google client → Sheets write: writes · Appends selected profile data into Sheets.
- Spreadsheet selector → Local storage: persists choice · Stores selected spreadsheet and tab locally.
- Background worker → Sheets write: dedupes before write · Uses local or remote state to avoid duplicate entries.
- Manifest → Content script: registers · Declares the content script entry point.
- Manifest → Background worker: registers · Declares the MV3 background service worker.
- Manifest → UI mount: registers · Wires the popup UI entry into the extension package.
- Vite config → Popup app: bundles · Builds the React popup application.
- Tailwind styles → Extension popup: styles · Provides the UI styling system for the popup.
- Docs pages → Manifest: separate surface · Documentation and policy pages live outside the runtime path.
