# jaiz-lana/kilat architecture

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

- Interactive diagram: https://gitdiagram.com/jaiz-lana/kilat
- Repository: https://github.com/jaiz-lana/kilat

## Overview

KiLat is a browser-based, local file-processing application with an offline PWA shell. The main user flow is selecting a tool and local files, processing them in the browser, then downloading or previewing results. The tree and excerpts expose the student/document engine and service worker, but not index.html or the general image, PDF, and audio implementations; those README capabilities are retained as directory-level subsystems, with their wiring left unasserted. Relationship evidence is therefore limited to the sampled engine, service worker, and README.

Main entry points: [`studentEngine.js`](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js) (Student tool dispatcher), [`index.html`](https://github.com/jaiz-lana/kilat/blob/main/index.html) (Preview and downloads), [`sw.js`](https://github.com/jaiz-lana/kilat/blob/main/sw.js) (Offline cache worker), [`security.js`](https://github.com/jaiz-lana/kilat/blob/main/security.js) (HTML sanitization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Tool interface"]
  node_tools["Tool selection<br/>[index.html]"]
  node_inputs["Local file inputs<br/>[index.html]"]
  node_results["Preview and downloads<br/>[index.html]"]
end

subgraph group_document["Student documents"]
  node_student_dispatch["Student tool dispatcher<br/>[studentEngine.js]"]
  node_target_pdf["Target PDF compression<br/>[studentEngine.js]"]
  node_signature["Document signatures<br/>[studentEngine.js]"]
  node_thesis_numbers["Thesis page numbers<br/>[studentEngine.js]"]
  node_id_watermark["ID watermarking<br/>[studentEngine.js]"]
  node_scanner["Document scanner<br/>[studentEngine.js]"]
  node_ocr["Image OCR<br/>[studentEngine.js]"]
end

subgraph group_media["File processing"]
  node_image_tools["Image compression<br/>[index.html]"]
  node_pdf_tools["PDF tools<br/>[index.html]"]
  node_audio_tools["Audio extraction<br/>[index.html]"]
  node_archive["Batch ZIP output<br/>[index.html]"]
end

subgraph group_offline["Offline runtime"]
  node_pwa_worker["Offline cache worker<br/>[sw.js]"]
  node_web_manifest["Installable app metadata"]
end

subgraph group_security["Local safety"]
  node_security_helpers["HTML sanitization<br/>[security.js]"]
end

node_user(("Browser user"))
node_browser{{"Browser APIs"}}
node_tesseract{{"Tesseract OCR"}}

node_user -->|"selects tool"| node_tools
node_user -->|"chooses files"| node_inputs
node_tools -.->|"dispatches"| node_student_dispatch
node_inputs -.->|"provides files"| node_student_dispatch
node_student_dispatch -->|"dispatches"| node_target_pdf
node_student_dispatch -->|"dispatches"| node_signature
node_student_dispatch -->|"dispatches"| node_thesis_numbers
node_student_dispatch -->|"dispatches"| node_id_watermark
node_student_dispatch -->|"dispatches"| node_scanner
node_student_dispatch -->|"dispatches"| node_ocr
node_ocr -->|"loads engine"| node_tesseract
node_target_pdf -->|"uses browser APIs"| node_browser
node_signature -->|"uses canvas"| node_browser
node_thesis_numbers -->|"saves PDF"| node_browser
node_id_watermark -->|"creates ZIP"| node_archive
node_scanner -->|"creates ZIP"| node_archive
node_student_dispatch -.->|"delivers results"| node_results
node_user -->|"uses"| node_image_tools
node_user -->|"uses"| node_pdf_tools
node_user -->|"uses"| node_audio_tools
node_image_tools -.->|"produces files"| node_results
node_pdf_tools -.->|"produces files"| node_results
node_audio_tools -.->|"produces files"| node_results
node_user -->|"visits app"| node_pwa_worker
node_pwa_worker -->|"caches asset"| node_web_manifest
node_pwa_worker -->|"stores cache"| node_browser
node_security_helpers -->|"sanitizes markup"| node_browser

click node_tools "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_inputs "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_results "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_student_dispatch "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_target_pdf "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_signature "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_thesis_numbers "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_id_watermark "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_scanner "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_ocr "https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js"
click node_image_tools "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_pdf_tools "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_audio_tools "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_archive "https://github.com/jaiz-lana/kilat/blob/main/index.html"
click node_pwa_worker "https://github.com/jaiz-lana/kilat/blob/main/sw.js"
click node_web_manifest "https://github.com/jaiz-lana/kilat/blob/main/manifest.webmanifest"
click node_security_helpers "https://github.com/jaiz-lana/kilat/blob/main/security.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_tools,node_inputs,node_results,node_user,node_browser toneBlue
class node_student_dispatch,node_target_pdf,node_signature,node_thesis_numbers,node_id_watermark,node_scanner,node_ocr toneAmber
class node_image_tools,node_pdf_tools,node_audio_tools,node_archive toneMint
class node_pwa_worker,node_web_manifest toneRose
class node_security_helpers,node_tesseract toneIndigo
```

## Components

### Tool interface

- [Tool selection](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`
- [Local file inputs](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`
- [Preview and downloads](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`

### Student documents

- [Student tool dispatcher](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [Target PDF compression](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [Document signatures](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [Thesis page numbers](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [ID watermarking](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [Document scanner](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`
- [Image OCR](https://github.com/jaiz-lana/kilat/blob/main/studentEngine.js): `studentEngine.js`

### File processing

- [Image compression](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`
- [PDF tools](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`
- [Audio extraction](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`
- [Batch ZIP output](https://github.com/jaiz-lana/kilat/blob/main/index.html): `index.html`

### Offline runtime

- [Offline cache worker](https://github.com/jaiz-lana/kilat/blob/main/sw.js): `sw.js`
- [Installable app metadata](https://github.com/jaiz-lana/kilat/blob/main/manifest.webmanifest): `manifest.webmanifest`

### Local safety

- [HTML sanitization](https://github.com/jaiz-lana/kilat/blob/main/security.js): `security.js`

### Other components

- **Browser user**
- **Browser APIs**
- **Tesseract OCR**

## Connections

- Browser user → Tool selection: selects tool (evidence: `README.md`)
- Browser user → Local file inputs: chooses files (evidence: `README.md`)
- Tool selection → Student tool dispatcher: dispatches
- Local file inputs → Student tool dispatcher: provides files
- Student tool dispatcher → Target PDF compression: dispatches (evidence: `studentEngine.js`)
- Student tool dispatcher → Document signatures: dispatches (evidence: `studentEngine.js`)
- Student tool dispatcher → Thesis page numbers: dispatches (evidence: `studentEngine.js`)
- Student tool dispatcher → ID watermarking: dispatches (evidence: `studentEngine.js`)
- Student tool dispatcher → Document scanner: dispatches (evidence: `studentEngine.js`)
- Student tool dispatcher → Image OCR: dispatches (evidence: `studentEngine.js`)
- Image OCR → Tesseract OCR: loads engine (evidence: `studentEngine.js`)
- Target PDF compression → Browser APIs: uses browser APIs (evidence: `studentEngine.js`)
- Document signatures → Browser APIs: uses canvas (evidence: `studentEngine.js`)
- Thesis page numbers → Browser APIs: saves PDF (evidence: `studentEngine.js`)
- ID watermarking → Batch ZIP output: creates ZIP (evidence: `studentEngine.js`)
- Document scanner → Batch ZIP output: creates ZIP (evidence: `studentEngine.js`)
- Student tool dispatcher → Preview and downloads: delivers results
- Browser user → Image compression: uses (evidence: `README.md`)
- Browser user → PDF tools: uses (evidence: `README.md`)
- Browser user → Audio extraction: uses (evidence: `README.md`)
- Image compression → Preview and downloads: produces files
- PDF tools → Preview and downloads: produces files
- Audio extraction → Preview and downloads: produces files
- Browser user → Offline cache worker: visits app (evidence: `README.md`)
- Offline cache worker → Installable app metadata: caches asset (evidence: `sw.js`)
- Offline cache worker → Browser APIs: stores cache (evidence: `sw.js`)
- HTML sanitization → Browser APIs: sanitizes markup (evidence: `security.js`)
