# koteitan/nostr-post-checker architecture

> Architecture diagram of the GitHub repository koteitan/nostr-post-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/koteitan/nostr-post-checker
- Repository: https://github.com/koteitan/nostr-post-checker

## Overview

##### Project Type and Purpose
- This is a small, static, front-end only web application (“nostr-post-checker”) that runs entirely in the browser.
- Its sole purpose is to let a user enter a Nostr “note” ID and verify whether that note exists on one or more Nostr relays.

##### Top-Level File Structure
- index.html: single‐page UI shell
- style.css: styling for the page
- main.js: application logic (handles user input, invokes Nostr library, drives UI updates)
- bech32.js: utility module for bech32 encoding/decoding (part of Nostr protocol)
- LICENSE.md, README.md: documentation

##### Key Components
a. Browser / Client
- UI Layer (index.html + style.css)
- Application Logic (main.js)
- Utility Module (bech32.js)
- External Library (nostr-tools, implicitly imported by main.js)
b. External Services
- Nostr Relays (WebSocket or HTTP endpoints where “notes” are stored)
c. Hosting
- GitHub Pages (static file host)

##### Relationships & Data Flows
1. User opens index.html in browser
2. Browser loads style.css, bech32.js, main.js (+ nostr-tools bundle)
3. User inputs a note ID into the UI
4. main.js uses nostr-tools + bech32.js to format the ID
5. main.js opens WebSocket connections (or HTTP requests) to configured Nostr relays
6. Relays respond with presence/absence of the note
7. main.js updates the UI with the check result

##### Architectural Patterns & Design Principles
- Separation of concerns:
- UI (HTML/CSS)
- Business logic (main.js)
- Utility code (bech32.js)
- Single-page application pattern
- Externalizing protocol logic into nostr-tools

##### Technologies & Frameworks
- HTML5, CSS3, Vanilla JavaScript
- bech32.js (bech32 encoding module)
- nostr-tools (imported via CDN or bundle)
- GitHub Pages (static hosting)
- WebSocket or HTTP for relay communication

##### Elements
- Clear labels for each component (e.g., “UI (index.html + style.css)”, “App Logic (main.js)”).
- Rectangles for in-browser modules
- Optional: callouts or annotations for “nostr-tools” usage and bech32 encoding.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hosting
    GitHubPages["GitHub Pages (static host)"]:::external

    %% Browser container
    subgraph "Browser / Client"
        direction TB
        UI["UI (index.html + style.css)"]:::ui
        Logic["App Logic (main.js)"]:::logic
        Util["Utility Module (bech32.js)"]:::util
    end

    %% External Services
    NostrRelays[(“Nostr Relays”)]:::external

    %% Connections
    GitHubPages -->|"serves static files"| UI
    UI -->|"user input"| Logic
    Logic -->|"format ID"| Util
    Logic -->|"WebSocket/HTTP"| NostrRelays
    NostrRelays -->|"note presence/absence"| Logic
    Logic -->|"update UI"| UI

    %% Click Events
    click UI "https://github.com/koteitan/nostr-post-checker/blob/main/index.html"
    click UI "https://github.com/koteitan/nostr-post-checker/blob/main/style.css"
    click Logic "https://github.com/koteitan/nostr-post-checker/blob/main/main.js"
    click Util "https://github.com/koteitan/nostr-post-checker/blob/main/bech32.js"

    %% Styles
    classDef ui fill:#cfe2ff,stroke:#084298,color:#084298
    classDef logic fill:#d1e7dd,stroke:#0f5132,color:#0f5132
    classDef util fill:#fff3cd,stroke:#664d03,color:#664d03
    classDef external fill:#ffe5d9,stroke:#d9480f,color:#d9480f
```
