# jcalhinho/dacti architecture

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

- Interactive diagram: https://gitdiagram.com/jcalhinho/dacti
- Repository: https://github.com/jcalhinho/dacti

## Overview

DACTI is a Chrome extension for text assistance. A user selects page text (or uses page context) and triggers a task through the toolbar, context menu, or shortcut; the background worker coordinates the task and updates the floating panel. Task modules prefer Chrome’s local AI APIs and can fall back to cloud generation, with optional PII masking and session caching. The graph follows documented flows and shown calls; some panel-to-worker task wiring and unsampled task implementations are represented only where README or the source index supports them.

Main entry points: [`src/background/index.ts`](https://github.com/jcalhinho/dacti/blob/main/src/background/index.ts) (Background worker), [`src/shared/ai/gemini-api.ts`](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/gemini-api.ts) (Cloud API client), [`src/content/events.ts`](https://github.com/jcalhinho/dacti/blob/main/src/content/events.ts) (Content event bridge), [`src/content/panel.ts`](https://github.com/jcalhinho/dacti/blob/main/src/content/panel.ts) (Floating panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Extension interaction"]
  node_panel["Floating panel<br/>[panel.ts]"]
  node_events["Content event bridge<br/>[events.ts]"]
  node_state["Panel state<br/>[globals.ts]"]
  node_render["Markdown renderer<br/>[utils.ts]"]
end

subgraph group_orchestration["Task coordination"]
  node_background["Background worker<br/>[index.ts]"]
  node_session[("Session cache")]
end

subgraph group_tasks["AI capabilities"]
  node_summarize["Summarization<br/>[summarizer.ts]"]
  node_translate["Translation<br/>[translator.ts]"]
  node_rewrite["Rewriting<br/>[rewriter.ts]"]
  node_write["Writing<br/>[writer.ts]"]
  node_proofread["Proofreading<br/>[proofreader.ts]"]
  node_mask["PII masking<br/>[mask.ts]"]
end

subgraph group_providers["AI execution"]
  node_localai["Chrome local AI"]
  node_gemini["Cloud API client<br/>[gemini-api.ts]"]
end

node_user(("User"))
node_chrome["Chrome APIs"]
node_page["Page context"]
node_proxy["Cloud proxy"]
node_geminiservice["Gemini REST API"]

node_user -->|"opens"| node_panel
node_user -->|"triggers task"| node_background
node_page -->|"provides context"| node_background
node_background -->|"updates progress"| node_panel
node_panel -->|"cancels task"| node_background
node_background -->|"reads and writes"| node_session
node_background -->|"summarizes"| node_summarize
node_background -->|"translates"| node_translate
node_background -->|"rewrites"| node_rewrite
node_background -->|"generates text"| node_write
node_background -->|"proofreads"| node_proofread
node_background -->|"requests local task"| node_events
node_events -->|"runs local AI"| node_localai
node_events -->|"updates"| node_state
node_panel -->|"uses"| node_state
node_panel -->|"renders output"| node_render
node_events -->|"renders output"| node_render
node_events -->|"masks PII"| node_mask
node_background -->|"masks PII"| node_mask
node_summarize -->|"tries local"| node_localai
node_translate -->|"tries local"| node_localai
node_rewrite -.->|"tries local"| node_localai
node_write -->|"tries local"| node_localai
node_proofread -->|"tries local"| node_localai
node_summarize -->|"falls back"| node_gemini
node_translate -->|"falls back"| node_gemini
node_rewrite -->|"falls back"| node_gemini
node_write -->|"falls back"| node_gemini
node_proofread -->|"falls back"| node_gemini
node_gemini -->|"sends request"| node_proxy
node_gemini -->|"sends request"| node_geminiservice
node_chrome -->|"dispatches events"| node_background

click node_background "https://github.com/jcalhinho/dacti/blob/main/src/background/index.ts"
click node_panel "https://github.com/jcalhinho/dacti/blob/main/src/content/panel.ts"
click node_events "https://github.com/jcalhinho/dacti/blob/main/src/content/events.ts"
click node_state "https://github.com/jcalhinho/dacti/blob/main/src/content/globals.ts"
click node_render "https://github.com/jcalhinho/dacti/blob/main/src/content/utils.ts"
click node_summarize "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/summarizer.ts"
click node_translate "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/translator.ts"
click node_rewrite "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/rewriter.ts"
click node_write "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/writer.ts"
click node_proofread "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/proofreader.ts"
click node_mask "https://github.com/jcalhinho/dacti/blob/main/src/shared/utils/mask.ts"
click node_gemini "https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/gemini-api.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_panel,node_events,node_state,node_render,node_user toneBlue
class node_background,node_session toneAmber
class node_summarize,node_translate,node_rewrite,node_write,node_proofread,node_mask,node_chrome,node_geminiservice toneMint
class node_localai,node_gemini toneRose
class node_page,node_proxy toneIndigo
```

## Components

### Extension interaction

- [Floating panel](https://github.com/jcalhinho/dacti/blob/main/src/content/panel.ts): `src/content/panel.ts`
- [Content event bridge](https://github.com/jcalhinho/dacti/blob/main/src/content/events.ts): `src/content/events.ts`
- [Panel state](https://github.com/jcalhinho/dacti/blob/main/src/content/globals.ts): `src/content/globals.ts`
- [Markdown renderer](https://github.com/jcalhinho/dacti/blob/main/src/content/utils.ts): `src/content/utils.ts`

### Task coordination

- [Background worker](https://github.com/jcalhinho/dacti/blob/main/src/background/index.ts): `src/background/index.ts`
- **Session cache**

### AI capabilities

- [Summarization](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/summarizer.ts): `src/shared/ai/summarizer.ts`
- [Translation](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/translator.ts): `src/shared/ai/translator.ts`
- [Rewriting](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/rewriter.ts): `src/shared/ai/rewriter.ts`
- [Writing](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/writer.ts): `src/shared/ai/writer.ts`
- [Proofreading](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/proofreader.ts): `src/shared/ai/proofreader.ts`
- [PII masking](https://github.com/jcalhinho/dacti/blob/main/src/shared/utils/mask.ts): `src/shared/utils/mask.ts`

### AI execution

- **Chrome local AI**
- [Cloud API client](https://github.com/jcalhinho/dacti/blob/main/src/shared/ai/gemini-api.ts): `src/shared/ai/gemini-api.ts`

### Other components

- **User**
- **Chrome APIs**
- **Page context**
- **Cloud proxy**
- **Gemini REST API**

## Connections

- User → Floating panel: opens (evidence: `README.md`)
- User → Background worker: triggers task (evidence: `README.md`)
- Page context → Background worker: provides context (evidence: `README.md`)
- Background worker → Floating panel: updates progress (evidence: `README.md`)
- Floating panel → Background worker: cancels task (evidence: `src/content/panel.ts`)
- Background worker → Session cache: reads and writes (evidence: `src/background/index.ts`)
- Background worker → Summarization: summarizes (evidence: `src/background/index.ts`)
- Background worker → Translation: translates (evidence: `src/background/index.ts`)
- Background worker → Rewriting: rewrites (evidence: `src/background/index.ts`)
- Background worker → Writing: generates text (evidence: `src/background/index.ts`)
- Background worker → Proofreading: proofreads (evidence: `src/background/index.ts`)
- Background worker → Content event bridge: requests local task (evidence: `src/background/index.ts`)
- Content event bridge → Chrome local AI: runs local AI (evidence: `src/content/events.ts`)
- Content event bridge → Panel state: updates (evidence: `src/content/events.ts`)
- Floating panel → Panel state: uses (evidence: `src/content/panel.ts`)
- Floating panel → Markdown renderer: renders output (evidence: `README.md`)
- Content event bridge → Markdown renderer: renders output (evidence: `README.md`)
- Content event bridge → PII masking: masks PII (evidence: `src/content/events.ts`)
- Background worker → PII masking: masks PII (evidence: `src/background/index.ts`)
- Summarization → Chrome local AI: tries local (evidence: `src/shared/ai/summarizer.ts`)
- Translation → Chrome local AI: tries local (evidence: `src/shared/ai/translator.ts`)
- Rewriting → Chrome local AI: tries local
- Writing → Chrome local AI: tries local (evidence: `README.md`)
- Proofreading → Chrome local AI: tries local (evidence: `src/shared/ai/proofreader.ts`)
- Summarization → Cloud API client: falls back (evidence: `src/shared/ai/summarizer.ts`)
- Translation → Cloud API client: falls back (evidence: `src/shared/ai/translator.ts`)
- Rewriting → Cloud API client: falls back (evidence: `src/shared/ai/rewriter.ts`)
- Writing → Cloud API client: falls back (evidence: `src/shared/ai/writer.ts`)
- Proofreading → Cloud API client: falls back (evidence: `src/shared/ai/proofreader.ts`)
- Cloud API client → Cloud proxy: sends request (evidence: `src/shared/ai/gemini-api.ts`)
- Cloud API client → Gemini REST API: sends request (evidence: `src/shared/ai/gemini-api.ts`)
- Chrome APIs → Background worker: dispatches events (evidence: `src/background/index.ts`)
