# noah20102021/txtshare architecture

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

- Interactive diagram: https://gitdiagram.com/noah20102021/txtshare
- Repository: https://github.com/noah20102021/txtshare

## Overview

#### Purpose and entry points
txtShare is a lightweight text-sharing service usable from a browser and shell clients. It accepts text under a key, optionally password-protected, and retrieves it later. The Spring Boot process starts at `src/main/java/com/kwirll/txtshare/TxtShareApplication.java`; its HTTP API is likely concentrated in `src/main/java/com/kwirll/txtshare/apiInterface.java`. The browser entry point is the packaged static page at `src/main/resources/static/index.html`.

#### Runtime and infrastructure
The application is a Java 21/Maven Spring Boot service (`pom.xml`) running on embedded Tomcat. Per the README, local startup uses an embedded H2 database, so no externally provisioned datastore is required. Runtime properties are held in `src/main/resources/application.properties`. Deployment-specific public host configuration is a code-level setting in `src/main/java/com/kwirll/txtshare/config.java`, which shell setup and generated client commands likely depend on.

#### HTTP and shell-client boundary
The server exposes endpoints consumed by both the static web UI and command-line workflow. The README identifies `/setup` as the bootstrap endpoint that users pipe into their shell, then use generated `txtPush`, `txtGet`, and `txtHelp` commands. `src/main/java/com/kwirll/txtshare/apiInterface.java` is the key boundary translating HTTP requests into text-storage operations; `src/main/java/com/kwirll/txtshare/config.java` provides the canonical host used in returned setup content or URLs.

#### Text persistence model
`src/main/java/com/kwirll/txtshare/txtClass.java` is the central text-record/domain component and likely maps stored values, keys, and password-related fields to the embedded persistence layer. Write flow is: web or shell request → API interface → text model/storage. Read flow is: key (and optional password) → API interface → lookup/validation → returned text. H2 persistence is the durability boundary between requests and restarts, subject to its configured mode.

#### Application logic layer
`src/main/java/com/kwirll/txtshare/functions.java` appears to isolate shared operational logic from transport handling, likely covering key lookup, text creation, password checks, or response formatting. This separates request routing in `apiInterface.java` from domain behavior and persistence represented by `txtClass.java`. `src/main/java/com/kwirll/txtshare/config.java` is a second cross-cutting boundary for host/environment assumptions.

#### Web presentation client
Spring Boot serves the browser UI directly from `src/main/resources/static/`. `src/main/resources/static/index.html` supplies the page, `src/main/resources/static/script.js` performs browser-side interaction with the API, and `src/main/resources/static/style.css` provides presentation. This client is static rather than a separate frontend runtime: it communicates to the same deployed Spring Boot origin and shares the API contract with shell clients.

#### Primary operational flow
1. Embedded Tomcat starts the Spring Boot application and serves API routes plus static assets.
2. A browser loads the static UI, or a shell fetches `/setup` to install/define commands.
3. Clients submit keyed text, optionally including a password, to the API.
4. The API delegates common behavior to `functions.java` and persists or retrieves `txtClass` records through the embedded H2-backed application layer.
5. Retrieval requests enforce the key/password contract and return text for shell output or browser rendering.

Main entry points: [`src/main/java/com/kwirll/txtshare/apiInterface.java`](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/apiInterface.java) (API interface), [`src/main/resources/static/index.html`](https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/index.html) (Share page), [`src/main/java/com/kwirll/txtshare/TxtShareApplication.java`](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/TxtShareApplication.java) (TxtShare application), [`src/main/java/com/kwirll/txtshare/functions.java`](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/functions.java) (Shared operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Spring Boot service"]
  node_app{{"TxtShare application<br/>Spring Boot entry point"}}
  node_tomcat["Embedded Tomcat<br/>HTTP runtime"]
  node_api["API interface<br/>HTTP controller<br/>[apiInterface.java]"]
  node_functions["Shared operations<br/>application logic<br/>[functions.java]"]
  node_text_record["Text record<br/>persistence model<br/>[txtClass.java]"]
  node_h2[("Embedded H2<br/>database")]
  node_config["Host configuration<br/>runtime configuration<br/>[config.java]"]
  node_properties["Application properties<br/>runtime properties"]
end

subgraph group_web["Browser client"]
  node_index["Share page<br/>static HTML<br/>[index.html]"]
  node_script["Browser interaction<br/>client JavaScript<br/>[script.js]"]
  node_style["Page styling<br/>CSS<br/>[style.css]"]
end

subgraph group_clients["Client entry points"]
  node_browser(("Browser<br/>web client"))
  node_shell(("Shell client<br/>command workflow"))
end

node_app -->|"starts"| node_tomcat
node_properties -->|"configures"| node_app
node_tomcat -->|"routes requests to"| node_api
node_tomcat -->|"serves"| node_index
node_index -->|"loads"| node_script
node_index -->|"loads"| node_style
node_browser -->|"loads"| node_index
node_script -->|"calls"| node_api
node_shell -->|"fetches /setup and uses commands"| node_api
node_api -->|"uses host"| node_config
node_api -->|"delegates to"| node_functions
node_functions -->|"creates and looks up"| node_text_record
node_text_record -->|"persists in"| node_h2

click node_app "https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/TxtShareApplication.java"
click node_api "https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/apiInterface.java"
click node_functions "https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/functions.java"
click node_text_record "https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/txtClass.java"
click node_config "https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/config.java"
click node_properties "https://github.com/noah20102021/txtshare/blob/master/src/main/resources/application.properties"
click node_index "https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/index.html"
click node_script "https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/script.js"
click node_style "https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/style.css"

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_app,node_tomcat,node_api,node_functions,node_text_record,node_h2,node_config,node_properties toneBlue
class node_index,node_script,node_style toneAmber
class node_browser,node_shell toneMint
```

## Components

### Spring Boot service

Single deployed Java runtime.

- [TxtShare application](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/TxtShareApplication.java): Spring Boot entry point · `src/main/java/com/kwirll/txtshare/TxtShareApplication.java`
- **Embedded Tomcat**: HTTP runtime · Serves API routes and packaged static files.
- [API interface](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/apiInterface.java): HTTP controller · Translates setup, write, and retrieval requests into application operations. · `src/main/java/com/kwirll/txtshare/apiInterface.java`
- [Shared operations](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/functions.java): application logic · Handles text creation, lookup, password checks, and response behavior. · `src/main/java/com/kwirll/txtshare/functions.java`
- [Text record](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/txtClass.java): persistence model · Represents keyed text and optional password-related data. · `src/main/java/com/kwirll/txtshare/txtClass.java`
- **Embedded H2**: database · Durability boundary for stored text records.
- [Host configuration](https://github.com/noah20102021/txtshare/blob/master/src/main/java/com/kwirll/txtshare/config.java): runtime configuration · Provides the canonical public host used by setup output. · `src/main/java/com/kwirll/txtshare/config.java`
- [Application properties](https://github.com/noah20102021/txtshare/blob/master/src/main/resources/application.properties): runtime properties · `src/main/resources/application.properties`

### Browser client

Static assets served by the application.

- [Share page](https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/index.html): static HTML · `src/main/resources/static/index.html`
- [Browser interaction](https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/script.js): client JavaScript · Calls the same-origin HTTP API. · `src/main/resources/static/script.js`
- [Page styling](https://github.com/noah20102021/txtshare/blob/master/src/main/resources/static/style.css): CSS · `src/main/resources/static/style.css`

### Client entry points

- **Browser**: web client
- **Shell client**: command workflow · Installs generated txtPush, txtGet, and txtHelp commands.

## Connections

- TxtShare application → Embedded Tomcat: starts
- Application properties → TxtShare application: configures
- Embedded Tomcat → API interface: routes requests to
- Embedded Tomcat → Share page: serves
- Share page → Browser interaction: loads
- Share page → Page styling: loads
- Browser → Share page: loads
- Browser interaction → API interface: calls
- Shell client → API interface: fetches /setup and uses commands
- API interface → Host configuration: uses host
- API interface → Shared operations: delegates to
- Shared operations → Text record: creates and looks up
- Text record → Embedded H2: persists in
