# lightbender255/lbff_the_last_caretaker_db architecture

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

- Interactive diagram: https://gitdiagram.com/lightbender255/lbff_the_last_caretaker_db
- Repository: https://github.com/lightbender255/lbff_the_last_caretaker_db

## Overview

This is an Electron POI tracker for The Last Caretaker. The primary workflow is a user browsing, filtering, adding, editing, or deleting POIs in the renderer; requests cross a preload IPC bridge to the main process, which reads and writes the local database and asynchronously syncs changes to a remote database. Lookup values support form choices, and a separate command-line sync performs full local-to-remote synchronization. The graph focuses on runtime product behavior; import and schema-migration utilities are peripheral. Source excerpts establish the UI/IPC and sync calls, but do not expose database connection details.

Main entry points: [`src/electron/main.js`](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/main.js) (POI handlers), [`data/schema.local.prisma`](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/data/schema.local.prisma) (Local database), [`scripts/sync.js`](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/scripts/sync.js) (CLI full sync), [`src/electron/renderer.js`](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/renderer.js) (POI grid and forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_renderer["POI grid and forms<br/>[renderer.js]"]
  node_bridge["IPC bridge<br/>[preload.js]"]
end

subgraph group_backend["Application backend"]
  node_handlers["POI handlers<br/>[main.js]"]
  node_sync["Startup and CRUD sync<br/>[main.js]"]
  node_cli_sync["CLI full sync<br/>[sync.js]"]
end

subgraph group_storage["Data and sync"]
  node_local[("Local database")]
  node_remote[("Remote database")]
end

node_user(("Tracker user"))

node_user -->|"uses"| node_renderer
node_renderer -->|"invokes API"| node_bridge
node_bridge -->|"sends IPC"| node_handlers
node_handlers -->|"queries and writes"| node_local
node_handlers -->|"starts sync"| node_sync
node_sync -->|"reads and writes"| node_local
node_sync -->|"upserts changes"| node_remote
node_cli_sync -->|"reads records"| node_local
node_cli_sync -->|"upserts records"| node_remote

click node_renderer "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/renderer.js"
click node_bridge "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/preload.js"
click node_handlers "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/main.js"
click node_sync "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/main.js"
click node_local "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/data/schema.local.prisma"
click node_remote "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/data/schema.remote.prisma"
click node_cli_sync "https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/scripts/sync.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_renderer,node_bridge,node_user toneBlue
class node_handlers,node_sync,node_cli_sync toneAmber
class node_local,node_remote toneMint
```

## Components

### Desktop interface

- [POI grid and forms](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/renderer.js): `src/electron/renderer.js`
- [IPC bridge](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/preload.js): `src/electron/preload.js`

### Application backend

- [POI handlers](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/main.js): `src/electron/main.js`
- [Startup and CRUD sync](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/src/electron/main.js): `src/electron/main.js`
- [CLI full sync](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/scripts/sync.js): `scripts/sync.js`

### Data and sync

- [Local database](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/data/schema.local.prisma): `data/schema.local.prisma`
- [Remote database](https://github.com/lightbender255/lbff_the_last_caretaker_db/blob/main/data/schema.remote.prisma): `data/schema.remote.prisma`

### Other components

- **Tracker user**

## Connections

- Tracker user → POI grid and forms: uses (evidence: `README.md`)
- POI grid and forms → IPC bridge: invokes API (evidence: `src/electron/renderer.js`)
- IPC bridge → POI handlers: sends IPC (evidence: `src/electron/preload.js`)
- POI handlers → Local database: queries and writes (evidence: `src/electron/main.js`)
- POI handlers → Startup and CRUD sync: starts sync (evidence: `src/electron/main.js`)
- Startup and CRUD sync → Local database: reads and writes (evidence: `src/electron/main.js`)
- Startup and CRUD sync → Remote database: upserts changes (evidence: `src/electron/main.js`)
- CLI full sync → Local database: reads records (evidence: `scripts/sync.js`)
- CLI full sync → Remote database: upserts records (evidence: `scripts/sync.js`)
