# priezz/linkedin-email-extractor architecture

> Architecture diagram of the GitHub repository priezz/linkedin-email-extractor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priezz/linkedin-email-extractor
- Repository: https://github.com/priezz/linkedin-email-extractor

## Overview

##### Project type and purpose
- This is a Node.js command-line tool (a backend-only “script” application), whose sole purpose is to read your LinkedIn connections CSV, log into LinkedIn in a headless browser, scrape each contact’s page for their email address, and update the CSV in place.

##### File structure
- Top-level files only:
- index.js – the entire orchestration (CLI prompts, CSV I/O, browser automation, scraping logic).
- package.json – lists dependencies (likely Puppeteer or a request/cheerio combo, a CSV parser, readline or inquirer for prompts).
- README.md – usage instructions.
- .gitignore – standard ignores (node_modules, .env if any).
- There are no multi-service components or front-end artifacts—this is a single Node process.

##### README for additional insights
- The README explains:
- You supply “Connections.csv” exported from LinkedIn.
- It prompts for your LinkedIn credentials.
- It asks which UI version (“old” vs “new”) you have.
- It then cycles through contacts, scraping with DOM selectors that may differ by UI version, and updates the CSV row-by-row.
- It warns about rate-limiting and the need to restart the script manually.

- CLI Interface Module
– Reads Connections.csv (File System)
– Prompts for credentials & UI version
- Scraper Module
– Launches headless browser (Puppeteer or similar)
– Navigates to LinkedIn, logs in
– Iterates through each profile page
– Applies version-specific DOM selectors
- Data Processor / CSV Module
– Parses CSV, appends/updates rows with discovered emails
– Writes back to Connections.csv
- External Service
– LinkedIn (the web application endpoint)
b. Relationships and data flows
1. User invokes `yarn start` → CLI Module
2. CLI reads Connections.csv → sends list of profile URLs to Scraper Module
3. Scraper Module ↔ LinkedIn over HTTP/HTTPS via headless browser
4. Scraper returns parsed email data → Data Processor Module
5. Data Processor writes updated rows → Connections.csv
c. Architectural patterns / design principles
- Single-process, event-driven Node.js application.
- Separation of concerns:
- CLI & user prompts
- Browser automation & scraping logic
- CSV parsing & file I/O
- Runtime branching based on UI version for selector differences.
d. Key technologies & libraries
- Node.js (v10+ implied)
- Puppeteer (or request + cheerio, depending on package.json)
- csv-parse / csv-stringify (or similar)
- readline or inquirer for interactive prompts
- fs module for file I/O

##### Detail
- Error-handling or restart loop as a note: “On rate-limit, restart script.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    Start["User: yarn start"]:::io
    CLI["CLI Interface Module"]:::process
    Scraper["Scraper Module<br/>(UI Version Branch)"]:::process
    CSVProcessor["Data Processor (CSV) Module"]:::process
    CSVFile["Connections.csv"]:::io
    LinkedIn["LinkedIn Web"]:::external

    Start -->|invokes| CLI
    CLI -->|reads| CSVFile
    CLI -->|sends URLs| Scraper
    Scraper -->|HTTP| LinkedIn
    LinkedIn -->|page HTML| Scraper
    Scraper -->|extracted emails| CSVProcessor
    CSVProcessor -->|writes| CSVFile

    subgraph "Project Files"
      Package["package.json"]:::io
      Readme["README.md"]:::io
      Gitignore[".gitignore"]:::io
    end

    click CLI "https://github.com/priezz/linkedin-email-extractor/blob/master/index.js"
    click Scraper "https://github.com/priezz/linkedin-email-extractor/blob/master/index.js"
    click CSVProcessor "https://github.com/priezz/linkedin-email-extractor/blob/master/index.js"
    click Package "https://github.com/priezz/linkedin-email-extractor/blob/master/package.json"
    click Readme "https://github.com/priezz/linkedin-email-extractor/blob/master/README.md"
    click Gitignore "https://github.com/priezz/linkedin-email-extractor/blob/master/.gitignore"

    classDef io fill:#e0f7fa,stroke:#006064,stroke-width:1px;
    classDef process fill:#fff3e0,stroke:#e65100,stroke-width:1px;
    classDef external fill:#e8f5e9,stroke:#1b5e20,stroke-width:1px;
```
