---
title: 'JavaScript and Electron app analysis · Reverse Engineer Projects'
url: https://reverseengineerprojects.com/guides/javascript/
---

[Home](https://reverseengineerprojects.com/) / [Guides](https://reverseengineerprojects.com/guides/) / JavaScript & Electron

# Follow an export to the disk.

  Desktop apps built on Electron split one feature over three places: the page, a preload bridge and the main process. REP connects them by the names they share.

## Where does “Export notes” go?

- Page → bridge
### A small API
The page can only call what the preload script exposes.

- Between processes
### A named message
The bridge sends a channel name the main process listens on.

- Main process
### The real work
The handler formats the data and writes the file.

## Ask about the export

    Use our [Notes example](https://reverseengineerprojects.com/examples/notes-example.zip) (six files) or any Electron app you may examine. Packaged apps keep their code in resources/app.asar; REP reads inside it, so there is nothing to unpack by hand.

    Your coding agentCopy

      ›Use REP to analyze the app in ./notes-example. Trace the Export notes button: the API the page calls, the IPC channel, the handler, and the file it writes. Cite files and lines.

## Trace it

### The page calls a small API

    renderer.js

```
document.querySelector('#export').addEventListener('click', async () => {
  const file = await window.notesApi.saveCsv();
  status.textContent = `Saved to ${file}`;
});
```

### The preload script turns it into a message

    preload.js

```
contextBridge.exposeInMainWorld('notesApi', {
  list: () => ipcRenderer.invoke('notes:list'),
  saveCsv: () => ipcRenderer.invoke('notes:save-csv'),
});
```

### The main process answers it

    main.js

```
ipcMain.handle('notes:save-csv', () => {
  const file = path.join(app.getPath('documents'), 'notes-export.csv');
  fs.writeFileSync(file, toCsv(notes, ['id', 'title', 'created']));
  return file;
});
```

    The channel name is the join: one invoke in the bridge, one handle in the main process. REP lists every exposed API, every channel and every handler, and pairs them, so the agent follows the feature instead of searching for words.

## From the terminal

    The same analysis runs without an agent and prints JSON you can keep:

    TerminalCopy

```
rep analyze-javascript-application ./notes-example --json
```

## Read the writer

    csv.js

```
function toCsv(rows, columns) {
  const head = columns.join(',');
  const body = rows.map((r) => columns.map((c) => cell(r[c])).join(','));
  return [head, ...body].join('\n') + '\n';
}
```

    So the file starts with id,title,created, then one line per note; a title with a comma or a quote gets wrapped in quotes by cell.

  On this page[The shape](#shape)[Ask](#ask)[Trace it](#trace)[From the terminal](#terminal)[Read the writer](#writer)
