# mehedieh/railway-booking-helper architecture

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

- Interactive diagram: https://gitdiagram.com/mehedieh/railway-booking-helper
- Repository: https://github.com/mehedieh/railway-booking-helper

## Overview

This MV3 Chrome extension helps a user search Bangladesh Railway’s e-ticket site and automate train, class, coach, and seat selection. The workflow starts in the popup, where booking preferences are saved locally; the user opens or fills the search page, then starts an immediate or scheduled run. The page flow retries train results, selects seats, and in live mode continues purchase before stopping at the OTP handoff. It avoids login, CAPTCHA, OTP entry, and payment. The graph reflects shown code and README claims; some flow details come from partial excerpts.

Main entry points: [`overlay.js`](https://github.com/mehedieh/railway-booking-helper/blob/main/overlay.js) (Status Overlay), [`popup.js`](https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js) (Booking Controls), [`flow.js`](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js) (Run Scheduler), [`selectors.js`](https://github.com/mehedieh/railway-booking-helper/blob/main/selectors.js) (Site Selectors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_popup["Popup and Settings"]
  node_popupui["Booking Controls<br/>[popup.js]"]
  node_savedbooking[("Saved Preferences<br/>[popup.js]")]
  node_searchurl["Search Page Link<br/>[popup.js]"]
end

subgraph group_page["Railway Page Workflow"]
  node_formfill["Search Form Fill<br/>[content.js]"]
  node_router["Page Message Router<br/>[content.js]"]
  node_scheduler["Run Scheduler<br/>[flow.js]"]
  node_trainmatch["Train and Class Match<br/>[flow.js]"]
  node_coachpick["Coach Selection<br/>[flow.js]"]
  node_seatpick["Seat Selection<br/>[flow.js]"]
  node_purchase["Purchase Continue<br/>[flow.js]"]
  node_otphandoff["OTP Handoff<br/>[flow.js]"]
end

subgraph group_support["Page Support"]
  node_selectors["Site Selectors<br/>[selectors.js]"]
  node_utils["Shared Utilities<br/>[utils.js]"]
  node_status["Status Overlay<br/>[overlay.js]"]
end

subgraph group_alerts["Alerts and Browser"]
  node_background["Notification Handler<br/>[background.js]"]
end

node_user(("User"))
node_railway["Railway E-ticket Site"]
node_chrome["Chrome APIs"]

node_user -->|"sets preferences"| node_popupui
node_popupui -->|"saves settings"| node_savedbooking
node_popupui -->|"opens search"| node_searchurl
node_searchurl -->|"creates tab"| node_chrome
node_popupui -->|"sends commands"| node_router
node_popupui -->|"reads and writes"| node_chrome
node_router -->|"runs form fill"| node_formfill
node_router -->|"starts or schedules"| node_scheduler
node_router -->|"stops run"| node_scheduler
node_formfill -->|"fills search fields"| node_railway
node_scheduler -->|"starts booking flow"| node_trainmatch
node_trainmatch -->|"reads results"| node_railway
node_coachpick -->|"selects coach"| node_railway
node_seatpick -->|"selects seats"| node_railway
node_purchase -->|"continues purchase"| node_railway
node_otphandoff -->|"watches OTP screen"| node_railway
node_scheduler -->|"updates status"| node_status
node_trainmatch -->|"reports progress"| node_status
node_coachpick -->|"reports progress"| node_status
node_seatpick -->|"reports progress"| node_status
node_purchase -->|"reports progress"| node_status
node_otphandoff -->|"alerts user"| node_status
node_status -->|"sends notification"| node_background
node_background -->|"creates notification"| node_chrome
node_background -->|"focuses tab"| node_chrome
node_formfill -->|"uses selectors"| node_selectors
node_trainmatch -->|"uses selectors"| node_selectors
node_coachpick -->|"uses selectors"| node_selectors
node_seatpick -->|"uses selectors"| node_selectors
node_otphandoff -->|"checks OTP selectors"| node_selectors
node_formfill -->|"formats and waits"| node_utils
node_scheduler -->|"formats countdown"| node_utils

click node_popupui "https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js"
click node_savedbooking "https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js"
click node_searchurl "https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js"
click node_formfill "https://github.com/mehedieh/railway-booking-helper/blob/main/content.js"
click node_router "https://github.com/mehedieh/railway-booking-helper/blob/main/content.js"
click node_scheduler "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_trainmatch "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_coachpick "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_seatpick "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_purchase "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_otphandoff "https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js"
click node_selectors "https://github.com/mehedieh/railway-booking-helper/blob/main/selectors.js"
click node_utils "https://github.com/mehedieh/railway-booking-helper/blob/main/utils.js"
click node_status "https://github.com/mehedieh/railway-booking-helper/blob/main/overlay.js"
click node_background "https://github.com/mehedieh/railway-booking-helper/blob/main/background.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_popupui,node_savedbooking,node_searchurl,node_user toneBlue
class node_formfill,node_router,node_scheduler,node_trainmatch,node_coachpick,node_seatpick,node_purchase,node_otphandoff toneAmber
class node_selectors,node_utils,node_status,node_chrome toneMint
class node_background toneRose
class node_railway toneIndigo
```

## Components

### Popup and Settings

- [Booking Controls](https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js): `popup.js`
- [Saved Preferences](https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js): `popup.js`
- [Search Page Link](https://github.com/mehedieh/railway-booking-helper/blob/main/popup.js): `popup.js`

### Railway Page Workflow

- [Search Form Fill](https://github.com/mehedieh/railway-booking-helper/blob/main/content.js): `content.js`
- [Page Message Router](https://github.com/mehedieh/railway-booking-helper/blob/main/content.js): `content.js`
- [Run Scheduler](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`
- [Train and Class Match](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`
- [Coach Selection](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`
- [Seat Selection](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`
- [Purchase Continue](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`
- [OTP Handoff](https://github.com/mehedieh/railway-booking-helper/blob/main/flow.js): `flow.js`

### Page Support

- [Site Selectors](https://github.com/mehedieh/railway-booking-helper/blob/main/selectors.js): `selectors.js`
- [Shared Utilities](https://github.com/mehedieh/railway-booking-helper/blob/main/utils.js): `utils.js`
- [Status Overlay](https://github.com/mehedieh/railway-booking-helper/blob/main/overlay.js): `overlay.js`

### Alerts and Browser

- [Notification Handler](https://github.com/mehedieh/railway-booking-helper/blob/main/background.js): `background.js`

### Other components

- **User**
- **Railway E-ticket Site**
- **Chrome APIs**

## Connections

- User → Booking Controls: sets preferences (evidence: `popup.js`)
- Booking Controls → Saved Preferences: saves settings (evidence: `popup.js`)
- Booking Controls → Search Page Link: opens search (evidence: `popup.js`)
- Search Page Link → Chrome APIs: creates tab (evidence: `popup.js`)
- Booking Controls → Page Message Router: sends commands (evidence: `popup.js`)
- Booking Controls → Chrome APIs: reads and writes (evidence: `popup.js`)
- Page Message Router → Search Form Fill: runs form fill (evidence: `content.js`)
- Page Message Router → Run Scheduler: starts or schedules (evidence: `content.js`)
- Page Message Router → Run Scheduler: stops run (evidence: `content.js`)
- Search Form Fill → Railway E-ticket Site: fills search fields (evidence: `content.js`)
- Run Scheduler → Train and Class Match: starts booking flow (evidence: `flow.js`)
- Train and Class Match → Railway E-ticket Site: reads results (evidence: `flow.js`)
- Coach Selection → Railway E-ticket Site: selects coach (evidence: `flow.js`)
- Seat Selection → Railway E-ticket Site: selects seats (evidence: `flow.js`)
- Purchase Continue → Railway E-ticket Site: continues purchase (evidence: `flow.js`)
- OTP Handoff → Railway E-ticket Site: watches OTP screen (evidence: `flow.js`)
- Run Scheduler → Status Overlay: updates status (evidence: `flow.js`)
- Train and Class Match → Status Overlay: reports progress (evidence: `flow.js`)
- Coach Selection → Status Overlay: reports progress (evidence: `flow.js`)
- Seat Selection → Status Overlay: reports progress (evidence: `flow.js`)
- Purchase Continue → Status Overlay: reports progress (evidence: `flow.js`)
- OTP Handoff → Status Overlay: alerts user (evidence: `flow.js`)
- Status Overlay → Notification Handler: sends notification (evidence: `overlay.js`)
- Notification Handler → Chrome APIs: creates notification (evidence: `background.js`)
- Notification Handler → Chrome APIs: focuses tab (evidence: `background.js`)
- Search Form Fill → Site Selectors: uses selectors (evidence: `content.js`)
- Train and Class Match → Site Selectors: uses selectors (evidence: `flow.js`)
- Coach Selection → Site Selectors: uses selectors (evidence: `flow.js`)
- Seat Selection → Site Selectors: uses selectors (evidence: `flow.js`)
- OTP Handoff → Site Selectors: checks OTP selectors (evidence: `flow.js`)
- Search Form Fill → Shared Utilities: formats and waits (evidence: `content.js`)
- Run Scheduler → Shared Utilities: formats countdown (evidence: `flow.js`)
