# nhatduy288/facebook-tool architecture

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

- Interactive diagram: https://gitdiagram.com/nhatduy288/facebook-tool
- Repository: https://github.com/nhatduy288/facebook-tool

## Overview

Facebook Tool is a local web application for monitoring a configured Facebook profile or Page and optionally liking, sharing, and commenting on new posts. The operator configures the tool and logs in, establishes a three-post baseline, then the engine repeatedly reads and verifies posts, suppresses duplicates, creates jobs, and runs enabled actions; uncertain submissions require reconciliation rather than automatic retry. The graph covers the documented workflow and major subsystems. Some internal links rely on the SOURCE INDEX or README because the relevant source was not excerpted.

Main entry points: [`src/main.ts`](https://github.com/nhatduy288/facebook-tool/blob/main/src/main.ts) (Local server), [`src/facebook/actions.ts`](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/actions.ts) (Action adapter), [`src/facebook/reader.ts`](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/reader.ts) (Feed reader), [`src/engine.ts`](https://github.com/nhatduy288/facebook-tool/blob/main/src/engine.ts) (Workflow engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Local application"]
  node_webui["Web interface<br/>[app.js]"]
  node_server["Local server<br/>[main.ts]"]
  node_engine["Workflow engine<br/>[engine.ts]"]
  node_browser["Browser session<br/>[browser.ts]"]
end

subgraph group_reading["Feed reading"]
  node_reader["Feed reader<br/>[reader.ts]"]
  node_feedwindow["Window verification"]
  node_capture["Query capture<br/>[capture.ts]"]
  node_queryparser["Response parser<br/>[query-parser.mjs]"]
  node_windowparser["Window parser<br/>[window-parser.mjs]"]
  node_observed["Observed query store"]
  node_target["Source targets<br/>[read-target.ts]"]
end

subgraph group_actions["Post actions"]
  node_actions["Action adapter<br/>[actions.ts]"]
  node_confirmation["Action confirmation<br/>[confirmation.ts]"]
  node_shareverify["Share verification"]
  node_postloading["Post loading<br/>[post-loading.ts]"]
end

subgraph group_state["Configuration and state"]
  node_config["Configuration<br/>[config.ts]"]
  node_store[("SQLite state<br/>[store.ts]")]
end

node_operator(("Operator"))
node_facebook["Facebook"]

node_operator -->|"configures and controls"| node_webui
node_webui -->|"calls local API"| node_server
node_server -->|"creates session"| node_browser
node_server -->|"creates reader"| node_reader
node_server -->|"creates adapter"| node_actions
node_server -->|"creates engine"| node_engine
node_server -->|"opens database"| node_store
node_server -->|"serves assets"| node_webui
node_engine -->|"loads configuration and records jobs"| node_store
node_engine -->|"reads feed"| node_reader
node_engine -->|"runs enabled actions"| node_actions
node_reader -->|"uses browser session"| node_browser
node_reader -->|"validates source"| node_target
node_reader -->|"reads verified window"| node_feedwindow
node_feedwindow -->|"uses captured query"| node_capture
node_feedwindow -->|"uses observed query"| node_observed
node_capture -->|"parses responses"| node_queryparser
node_capture -->|"inspects windows"| node_windowparser
node_capture -->|"checks source"| node_target
node_reader -->|"reads Facebook feed"| node_facebook
node_actions -->|"uses browser session"| node_browser
node_actions -->|"checks outcomes"| node_confirmation
node_actions -->|"verifies share audience"| node_shareverify
node_actions -->|"loads target posts"| node_postloading
node_actions -->|"submits and reconciles actions"| node_facebook
node_config -->|"selects source"| node_target
node_store -->|"validates and plans"| node_config

click node_webui "https://github.com/nhatduy288/facebook-tool/blob/main/public/app.js"
click node_server "https://github.com/nhatduy288/facebook-tool/blob/main/src/main.ts"
click node_engine "https://github.com/nhatduy288/facebook-tool/blob/main/src/engine.ts"
click node_browser "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/browser.ts"
click node_reader "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/reader.ts"
click node_feedwindow "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/read-complete-window.ts"
click node_capture "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/capture.ts"
click node_queryparser "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/query-parser.mjs"
click node_windowparser "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/window-parser.mjs"
click node_observed "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/observed-query-store.ts"
click node_target "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/read-target.ts"
click node_actions "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/actions.ts"
click node_confirmation "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/confirmation.ts"
click node_shareverify "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/share-verification.ts"
click node_postloading "https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/post-loading.ts"
click node_config "https://github.com/nhatduy288/facebook-tool/blob/main/src/config.ts"
click node_store "https://github.com/nhatduy288/facebook-tool/blob/main/src/store.ts"

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_webui,node_server,node_engine,node_browser toneBlue
class node_reader,node_feedwindow,node_capture,node_queryparser,node_windowparser,node_observed,node_target toneAmber
class node_actions,node_confirmation,node_shareverify,node_postloading toneMint
class node_config,node_store toneRose
class node_operator,node_facebook toneIndigo
```

## Components

### Local application

- [Web interface](https://github.com/nhatduy288/facebook-tool/blob/main/public/app.js): `public/app.js`
- [Local server](https://github.com/nhatduy288/facebook-tool/blob/main/src/main.ts): `src/main.ts`
- [Workflow engine](https://github.com/nhatduy288/facebook-tool/blob/main/src/engine.ts): `src/engine.ts`
- [Browser session](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/browser.ts): `src/facebook/browser.ts`

### Feed reading

- [Feed reader](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/reader.ts): `src/facebook/reader.ts`
- [Window verification](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/read-complete-window.ts): `src/facebook/feed/read-complete-window.ts`
- [Query capture](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/capture.ts): `src/facebook/feed/capture.ts`
- [Response parser](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/query-parser.mjs): `src/facebook/feed/query-parser.mjs`
- [Window parser](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/window-parser.mjs): `src/facebook/feed/window-parser.mjs`
- [Observed query store](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/observed-query-store.ts): `src/facebook/feed/observed-query-store.ts`
- [Source targets](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/feed/read-target.ts): `src/facebook/feed/read-target.ts`

### Post actions

- [Action adapter](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/actions.ts): `src/facebook/actions.ts`
- [Action confirmation](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/confirmation.ts): `src/facebook/confirmation.ts`
- [Share verification](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/share-verification.ts): `src/facebook/share-verification.ts`
- [Post loading](https://github.com/nhatduy288/facebook-tool/blob/main/src/facebook/post-loading.ts): `src/facebook/post-loading.ts`

### Configuration and state

- [Configuration](https://github.com/nhatduy288/facebook-tool/blob/main/src/config.ts): `src/config.ts`
- [SQLite state](https://github.com/nhatduy288/facebook-tool/blob/main/src/store.ts): `src/store.ts`

### Other components

- **Operator**
- **Facebook**

## Connections

- Operator → Web interface: configures and controls (evidence: `README.md`)
- Web interface → Local server: calls local API (evidence: `README.md`)
- Local server → Browser session: creates session (evidence: `src/main.ts`)
- Local server → Feed reader: creates reader (evidence: `src/main.ts`)
- Local server → Action adapter: creates adapter (evidence: `src/main.ts`)
- Local server → Workflow engine: creates engine (evidence: `src/main.ts`)
- Local server → SQLite state: opens database (evidence: `src/main.ts`)
- Local server → Web interface: serves assets (evidence: `src/main.ts`)
- Workflow engine → SQLite state: loads configuration and records jobs (evidence: `src/engine.ts`)
- Workflow engine → Feed reader: reads feed (evidence: `README.md`)
- Workflow engine → Action adapter: runs enabled actions (evidence: `README.md`)
- Feed reader → Browser session: uses browser session (evidence: `src/facebook/reader.ts`)
- Feed reader → Source targets: validates source (evidence: `src/facebook/reader.ts`)
- Feed reader → Window verification: reads verified window (evidence: `src/facebook/reader.ts`)
- Window verification → Query capture: uses captured query (evidence: `src/facebook/feed/read-complete-window.ts`)
- Window verification → Observed query store: uses observed query (evidence: `src/facebook/feed/read-complete-window.ts`)
- Query capture → Response parser: parses responses (evidence: `src/facebook/feed/capture.ts`)
- Query capture → Window parser: inspects windows (evidence: `src/facebook/feed/capture.ts`)
- Query capture → Source targets: checks source (evidence: `src/facebook/feed/capture.ts`)
- Feed reader → Facebook: reads Facebook feed (evidence: `README.md`)
- Action adapter → Browser session: uses browser session (evidence: `src/facebook/actions.ts`)
- Action adapter → Action confirmation: checks outcomes (evidence: `src/facebook/actions.ts`)
- Action adapter → Share verification: verifies share audience (evidence: `src/facebook/actions.ts`)
- Action adapter → Post loading: loads target posts (evidence: `src/facebook/actions.ts`)
- Action adapter → Facebook: submits and reconciles actions (evidence: `README.md`)
- Configuration → Source targets: selects source (evidence: `src/config.ts`)
- SQLite state → Configuration: validates and plans (evidence: `src/store.ts`)
