How developertirth/netrabrowser works
1. Project type and runtime
- NetraBrowser is an Electron desktop application written in JavaScript.
- It has the standard Electron split: a main process, a renderer UI, and a webview-specific preload layer for content running inside the embedded browser surface.
2. Primary architecture
- The app is organized around a control plane in the Electron main process and a visual browser surface in a webview.
- The renderer is the user-facing control panel where goals, settings, and agent state are shown.
- The webview hosts the actual target website that the agent observes and manipulates.
3. Main process boundary
- src/main.js is the central orchestration layer.
- In an Electron app like this, the main process typically owns window creation, lifecycle, IPC routing, and privileged browser control.
- This is the boundary where browser automation, security-sensitive actions, and model-provider coordination are most likely concentrated.
4. Renderer boundary
- src/renderer/index.html, src/renderer/renderer.js, and src/renderer/index.css make up the UI layer.
- This layer is responsible for the visible application shell: user input, status display, settings, and the “agent HUD” described in the README.
- It should be treated as presentation-only relative to the browser automation engine.
5. Webview boundary
- src/webview/preload-webview.js indicates a separate preload script for content inside the embedded browsing context.
- This is the natural place for page-side instrumentation: injecting overlays, collecting viewport state, and mediating interactions with the target site.
- The webview is the closest layer to the actual webpage and is distinct from the app renderer.
6. IPC as the main data channel
- The key internal communication path is IPC between renderer, main process, and webview.
- User goals and UI actions originate in the renderer, are forwarded to the main process, and then become browser actions or page instrumentation in the webview.
- Results, screenshots, and agent state flow back in the opposite direction for display and next-step decisions.
7. Browser automation model
- The README describes a vision-driven agent loop rather than DOM-selector-based automation.
- The browser captures the page visually, overlays Netra IDs / NIDs around interactive elements, and uses those visual cues as the input to model reasoning.
- Actions are then dispatched natively through browser control, described as CDP-backed input events.
8. AI/model integration boundary
- The repository is designed for BYOM: local or cloud model providers.
- The README names Ollama for local VLMs and cloud APIs such as OpenAI, Anthropic, and Gemini.
- Architecturally, this means model calls are an external service boundary consumed by the agent loop, not by the UI directly.
9. Agent loop and state flow
- The operational cycle is: user goal → page capture/annotation → model reasoning → structured action → browser interaction → updated page state.
- The model produces an action plan, and the app applies it to the webview.
- This loop repeats until the task completes or the user interrupts it.
10. Security and privilege separation
- The Electron split is important here: the renderer should remain constrained, while the main process holds the privileged browser control path.
- The webview preload is a separate trust boundary because it runs in the target-page context and can observe or inject into that page.
- This separation is central to the architecture diagram because it shows where untrusted webpage content ends and app-controlled automation begins.
11. Packaging and build tooling
- forge.config.js indicates the app is packaged with Electron Forge.
- That matters architecturally because Forge shapes distribution, entry points, and packaging of the Electron app into a desktop binary.
- package-lock.json and package.json define the Node/Electron dependency graph and runtime setup.
12. What to show in an architecture diagram
- Draw three main zones: Renderer UI, Main Process Orchestrator, and Webview Target Browser.
- Connect them with IPC arrows in both directions.
- Add an external Model Provider box for Ollama/OpenAI/Anthropic/Gemini.
- Show the browser automation loop cycling between webview state capture, model decision-making, and native interaction dispatch.
13. Key repository takeaway
- This repo is not a generic browser clone; it is an agentic browser control system.
- The core architectural distinction is between:
- human-facing control UI,
- privileged orchestration,
- and the embedded browsing surface that is visually observed and programmatically driven.
Main entry points: main.js Main · renderer.js Renderer · preload.js App Preload · preload-webview.js Webview Preload
Components 17
Renderer UI
Human-facing control panel and HUD
- Shell HTML · App shell and layout for the control panel
src/renderer/index.html - Renderer · User-facing state, inputs, and agent HUD behavior
src/renderer/renderer.js - Styles · Presentation layer for the control panel
src/renderer/index.css
Main Process
Privileged Electron orchestration and IPC
- Main · Creates windows, routes IPC, and coordinates privileged browser actions
src/main.js - App Preload · Preload bridge for the app window boundary
src/preload.js - Action Dispatch · Applies model-selected browser actions through CDP-backed interaction
- Agent Loop · Repeats capture, reasoning, action, and state update cycles
- Model Gateway · Normalizes calls to local and cloud model providers
Webview
Embedded target-browser surface and page instrumentation
- Webview Preload · Instrumentation and interaction bridge inside the embedded browser context
src/webview/preload-webview.js - Target Page · The remote website being observed and manipulated
- Page Capture · Collects visual page state for the agent loop
- NID Overlay · Draws Netra IDs around interactive elements
External Services
Model providers consumed by the agent loop
- Ollama · Local VLM/provider option
- Cloud APIs · OpenAI, Anthropic, and Gemini provider boundary
Packaging
Electron Forge and Node packaging setup
- Electron Forge · Builds and packages the desktop application
forge.config.js - Package · Dependency and runtime configuration
package.json - Lockfile · Pinned dependency resolution
package-lock.json
Connections 20
- Shell HTML → Renderer: bootstraps · HTML loads the renderer controller
- Styles → Renderer: styles · Renderer UI styling supports the control panel
- Renderer → App Preload: ipc · Renderer sends UI events through the preload boundary
- App Preload → Main: ipc · Preload forwards controlled messages into the main process
- Main → Renderer: state · Main process returns status, results, and agent updates
- Main → Webview Preload: load · Main creates and configures the embedded browsing context
- Webview Preload → Target Page: instrument · Preload injects overlays and page instrumentation
- Target Page → Page Capture: capture · Visual page state is sampled from the target site
- Page Capture → NID Overlay: annotate · Interactive elements are marked with Netra IDs
- NID Overlay → Agent Loop: observations · Annotated state feeds the reasoning loop
- Renderer → Agent Loop: goal · User intent and settings enter the agent loop
- Agent Loop → Model Gateway: reason · The loop sends observations for model reasoning
- Model Gateway → Ollama: local · Routes to local model providers when selected
- Model Gateway → Cloud APIs: cloud · Routes to remote API providers when selected
- Model Gateway → Action Dispatch: plan · Model output is converted into a structured action
- Action Dispatch → Target Page: act · Native browser control executes the chosen action
- Target Page → Agent Loop: update · Updated page state re-enters the loop
- Main → Electron Forge: package · Main entry is packaged into the desktop app
- Package → Main: runtime · Manifest defines the Electron/Node runtime entrypoints
- Lockfile → Package: pins · Lockfile constrains dependency versions