# jyen2k/tax-diagram-tool architecture

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

- Interactive diagram: https://gitdiagram.com/jyen2k/tax-diagram-tool
- Repository: https://github.com/jyen2k/tax-diagram-tool

## Overview

1. **What this repo is**
   This is a lightweight, mostly client-side browser app for building tax structure diagrams. The main product surface is the diagram editor; the only meaningful backend responsibility is serving the app and accepting feedback submissions.

2. **Top-level split**
   The repository is organized around two browser entry points:
   - `index.html` for the diagram builder
   - `feedback.html` for the internal feedback form  
   Supporting logic lives in `app.js` and `feedback.js`, with shared styling in `styles.css`.

3. **Main editor boundary**
   The core architecture is a single-page, JavaScript-driven editor rendered in the browser. The UI appears to be built without a heavyweight frontend framework, using plain HTML/CSS/JS plus static vendor libraries under `vendor/`.

4. **Diagram model and interaction flow**
   The diagram tool likely maintains an in-browser state model for entities, ownership relationships, and transaction arrows. User actions such as drag-and-drop, editing in the inspector panel, and switching relationship modes all feed into that state, which then drives the SVG canvas rendering.

5. **Tax-specific semantics**
   The repository is not a generic diagram app; the entity palette is tax-domain specific. It supports corporations, partnerships, hybrid/disregarded entities, trusts/non-entities, and individuals, so the model likely distinguishes node types and relationship types in a way that supports tax-structure notation.

6. **Rendering and output**
   The canvas is SVG-based, which is important architecturally because it enables both interactive editing and export. The same diagram state can be saved in-browser and exported as SVG, PNG, and editable PPTX, indicating a client-side export pipeline rather than server-side rendering.

7. **Persistence boundary**
   Regular editor state is stored in the browser, so the app can run with minimal backend dependence. That makes the browser the primary system of record for drafts, with export files acting as the portable output format.

8. **Narrative generation**
   The “plain-English structure descriptions” feature suggests a second derived view over the same diagram model: the editor state is transformed into narrative text for lawyers. This is likely computed locally in the client, not via a separate service.

9. **Feedback subsystem**
   Feedback is a separate internal workflow, not part of the main editor loop. `feedback.html`/`feedback.js` capture a comment plus a PNG snapshot of the current diagram, and can include the authenticated user email when the platform provides it.

10. **Backend/API boundary**
   `server.py` is the lightweight backend entrypoint. Based on the README, it serves the browser app and provides a feedback API. Feedback is persisted either to local storage on disk under `/tmp/tax-flow-chart-feedback` or to Postgres when `DATABASE_URL` is present.

11. **Deployment/runtime**
   The `Dockerfile` and `.appgarden.json` show the app is designed for App Garden deployment. The container runs the web app and feedback API on the platform-provided `PORT`, with internal auth enabled when used as a teammate-facing tool.

12. **External dependencies**
   The only external infrastructure that materially changes the architecture is managed Postgres for feedback storage and App Garden authentication headers. Everything else — editing, rendering, and export — is handled in the browser.

13. **How to draw the architecture**
   A good diagram would show:
   - Browser UI as the primary application boundary
   - Static assets and client-side logic as the main engine
   - A small Python server behind it for serving files and feedback submission
   - Optional Postgres persistence for feedback only
   - No server-side involvement in normal diagram editing/export workflows

Main entry points: [`server.py`](https://github.com/jyen2k/tax-diagram-tool/blob/main/server.py) (Python server), [`index.html`](https://github.com/jyen2k/tax-diagram-tool/blob/main/index.html) (Diagram editor), [`feedback.js`](https://github.com/jyen2k/tax-diagram-tool/blob/main/feedback.js) (Feedback logic), [`app.js`](https://github.com/jyen2k/tax-diagram-tool/blob/main/app.js) (Editor logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser app"]
  node_index["Diagram editor<br/>html entry<br/>[index.html]"]
  node_appjs["Editor logic<br/>client app<br/>[app.js]"]
  node_styles["Shared styles<br/>css theme<br/>[styles.css]"]
  node_vendor["Vendor libs<br/>static deps"]
  node_model{{"Diagram model<br/>state model"}}
  node_interaction["Editor tools<br/>interaction layer"]
  node_render(("SVG canvas<br/>renderer"))
  node_export["Export pipeline<br/>output pipeline"]
  node_narrative["Narrative text<br/>derived view"]
  node_storage[("Local drafts<br/>browser storage")]
end

subgraph group_feedback["Feedback flow"]
  node_feedbackhtml["Feedback form<br/>html entry<br/>[feedback.html]"]
  node_feedbackjs["Feedback logic<br/>client form<br/>[feedback.js]"]
  node_snapshot["PNG snapshot<br/>capture artifact"]
end

subgraph group_backend["Backend"]
  node_server["Python server<br/>web server<br/>[server.py]"]
  node_feedbackapi["Feedback API<br/>api endpoint"]
  node_disk[("Disk store<br/>file storage")]
  node_postgres[("Postgres<br/>database")]
end

subgraph group_deploy["Deployment"]
  node_dockerfile["Container<br/>docker build"]
  node_appgarden["App config<br/>platform config<br/>[.appgarden.json]"]
end

node_index -->|"loads"| node_appjs
node_index -->|"uses"| node_styles
node_index -->|"bundles"| node_vendor
node_appjs -->|"updates"| node_model
node_interaction -->|"edits"| node_model
node_model -->|"drives"| node_render
node_render -->|"feeds"| node_export
node_model -->|"derives"| node_narrative
node_model -->|"persists"| node_storage
node_feedbackhtml -->|"loads"| node_feedbackjs
node_feedbackjs -->|"captures"| node_snapshot
node_feedbackjs -->|"submits"| node_server
node_server -->|"exposes"| node_feedbackapi
node_feedbackapi -->|"stores"| node_disk
node_feedbackapi -->|"stores"| node_postgres
node_dockerfile -->|"packages"| node_server
node_appgarden -->|"configures"| node_server
node_server -->|"serves"| node_index
node_server -->|"serves"| node_feedbackhtml

click node_index "https://github.com/jyen2k/tax-diagram-tool/blob/main/index.html"
click node_appjs "https://github.com/jyen2k/tax-diagram-tool/blob/main/app.js"
click node_styles "https://github.com/jyen2k/tax-diagram-tool/blob/main/styles.css"
click node_vendor "https://github.com/jyen2k/tax-diagram-tool/tree/main/vendor"
click node_feedbackhtml "https://github.com/jyen2k/tax-diagram-tool/blob/main/feedback.html"
click node_feedbackjs "https://github.com/jyen2k/tax-diagram-tool/blob/main/feedback.js"
click node_server "https://github.com/jyen2k/tax-diagram-tool/blob/main/server.py"
click node_dockerfile "https://github.com/jyen2k/tax-diagram-tool/tree/main/Dockerfile"
click node_appgarden "https://github.com/jyen2k/tax-diagram-tool/blob/main/.appgarden.json"

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_index,node_appjs,node_styles,node_vendor,node_model,node_interaction,node_render,node_export,node_narrative,node_storage toneBlue
class node_feedbackhtml,node_feedbackjs,node_snapshot toneAmber
class node_server,node_feedbackapi,node_disk,node_postgres toneMint
class node_dockerfile,node_appgarden toneRose
```

## Components

### Browser app

Client-side diagram editor and shared UI assets

- [Diagram editor](https://github.com/jyen2k/tax-diagram-tool/blob/main/index.html): html entry · Main tax-structure diagram builder surface · `index.html`
- [Editor logic](https://github.com/jyen2k/tax-diagram-tool/blob/main/app.js): client app · Primary browser-side controller for state, interactions, and rendering · `app.js`
- [Shared styles](https://github.com/jyen2k/tax-diagram-tool/blob/main/styles.css): css theme · Common visual styling for the browser UI · `styles.css`
- [Vendor libs](https://github.com/jyen2k/tax-diagram-tool/tree/main/vendor): static deps · Bundled third-party browser libraries used by the editor · `vendor`
- **Diagram model**: state model · In-browser representation of entities, relationships, and transactions
- **Editor tools**: interaction layer · Drag, edit, mode switching, and inspector-driven updates
- **SVG canvas**: renderer · Interactive SVG drawing surface for the diagram
- **Export pipeline**: output pipeline · Client-side export to SVG, PNG, and editable PPTX
- **Narrative text**: derived view · Plain-English description generation from diagram state
- **Local drafts**: browser storage · Persistent browser-side storage for editor state

### Feedback flow

Separate internal feedback capture workflow

- [Feedback form](https://github.com/jyen2k/tax-diagram-tool/blob/main/feedback.html): html entry · Internal feedback submission page · `feedback.html`
- [Feedback logic](https://github.com/jyen2k/tax-diagram-tool/blob/main/feedback.js): client form · Captures comment, snapshot, and user identity when available · `feedback.js`
- **PNG snapshot**: capture artifact · Image capture of the current diagram included with feedback

### Backend

Small Python server and persistence boundary

- [Python server](https://github.com/jyen2k/tax-diagram-tool/blob/main/server.py): web server · Serves the browser app and accepts feedback submissions · `server.py`
- **Feedback API**: api endpoint · Backend endpoint for storing feedback payloads
- **Disk store**: file storage · Local on-disk feedback persistence under /tmp/tax-flow-chart-feedback
- **Postgres**: database · Optional managed persistence for feedback when DATABASE_URL is set

### Deployment

Container and platform runtime configuration

- [Container](https://github.com/jyen2k/tax-diagram-tool/tree/main/Dockerfile): docker build · Container image definition for App Garden deployment · `Dockerfile`
- [App config](https://github.com/jyen2k/tax-diagram-tool/blob/main/.appgarden.json): platform config · Platform deployment and runtime settings · `.appgarden.json`

## Connections

- Diagram editor → Editor logic: loads · Browser entry bootstraps the main editor logic
- Diagram editor → Shared styles: uses · Main app shares the common stylesheet
- Diagram editor → Vendor libs: bundles · Editor depends on static third-party browser libraries
- Editor logic → Diagram model: updates · User actions mutate the diagram state model
- Editor tools → Diagram model: edits · Inspector, drag-and-drop, and mode changes feed the model
- Diagram model → SVG canvas: drives · State changes re-render the SVG canvas
- SVG canvas → Export pipeline: feeds · Rendered diagram state is exported to file formats
- Diagram model → Narrative text: derives · Same diagram state is transformed into plain-English structure text
- Diagram model → Local drafts: persists · Draft editor state is stored locally in the browser
- Feedback form → Feedback logic: loads · Feedback page bootstraps the feedback client logic
- Feedback logic → PNG snapshot: captures · Feedback submission includes a PNG of the current diagram
- Feedback logic → Python server: submits · Feedback client posts submissions to the backend
- Python server → Feedback API: exposes · Backend provides the feedback submission endpoint
- Feedback API → Disk store: stores · Fallback persistence writes feedback to local disk
- Feedback API → Postgres: stores · Optional persistence writes feedback to Postgres
- Container → Python server: packages · Container image runs the Python web server
- App config → Python server: configures · Platform config sets runtime and port behavior
- Python server → Diagram editor: serves · Backend serves the main browser application
- Python server → Feedback form: serves · Backend serves the feedback form page
