# gb-tec/app-desktop architecture

> Architecture diagram of the GitHub repository gb-tec/app-desktop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gb-tec/app-desktop
- Repository: https://github.com/gb-tec/app-desktop

## Overview

GbSoft Desktop is an Electron fiscal-management application. Its visible workflow is opening the desktop UI, authenticating a user, managing company records, and invoking fiscal automation through a local Express service; the UI also includes FETHAB PDF processing. The excerpts show the desktop process launching the server and loading the login page, plus Firebase-backed authentication and company data access. Several HTML wiring details and automation implementations are unsampled, so only evidenced relationships are drawn; the README is empty.

Main entry points: [`main.js`](https://github.com/gb-tec/app-desktop/blob/main/main.js) (Electron process), [`auth.js`](https://github.com/gb-tec/app-desktop/blob/main/auth.js) (Authentication), [`dashboard.js`](https://github.com/gb-tec/app-desktop/blob/main/dashboard.js) (Dashboard company loading), [`preload.js`](https://github.com/gb-tec/app-desktop/blob/main/preload.js) (IPC bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop runtime"]
  node_electron["Electron process<br/>[main.js]"]
  node_preload["IPC bridge<br/>[preload.js]"]
  node_localserver["Local server process<br/>[server.js]"]
end

subgraph group_identity["User access"]
  node_loginpage["Login page<br/>[index.html]"]
  node_dashboardpage["Dashboard page<br/>[dashboard.html]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_loginui["Login interface<br/>[script.js]"]
end

subgraph group_fiscal["Fiscal operations"]
  node_router["UI routing<br/>[app.js]"]
  node_fethab["FETHAB PDF processing<br/>[app.js]"]
  node_automationui["Dashboard automation<br/>[dashboard.js]"]
  node_api["Automation API<br/>[server.js]"]
  node_automation["Fiscal automation handlers<br/>[server.js]"]
end

subgraph group_records["Company records"]
  node_companies["Company management<br/>[app.js]"]
  node_dashboarddata["Dashboard company loading<br/>[dashboard.js]"]
end

node_user(("Desktop user"))
node_firebaseauth{{"Firebase Auth"}}
node_pdfjs{{"PDF.js"}}
node_firestore[("Firebase Firestore")]

node_user -->|"uses"| node_loginpage
node_electron -->|"loads"| node_loginpage
node_electron -->|"configures"| node_preload
node_electron -->|"spawns"| node_localserver
node_preload -->|"invokes IPC"| node_electron
node_loginui -->|"signs in"| node_firebaseauth
node_auth -->|"authenticates"| node_firebaseauth
node_auth -->|"creates user record"| node_firestore
node_router -->|"routes to"| node_fethab
node_fethab -->|"processes PDFs with"| node_pdfjs
node_dashboarddata -->|"checks access"| node_auth
node_dashboarddata -.->|"loads companies"| node_firestore
node_companies -->|"reads and writes"| node_firestore
node_automationui -.->|"requests automation"| node_api
node_api -->|"dispatches"| node_automation
node_electron -->|"checks status"| node_localserver

click node_electron "https://github.com/gb-tec/app-desktop/blob/main/main.js"
click node_preload "https://github.com/gb-tec/app-desktop/blob/main/preload.js"
click node_loginpage "https://github.com/gb-tec/app-desktop/blob/main/index.html"
click node_dashboardpage "https://github.com/gb-tec/app-desktop/blob/main/dashboard.html"
click node_auth "https://github.com/gb-tec/app-desktop/blob/main/auth.js"
click node_loginui "https://github.com/gb-tec/app-desktop/blob/main/script.js"
click node_router "https://github.com/gb-tec/app-desktop/blob/main/app.js"
click node_fethab "https://github.com/gb-tec/app-desktop/blob/main/app.js"
click node_automationui "https://github.com/gb-tec/app-desktop/blob/main/dashboard.js"
click node_api "https://github.com/gb-tec/app-desktop/blob/main/server.js"
click node_automation "https://github.com/gb-tec/app-desktop/blob/main/server.js"
click node_companies "https://github.com/gb-tec/app-desktop/blob/main/app.js"
click node_dashboarddata "https://github.com/gb-tec/app-desktop/blob/main/dashboard.js"
click node_localserver "https://github.com/gb-tec/app-desktop/blob/main/server.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_electron,node_preload,node_localserver,node_user toneBlue
class node_loginpage,node_dashboardpage,node_auth,node_loginui,node_firestore toneAmber
class node_router,node_fethab,node_automationui,node_api,node_automation toneMint
class node_companies,node_dashboarddata toneRose
class node_firebaseauth,node_pdfjs toneIndigo
```

## Components

### Desktop runtime

- [Electron process](https://github.com/gb-tec/app-desktop/blob/main/main.js): `main.js`
- [IPC bridge](https://github.com/gb-tec/app-desktop/blob/main/preload.js): `preload.js`
- [Local server process](https://github.com/gb-tec/app-desktop/blob/main/server.js): `server.js`

### User access

- [Login page](https://github.com/gb-tec/app-desktop/blob/main/index.html): `index.html`
- [Dashboard page](https://github.com/gb-tec/app-desktop/blob/main/dashboard.html): `dashboard.html`
- [Authentication](https://github.com/gb-tec/app-desktop/blob/main/auth.js): `auth.js`
- [Login interface](https://github.com/gb-tec/app-desktop/blob/main/script.js): `script.js`

### Fiscal operations

- [UI routing](https://github.com/gb-tec/app-desktop/blob/main/app.js): `app.js`
- [FETHAB PDF processing](https://github.com/gb-tec/app-desktop/blob/main/app.js): `app.js`
- [Dashboard automation](https://github.com/gb-tec/app-desktop/blob/main/dashboard.js): `dashboard.js`
- [Automation API](https://github.com/gb-tec/app-desktop/blob/main/server.js): `server.js`
- [Fiscal automation handlers](https://github.com/gb-tec/app-desktop/blob/main/server.js): `server.js`

### Company records

- [Company management](https://github.com/gb-tec/app-desktop/blob/main/app.js): `app.js`
- [Dashboard company loading](https://github.com/gb-tec/app-desktop/blob/main/dashboard.js): `dashboard.js`

### Other components

- **Desktop user**
- **Firebase Auth**
- **PDF.js**
- **Firebase Firestore**

## Connections

- Desktop user → Login page: uses
- Electron process → Login page: loads (evidence: `main.js`)
- Electron process → IPC bridge: configures (evidence: `main.js`)
- Electron process → Local server process: spawns (evidence: `main.js`)
- IPC bridge → Electron process: invokes IPC (evidence: `preload.js`)
- Login interface → Firebase Auth: signs in (evidence: `script.js`)
- Authentication → Firebase Auth: authenticates (evidence: `auth.js`)
- Authentication → Firebase Firestore: creates user record (evidence: `auth.js`)
- UI routing → FETHAB PDF processing: routes to (evidence: `app.js`)
- FETHAB PDF processing → PDF.js: processes PDFs with (evidence: `app.js`)
- Dashboard company loading → Authentication: checks access (evidence: `dashboard.js`)
- Dashboard company loading → Firebase Firestore: loads companies
- Company management → Firebase Firestore: reads and writes (evidence: `app.js`)
- Dashboard automation → Automation API: requests automation
- Automation API → Fiscal automation handlers: dispatches (evidence: `server.js`)
- Electron process → Local server process: checks status (evidence: `main.js`)
