# jstrieb/urlpages architecture

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

- Interactive diagram: https://gitdiagram.com/jstrieb/urlpages
- Repository: https://github.com/jstrieb/urlpages

## Overview

##### Main Application Components
- Main Page Handler (index.html)
- Editor Interface (editor/)
- Bookmarklet Component (bookmarklet.js)
- Encoding/Decoding System (b64.js)
- API Interface (api.js)

##### Data Flow Architecture
a. Content Creation Flow:
- Editor → Encoding System → URL Generation
b. Content Consumption Flow:
- URL → Decoding System → Page Rendering
c. Page Cloning Flow:
- Bookmarklet → External Page → Encoding System → URL Generation

##### User Interface Layer (Top)
- Use rectangles to represent these UI elements

##### External Interactions (Sides)
- Bookmarklet component
- Integration with external web pages
- URL shortener service interaction points

##### Data Transformation Layer (Bottom)
- Base64 encoding/decoding process
- URL composition/decomposition
- Where compression occurs

- Blue: Core application components
- Green: User interface elements
- Orange: External services/interactions
- Purple: Data transformation processes

Important Elements to Highlight:

##### Stateless Nature
- How all data lives in the URL

##### Security Features
- Optional encryption layer (Link Lock integration)
- Where password protection can be applied

##### Integration Points
- URL shortener service connection points
- Browser bookmark integration

Specific Implementation Details:

- Editor Input → JSON Creation → Base64 Encoding → URL Generation
- URL Hash → Base64 Decoding → HTML/CSS/JS Extraction → Page Rendering

##### A special section showing the bookmarklet's interaction
- External Page → DOM Capture → Resource Embedding → URL Encoding

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        Editor["Editor Interface"]
        MainPage["Main Page Handler"]
        ExamplePages["Example Pages"]
    end

    subgraph "Core Processing Layer"
        EncodingEngine["Encoding/Decoding Engine"]:::core
        B64["Base64 Processing"]:::core
        API["API Interface"]:::core
    end

    subgraph "External Interaction Layer"
        Bookmarklet["Bookmarklet"]:::external
        ExternalPage["External Web Pages"]:::external
        URLShortener["URL Shortener Services"]:::external
    end

    subgraph "Security Layer"
        LinkLock["Link Lock Encryption"]:::security
        PasswordProtection["Password Protection"]:::security
    end

    %% Data Flow Connections
    Editor --> EncodingEngine
    EncodingEngine --> B64
    B64 --> |"URL Generation"| MainPage
    MainPage --> |"URL Hash"| B64
    B64 --> |"Decode"| EncodingEngine
    
    Bookmarklet --> |"Page Capture"| ExternalPage
    ExternalPage --> EncodingEngine
    EncodingEngine -.-> |"Optional"| LinkLock
    EncodingEngine -.-> |"Optional"| URLShortener
    
    API --> EncodingEngine
    EncodingEngine --> |"Page Rendering"| MainPage
    ExamplePages --> MainPage

    %% Click Events
    click Editor "https://github.com/jstrieb/urlpages/tree/master/editor/"
    click MainPage "https://github.com/jstrieb/urlpages/blob/master/index.html"
    click Bookmarklet "https://github.com/jstrieb/urlpages/blob/master/bookmarklet.js"
    click B64 "https://github.com/jstrieb/urlpages/blob/master/b64.js"
    click API "https://github.com/jstrieb/urlpages/blob/master/api.js"
    click ExamplePages "https://github.com/jstrieb/urlpages/tree/master/examples/"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef security fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ExtComp["External Integration"]:::external
        SecComp["Security Feature"]:::security
    end
```
