# gnomocarek/bibliotecapdf architecture

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

- Interactive diagram: https://gitdiagram.com/gnomocarek/bibliotecapdf
- Repository: https://github.com/gnomocarek/bibliotecapdf

## Overview

Minha Biblioteca Digital de PDFs is a browser-based, installable library for adding, organizing, reading, and downloading PDFs. A user selects or drops a PDF; the app extracts metadata and a cover, saves the book locally and optionally to Supabase, then lists it for search, filters, reading progress, favorites, and download. IndexedDB supports offline use; cloud storage enables access across devices. The README also documents backup import/export, themes, statistics, and PWA support. The excerpts show the main app, PDF helper, local database, cloud client, and service worker; other UI details are documented but not independently inspected.

Main entry points: [`js/app.js`](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js) (App controller), [`js/db.js`](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/db.js) (IndexedDB manager), [`js/cloud.js`](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/cloud.js) (Supabase sync), [`sw.js`](https://github.com/gnomocarek/bibliotecapdf/blob/main/sw.js) (Service worker cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["Library experience"]
  node_app["App controller<br/>[app.js]"]
  node_pdf["PDF metadata and covers<br/>[pdf-helper.js]"]
  node_reader_view["PDF reader<br/>[index.html]"]
  node_discovery["Search and organization<br/>[app.js]"]
  node_backup["Backup and statistics<br/>[app.js]"]
end

subgraph group_persistence["Book persistence"]
  node_local_db["IndexedDB manager<br/>[db.js]"]
  node_indexeddb[("Browser book store")]
  node_cloud_sync["Supabase sync<br/>[cloud.js]"]
  node_supabase[("Supabase books and storage")]
end

subgraph group_offline["Offline and install"]
  node_service_worker["Service worker cache<br/>[sw.js]"]
  node_cache[("Cache API")]
  node_pwa["PWA manifest<br/>[manifest.json]"]
end

node_reader(("Library user"))

node_reader -->|"uses"| node_app
node_app -->|"extracts metadata"| node_pdf
node_app -->|"initializes and saves"| node_local_db
node_app -->|"fetches and uploads"| node_cloud_sync
node_app -->|"renders and filters"| node_discovery
node_app -->|"opens PDF"| node_reader_view
node_app -->|"exports and imports"| node_backup
node_local_db -->|"reads and writes"| node_indexeddb
node_cloud_sync -->|"syncs book data"| node_supabase
node_service_worker -->|"caches assets"| node_cache
node_reader -->|"installs app"| node_pwa

click node_app "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js"
click node_pdf "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/pdf-helper.js"
click node_reader_view "https://github.com/gnomocarek/bibliotecapdf/blob/main/index.html"
click node_discovery "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js"
click node_backup "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js"
click node_local_db "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/db.js"
click node_cloud_sync "https://github.com/gnomocarek/bibliotecapdf/blob/main/js/cloud.js"
click node_service_worker "https://github.com/gnomocarek/bibliotecapdf/blob/main/sw.js"
click node_pwa "https://github.com/gnomocarek/bibliotecapdf/blob/main/manifest.json"

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_app,node_pdf,node_reader_view,node_discovery,node_backup,node_reader toneBlue
class node_local_db,node_indexeddb,node_cloud_sync,node_supabase toneAmber
class node_service_worker,node_cache,node_pwa toneMint
```

## Components

### Library experience

- [App controller](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js): `js/app.js`
- [PDF metadata and covers](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/pdf-helper.js): `js/pdf-helper.js`
- [PDF reader](https://github.com/gnomocarek/bibliotecapdf/blob/main/index.html): `index.html`
- [Search and organization](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js): `js/app.js`
- [Backup and statistics](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/app.js): `js/app.js`

### Book persistence

- [IndexedDB manager](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/db.js): `js/db.js`
- **Browser book store**
- [Supabase sync](https://github.com/gnomocarek/bibliotecapdf/blob/main/js/cloud.js): `js/cloud.js`
- **Supabase books and storage**

### Offline and install

- [Service worker cache](https://github.com/gnomocarek/bibliotecapdf/blob/main/sw.js): `sw.js`
- **Cache API**
- [PWA manifest](https://github.com/gnomocarek/bibliotecapdf/blob/main/manifest.json): `manifest.json`

### Other components

- **Library user**

## Connections

- Library user → App controller: uses (evidence: `README.md`)
- App controller → PDF metadata and covers: extracts metadata (evidence: `js/app.js`)
- App controller → IndexedDB manager: initializes and saves (evidence: `js/app.js`)
- App controller → Supabase sync: fetches and uploads (evidence: `js/app.js`)
- App controller → Search and organization: renders and filters (evidence: `README.md`)
- App controller → PDF reader: opens PDF (evidence: `README.md`)
- App controller → Backup and statistics: exports and imports (evidence: `README.md`)
- IndexedDB manager → Browser book store: reads and writes (evidence: `js/db.js`)
- Supabase sync → Supabase books and storage: syncs book data (evidence: `js/cloud.js`)
- Service worker cache → Cache API: caches assets (evidence: `sw.js`)
- Library user → PWA manifest: installs app (evidence: `README.md`)
