# mun2ddd/baanright-mfu-housing-demo- architecture

> Architecture diagram of the GitHub repository mun2ddd/baanright-mfu-housing-demo-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mun2ddd/baanright-mfu-housing-demo-
- Repository: https://github.com/mun2ddd/baanright-mfu-housing-demo-

## Overview

Baan Buddy is a Chrome extension for translating Thai rental listings and organizing useful listing details. Users can submit selected text from a page through a floating button or the browser context menu; the background worker stores it for the popup, which translates and analyzes the listing. The popup also provides saved listings, search alerts, and Thai reply templates. The source excerpts establish selection dispatch, pending-text handoff, and local persistence; translation-service wiring and some popup behavior are not shown in the excerpts, so those links are marked unverified or omitted.

Main entry points: [`popup.js`](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js) (Popup interface), [`background.js`](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/background.js) (Background handoff), [`content.js`](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/content.js) (Page selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Text capture"]
  node_page_selection["Page selection<br/>[content.js]"]
  node_context_menu["Context menu<br/>[background.js]"]
  node_background_handoff["Background handoff<br/>[background.js]"]
end

subgraph group_listing["Listing workflow"]
  node_popup["Popup interface<br/>[popup.js]"]
  node_listing_analysis["Translate and analyze<br/>[popup.js]"]
end

subgraph group_organize["Listing tools"]
  node_local_storage[("Extension storage")]
  node_saved_listings["Saved listings<br/>[popup.js]"]
  node_search_alerts["Search alerts<br/>[popup.js]"]
  node_reply_templates["Thai reply generator<br/>[popup.js]"]
end

node_user(("User"))
node_translation_service["MyMemory API"]

node_user -->|"selects text"| node_page_selection
node_page_selection -->|"sends message"| node_background_handoff
node_user -->|"chooses selection"| node_context_menu
node_context_menu -->|"handles selection"| node_background_handoff
node_background_handoff -->|"stores pending text"| node_local_storage
node_background_handoff -->|"opens popup"| node_popup
node_popup -->|"reads and clears pending text"| node_local_storage
node_popup -->|"runs listing workflow"| node_listing_analysis
node_listing_analysis -.->|"translates text"| node_translation_service
node_popup -->|"saves and renders"| node_saved_listings
node_saved_listings -->|"reads and writes listings"| node_local_storage
node_popup -->|"manages alerts"| node_search_alerts
node_search_alerts -->|"reads and writes alerts"| node_local_storage
node_popup -->|"generates replies"| node_reply_templates

click node_page_selection "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/content.js"
click node_context_menu "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/background.js"
click node_background_handoff "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/background.js"
click node_popup "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js"
click node_listing_analysis "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js"
click node_saved_listings "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js"
click node_search_alerts "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js"
click node_reply_templates "https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js"

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_page_selection,node_context_menu,node_background_handoff,node_user toneBlue
class node_popup,node_listing_analysis toneAmber
class node_local_storage,node_saved_listings,node_search_alerts,node_reply_templates,node_translation_service toneMint
```

## Components

### Text capture

- [Page selection](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/content.js): `content.js`
- [Context menu](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/background.js): `background.js`
- [Background handoff](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/background.js): `background.js`

### Listing workflow

- [Popup interface](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js): `popup.js`
- [Translate and analyze](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js): `popup.js`

### Listing tools

- **Extension storage**
- [Saved listings](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js): `popup.js`
- [Search alerts](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js): `popup.js`
- [Thai reply generator](https://github.com/mun2ddd/baanright-mfu-housing-demo-/blob/main/popup.js): `popup.js`

### Other components

- **User**
- **MyMemory API**

## Connections

- User → Page selection: selects text (evidence: `content.js`)
- Page selection → Background handoff: sends message (evidence: `content.js`)
- User → Context menu: chooses selection (evidence: `background.js`)
- Context menu → Background handoff: handles selection (evidence: `background.js`)
- Background handoff → Extension storage: stores pending text (evidence: `background.js`)
- Background handoff → Popup interface: opens popup (evidence: `background.js`)
- Popup interface → Extension storage: reads and clears pending text (evidence: `popup.js`)
- Popup interface → Translate and analyze: runs listing workflow (evidence: `popup.js`)
- Translate and analyze → MyMemory API: translates text
- Popup interface → Saved listings: saves and renders (evidence: `popup.js`)
- Saved listings → Extension storage: reads and writes listings (evidence: `popup.js`)
- Popup interface → Search alerts: manages alerts (evidence: `popup.js`)
- Search alerts → Extension storage: reads and writes alerts (evidence: `popup.js`)
- Popup interface → Thai reply generator: generates replies (evidence: `popup.js`)
