# bulletjim/std-app architecture

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

- Interactive diagram: https://gitdiagram.com/bulletjim/std-app
- Repository: https://github.com/bulletjim/std-app

## Overview

#### Purpose and Runtime
Secure Table Database is an offline Electron desktop app for creating and managing password-protected tabular data. It uses TypeScript, Vite/Electron Forge packaging, synchronous local SQLite (`better-sqlite3`), Node’s native crypto, and local `electron-log`; it has no cloud or server dependency.

Entry/runtime boundaries:
- Electron main process: `src/backend/main.ts`
- Privileged preload bridge: `src/preload.ts`
- Renderer UI bootstrap: `src/frontend/renderer.ts`
- Renderer HTML shell: `src/frontend/index.html`

#### Process and IPC Boundary
The renderer cannot directly access the database or cryptography. UI code calls the API exposed through the preload script; the main process receives IPC requests and routes them to backend controllers. This boundary keeps filesystem, SQLite, and password/key operations in Electron’s privileged process.

Relevant paths:
- `src/preload.ts`
- `src/frontend/api.ts`
- `src/backend/main.ts`
- `src/backend/controllers/tableController.ts`

#### Frontend Application
The renderer is a lightweight component-based interface for navigation, table creation, and table-detail operations. Routing selects dashboard and detail views; UI utilities support table-oriented transformations. It is responsible for collecting user input and rendering decrypted data received over IPC, not persistence or encryption.

Relevant paths:
- `src/frontend/router.ts`
- `src/frontend/components/dashboard.ts`
- `src/frontend/components/createTable.ts`
- `src/frontend/components/tableDetails.ts`

#### Table Application Layer
The controller/service layer defines table lifecycle operations—create, retrieve/manage, import/export, and password changes—while separating IPC-facing orchestration from business rules. Shared contracts model table and security data passed across layers.

Relevant paths:
- `src/backend/controllers/tableController.ts`
- `src/backend/services/tableService.ts`
- `src/backend/interfaces/tableTypes.ts`
- `src/backend/interfaces/index.ts`

#### Security Model
`securityService` owns encryption-sensitive behavior: AES-256-GCM encryption and PBKDF2 password-derived keys. Keys/passwords are not persisted; only encrypted table content and necessary non-secret encryption metadata should cross into storage. Password loss is intentionally unrecoverable, and re-keying is a security-domain operation rather than a UI-only update.

Relevant paths:
- `src/backend/services/securityService.ts`
- `src/backend/interfaces/securityTypes.ts`
- `src/backend/services/tableService.ts`

#### Local Persistence
The repository layer is the sole storage boundary around local `better-sqlite3`. Services invoke it to persist and retrieve encrypted table records; decrypted values should remain in memory only for the active operation and renderer response. The synchronous database runtime is confined to the Electron backend process.

Relevant paths:
- `src/backend/db/tableRepository.ts`
- `src/backend/services/tableService.ts`
- `src/backend/main.ts`

#### Observability and Delivery
Main and renderer have separate logging utilities, with the documented policy of excluding passwords and decrypted contents. Electron Forge/Vite configurations build the distinct main, preload, and renderer bundles; GitHub Actions provides CI/CD and release automation.

Relevant paths:
- `src/backend/util/logger.ts`
- `src/frontend/util/logger.ts`
- `forge.config.ts`
- `.github/workflows/ci-cd-pipeline.yml`

Main entry points: [`src/frontend/router.ts`](https://github.com/bulletjim/std-app/blob/main/src/frontend/router.ts) (View router), [`forge.config.ts`](https://github.com/bulletjim/std-app/blob/main/forge.config.ts) (Forge/Vite build), [`src/frontend/renderer.ts`](https://github.com/bulletjim/std-app/blob/main/src/frontend/renderer.ts) (Renderer bootstrap), [`src/backend/main.ts`](https://github.com/bulletjim/std-app/blob/main/src/backend/main.ts) (Electron main)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_renderer["Renderer"]
  node_html["Renderer HTML shell<br/>HTML entry<br/>[index.html]"]
  node_renderer_bootstrap["Renderer bootstrap<br/>renderer entry<br/>[renderer.ts]"]
  node_router["View router<br/>routing<br/>[router.ts]"]
  node_dashboard["Dashboard<br/>UI component<br/>[dashboard.ts]"]
  node_create_table["Create table view<br/>UI component<br/>[createTable.ts]"]
  node_table_details["Table details view<br/>UI component<br/>[tableDetails.ts]"]
  node_renderer_api["Renderer API client<br/>IPC client<br/>[api.ts]"]
  node_renderer_logger["Renderer logger<br/>local logging<br/>[logger.ts]"]
end

subgraph group_electron["Electron Backend"]
  node_preload{{"Preload bridge<br/>privileged IPC bridge<br/>[preload.ts]"}}
  node_main["Electron main<br/>main-process entry<br/>[main.ts]"]
  node_controller["Table controller<br/>IPC controller<br/>[tableController.ts]"]
  node_table_service["Table service<br/>application service<br/>[tableService.ts]"]
  node_table_contracts["Table contracts<br/>shared contracts<br/>[tableTypes.ts]"]
  node_backend_logger["Backend logger<br/>local logging<br/>[logger.ts]"]
end

subgraph group_security["Security"]
  node_security_contracts["Security contracts<br/>[securityTypes.ts]"]
  node_security_service{{"Security service<br/>crypto service<br/>[securityService.ts]"}}
end

subgraph group_storage["Local Storage"]
  node_repository["Table repository<br/>SQLite repository<br/>[tableRepository.ts]"]
  node_sqlite[("Local SQLite<br/>better-sqlite3 database")]
end

subgraph group_delivery["Delivery"]
  node_forge["Forge/Vite build<br/>packaging config<br/>[forge.config.ts]"]
  node_ci_cd["CI/CD release pipeline<br/>GitHub Actions<br/>[ci-cd-pipeline.yml]"]
end

node_html -->|"loads"| node_renderer_bootstrap
node_renderer_bootstrap -->|"starts"| node_router
node_router -->|"selects"| node_dashboard
node_router -->|"selects"| node_create_table
node_router -->|"selects"| node_table_details
node_dashboard -->|"table actions"| node_renderer_api
node_create_table -->|"create request"| node_renderer_api
node_table_details -->|"manage request"| node_renderer_api
node_renderer_api -->|"invokes"| node_preload
node_preload -->|"IPC request"| node_main
node_main -->|"routes"| node_controller
node_controller -->|"orchestrates"| node_table_service
node_controller -.->|"uses"| node_table_contracts
node_table_service -->|"encrypts, decrypts, re-keys"| node_security_service
node_table_service -->|"persists encrypted records"| node_repository
node_security_service -.->|"uses"| node_security_contracts
node_repository -->|"reads and writes"| node_sqlite
node_main -.->|"logs safely"| node_backend_logger
node_renderer_bootstrap -.->|"logs safely"| node_renderer_logger
node_forge -.->|"bundles"| node_main
node_forge -.->|"bundles"| node_preload
node_forge -.->|"bundles"| node_renderer_bootstrap
node_ci_cd -->|"builds and releases"| node_forge

click node_html "https://github.com/bulletjim/std-app/blob/main/src/frontend/index.html"
click node_renderer_bootstrap "https://github.com/bulletjim/std-app/blob/main/src/frontend/renderer.ts"
click node_router "https://github.com/bulletjim/std-app/blob/main/src/frontend/router.ts"
click node_dashboard "https://github.com/bulletjim/std-app/blob/main/src/frontend/components/dashboard.ts"
click node_create_table "https://github.com/bulletjim/std-app/blob/main/src/frontend/components/createTable.ts"
click node_table_details "https://github.com/bulletjim/std-app/blob/main/src/frontend/components/tableDetails.ts"
click node_renderer_api "https://github.com/bulletjim/std-app/blob/main/src/frontend/api.ts"
click node_preload "https://github.com/bulletjim/std-app/blob/main/src/preload.ts"
click node_main "https://github.com/bulletjim/std-app/blob/main/src/backend/main.ts"
click node_controller "https://github.com/bulletjim/std-app/blob/main/src/backend/controllers/tableController.ts"
click node_table_service "https://github.com/bulletjim/std-app/blob/main/src/backend/services/tableService.ts"
click node_table_contracts "https://github.com/bulletjim/std-app/blob/main/src/backend/interfaces/tableTypes.ts"
click node_security_contracts "https://github.com/bulletjim/std-app/blob/main/src/backend/interfaces/securityTypes.ts"
click node_security_service "https://github.com/bulletjim/std-app/blob/main/src/backend/services/securityService.ts"
click node_repository "https://github.com/bulletjim/std-app/blob/main/src/backend/db/tableRepository.ts"
click node_backend_logger "https://github.com/bulletjim/std-app/blob/main/src/backend/util/logger.ts"
click node_renderer_logger "https://github.com/bulletjim/std-app/blob/main/src/frontend/util/logger.ts"
click node_forge "https://github.com/bulletjim/std-app/blob/main/forge.config.ts"
click node_ci_cd "https://github.com/bulletjim/std-app/blob/main/.github/workflows/ci-cd-pipeline.yml"

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_html,node_renderer_bootstrap,node_router,node_dashboard,node_create_table,node_table_details,node_renderer_api,node_renderer_logger toneBlue
class node_preload,node_main,node_controller,node_table_service,node_table_contracts,node_backend_logger toneAmber
class node_security_contracts,node_security_service toneMint
class node_repository,node_sqlite toneRose
class node_forge,node_ci_cd toneIndigo
```

## Components

### Renderer

Unprivileged UI runtime.

- [Renderer HTML shell](https://github.com/bulletjim/std-app/blob/main/src/frontend/index.html): HTML entry · `src/frontend/index.html`
- [Renderer bootstrap](https://github.com/bulletjim/std-app/blob/main/src/frontend/renderer.ts): renderer entry · `src/frontend/renderer.ts`
- [View router](https://github.com/bulletjim/std-app/blob/main/src/frontend/router.ts): routing · Selects dashboard and table-detail views. · `src/frontend/router.ts`
- [Dashboard](https://github.com/bulletjim/std-app/blob/main/src/frontend/components/dashboard.ts): UI component · `src/frontend/components/dashboard.ts`
- [Create table view](https://github.com/bulletjim/std-app/blob/main/src/frontend/components/createTable.ts): UI component · `src/frontend/components/createTable.ts`
- [Table details view](https://github.com/bulletjim/std-app/blob/main/src/frontend/components/tableDetails.ts): UI component · Renders decrypted data returned by the backend. · `src/frontend/components/tableDetails.ts`
- [Renderer API client](https://github.com/bulletjim/std-app/blob/main/src/frontend/api.ts): IPC client · `src/frontend/api.ts`
- [Renderer logger](https://github.com/bulletjim/std-app/blob/main/src/frontend/util/logger.ts): local logging · Excludes passwords and decrypted contents. · `src/frontend/util/logger.ts`

### Electron Backend

Privileged main-process application layer.

- [Preload bridge](https://github.com/bulletjim/std-app/blob/main/src/preload.ts): privileged IPC bridge · Exposes the renderer API without direct backend access. · `src/preload.ts`
- [Electron main](https://github.com/bulletjim/std-app/blob/main/src/backend/main.ts): main-process entry · Receives IPC and confines privileged runtime access. · `src/backend/main.ts`
- [Table controller](https://github.com/bulletjim/std-app/blob/main/src/backend/controllers/tableController.ts): IPC controller · Routes table lifecycle requests from the main process. · `src/backend/controllers/tableController.ts`
- [Table service](https://github.com/bulletjim/std-app/blob/main/src/backend/services/tableService.ts): application service · Coordinates table lifecycle, import/export, and password changes. · `src/backend/services/tableService.ts`
- [Table contracts](https://github.com/bulletjim/std-app/blob/main/src/backend/interfaces/tableTypes.ts): shared contracts · `src/backend/interfaces/tableTypes.ts`
- [Backend logger](https://github.com/bulletjim/std-app/blob/main/src/backend/util/logger.ts): local logging · Excludes passwords and decrypted contents. · `src/backend/util/logger.ts`

### Security

Password and encryption domain.

- [Security contracts](https://github.com/bulletjim/std-app/blob/main/src/backend/interfaces/securityTypes.ts): security contracts · `src/backend/interfaces/securityTypes.ts`
- [Security service](https://github.com/bulletjim/std-app/blob/main/src/backend/services/securityService.ts): crypto service · Derives PBKDF2 keys and performs AES-256-GCM encryption. · `src/backend/services/securityService.ts`

### Local Storage

Encrypted local persistence.

- [Table repository](https://github.com/bulletjim/std-app/blob/main/src/backend/db/tableRepository.ts): SQLite repository · Sole storage boundary for encrypted table records. · `src/backend/db/tableRepository.ts`
- **Local SQLite**: better-sqlite3 database · Synchronous database runtime used only in the main process.

### Delivery

Desktop build and release automation.

- [Forge/Vite build](https://github.com/bulletjim/std-app/blob/main/forge.config.ts): packaging config · Builds distinct main, preload, and renderer bundles. · `forge.config.ts`
- [CI/CD release pipeline](https://github.com/bulletjim/std-app/blob/main/.github/workflows/ci-cd-pipeline.yml): GitHub Actions · Automates validation and releases. · `.github/workflows/ci-cd-pipeline.yml`

## Connections

- Renderer HTML shell → Renderer bootstrap: loads
- Renderer bootstrap → View router: starts
- View router → Dashboard: selects
- View router → Create table view: selects
- View router → Table details view: selects
- Dashboard → Renderer API client: table actions
- Create table view → Renderer API client: create request
- Table details view → Renderer API client: manage request
- Renderer API client → Preload bridge: invokes
- Preload bridge → Electron main: IPC request
- Electron main → Table controller: routes
- Table controller → Table service: orchestrates
- Table controller → Table contracts: uses
- Table service → Security service: encrypts, decrypts, re-keys
- Table service → Table repository: persists encrypted records
- Security service → Security contracts: uses
- Table repository → Local SQLite: reads and writes
- Electron main → Backend logger: logs safely
- Renderer bootstrap → Renderer logger: logs safely
- Forge/Vite build → Electron main: bundles
- Forge/Vite build → Preload bridge: bundles
- Forge/Vite build → Renderer bootstrap: bundles
- CI/CD release pipeline → Forge/Vite build: builds and releases
