# junyi-99/chatgpt-api-scanner architecture

> Architecture diagram of the GitHub repository junyi-99/chatgpt-api-scanner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/junyi-99/chatgpt-api-scanner
- Repository: https://github.com/junyi-99/chatgpt-api-scanner

## Overview

This is a command-line security-research tool that searches GitHub code for candidate OpenAI API keys, checks candidates against OpenAI, and stores their statuses in SQLite. The main workflow is coordinated by the scanner in `src/main.py`; it also supports login cookies, resumable scans, rechecking stored keys, and deduplication. The README documents configurable keywords and languages and an existing-keys-only mode. Some source excerpts are partial, so the graph omits uncertain internal wiring and represents documented capabilities only where their owning module is supported.

Main entry points: [`src/main.py`](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py) (Scan coordinator), [`src/utils.py`](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/utils.py) (Key validation), [`src/manager.py`](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py) (Database manager), [`main.py`](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/main.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Scan workflow"]
  node_entry["CLI entry<br/>[main.py]"]
  node_scanner["Scan coordinator<br/>[main.py]"]
  node_config["Search patterns<br/>[configs.py]"]
  node_search["GitHub search<br/>[main.py]"]
  node_extract["Key extraction<br/>[main.py]"]
  node_expand["Result expansion<br/>[main.py]"]
  node_validate["Key validation<br/>[utils.py]"]
  node_recheck["Stored-key checks<br/>[main.py]"]
end

subgraph group_state["Session and storage"]
  node_cookies["Cookie manager<br/>[manager.py]"]
  node_progress["Progress manager<br/>[manager.py]"]
  node_dbmanager["Database manager<br/>[manager.py]"]
  node_database[("Results database<br/>[github.db]")]
end

subgraph group_integrations["External services"]
  node_browser["Chrome browser"]
  node_github["GitHub"]
  node_openai["OpenAI API"]
end

node_user(("Researcher"))

node_user -->|"runs"| node_entry
node_entry -->|"launches"| node_scanner
node_scanner -->|"reads patterns"| node_config
node_scanner -->|"runs scan"| node_search
node_search -->|"drives"| node_browser
node_browser -->|"searches"| node_github
node_search -->|"parses results"| node_extract
node_extract -->|"requests details"| node_expand
node_expand -->|"opens results"| node_browser
node_scanner -->|"manages login"| node_cookies
node_cookies -->|"sets cookies"| node_browser
node_scanner -->|"loads and saves"| node_progress
node_scanner -->|"checks candidates"| node_validate
node_recheck -->|"checks stored keys"| node_validate
node_validate -->|"tests key"| node_openai
node_scanner -->|"updates statuses"| node_recheck
node_scanner -->|"reads and writes"| node_dbmanager
node_recheck -->|"reads and updates"| node_dbmanager
node_dbmanager -->|"queries and stores"| node_database

click node_entry "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/main.py"
click node_scanner "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py"
click node_config "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/configs.py"
click node_search "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py"
click node_extract "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py"
click node_expand "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py"
click node_validate "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/utils.py"
click node_recheck "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py"
click node_cookies "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py"
click node_progress "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py"
click node_dbmanager "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py"
click node_database "https://github.com/junyi-99/chatgpt-api-scanner/blob/main/github.db"

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_entry,node_scanner,node_config,node_search,node_extract,node_expand,node_validate,node_recheck toneBlue
class node_cookies,node_progress,node_dbmanager,node_database toneAmber
class node_browser,node_github,node_openai toneMint
class node_user toneIndigo
```

## Components

### Scan workflow

- [CLI entry](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/main.py): `main.py`
- [Scan coordinator](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py): `src/main.py`
- [Search patterns](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/configs.py): `src/configs.py`
- [GitHub search](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py): `src/main.py`
- [Key extraction](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py): `src/main.py`
- [Result expansion](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py): `src/main.py`
- [Key validation](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/utils.py): `src/utils.py`
- [Stored-key checks](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/main.py): `src/main.py`

### Session and storage

- [Cookie manager](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py): `src/manager.py`
- [Progress manager](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py): `src/manager.py`
- [Database manager](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/src/manager.py): `src/manager.py`
- [Results database](https://github.com/junyi-99/chatgpt-api-scanner/blob/main/github.db): `github.db`

### External services

- **Chrome browser**
- **GitHub**
- **OpenAI API**

### Other components

- **Researcher**

## Connections

- Researcher → CLI entry: runs
- CLI entry → Scan coordinator: launches
- Scan coordinator → Search patterns: reads patterns
- Scan coordinator → GitHub search: runs scan
- GitHub search → Chrome browser: drives
- Chrome browser → GitHub: searches
- GitHub search → Key extraction: parses results
- Key extraction → Result expansion: requests details
- Result expansion → Chrome browser: opens results
- Scan coordinator → Cookie manager: manages login
- Cookie manager → Chrome browser: sets cookies
- Scan coordinator → Progress manager: loads and saves
- Scan coordinator → Key validation: checks candidates
- Stored-key checks → Key validation: checks stored keys
- Key validation → OpenAI API: tests key
- Scan coordinator → Stored-key checks: updates statuses
- Scan coordinator → Database manager: reads and writes
- Stored-key checks → Database manager: reads and updates
- Database manager → Results database: queries and stores
