# doosemavis/tailormytext architecture

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

- Interactive diagram: https://gitdiagram.com/doosemavis/tailormytext
- Repository: https://github.com/doosemavis/tailormytext

## Overview

TailorMyText turns uploaded or library documents into structured, customizable reading material, then presents it through an accessible reader with a word-paced mode. The main flow runs from the reader UI through document-state handling and format parsers, with saved documents and positions backed by cloud and browser storage. Separate product branches cover accounts, subscriptions and checkout, the book library, and administration/analytics. Some subsystems are represented by exact directory paths because their implementations were not sampled; unsampled links are omitted where their callers cannot be verified.

Main entry points: [`src/App.jsx`](https://github.com/doosemavis/tailormytext/blob/main/src/App.jsx) (Reader app), [`src/utils/supabase.js`](https://github.com/doosemavis/tailormytext/blob/main/src/utils/supabase.js) (Supabase client), [`src/workers/parser.worker.js`](https://github.com/doosemavis/tailormytext/blob/main/src/workers/parser.worker.js) (Parser worker), [`src/hooks/usePacer.js`](https://github.com/doosemavis/tailormytext/blob/main/src/hooks/usePacer.js) (Word pacer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reading["Reading experience"]
  node_reader["Reader app<br/>[App.jsx]"]
  node_reader_ui["Reader components<br/>[DocumentBody.jsx]"]
  node_pacer["Word pacer<br/>[usePacer.js]"]
  node_pacer_index["Word indexing<br/>[wordIndex.js]"]
end

subgraph group_content["Document processing"]
  node_doc_state["Document state"]
  node_format_parsers["Format parsers"]
  node_parser_worker["Parser worker bridge<br/>[parserWorker.js]"]
  node_parser_worker_runtime["Parser worker<br/>[parser.worker.js]"]
  node_pdf_analysis["PDF analysis<br/>[pdfAnalysis.js]"]
  node_markdown_parser["Markdown parser"]
  node_text_structure["Text structure detection<br/>[detectStructure.js]"]
end

subgraph group_identity["Accounts and plans"]
  node_auth["Authentication context<br/>[AuthContext.jsx]"]
  node_subscription["Subscription state<br/>[useSubscription.js]"]
  node_checkout["Checkout sessions<br/>[index.ts]"]
  node_billing_webhook["Billing lifecycle<br/>[index.ts]"]
end

subgraph group_data["Persistence and services"]
  node_cloud_docs["Cloud documents<br/>[cloudDocs.js]"]
  node_supabase["Supabase client<br/>[supabase.js]"]
  node_local_storage[("Browser storage<br/>[storage.js]")]
end

subgraph group_operations["Library and operations"]
  node_library["Book library<br/>[useLibrary.js]"]
  node_admin["Admin panel<br/>[AdminPanel.jsx]"]
  node_analytics["Event tracking<br/>[track.js]"]
end

node_user(("Reader"))
node_supabase_service[("Supabase service")]
node_stripe["Stripe"]

node_user -->|"opens reader"| node_reader
node_reader -->|"manages documents"| node_doc_state
node_doc_state -->|"parses uploads"| node_format_parsers
node_format_parsers -->|"offloads parsing"| node_parser_worker
node_parser_worker -->|"dispatches jobs"| node_parser_worker_runtime
node_parser_worker_runtime -->|"analyzes PDFs"| node_pdf_analysis
node_parser_worker_runtime -->|"parses Markdown"| node_markdown_parser
node_parser_worker_runtime -->|"structures text"| node_text_structure
node_reader -->|"renders document"| node_reader_ui
node_reader -->|"controls pacing"| node_pacer
node_pacer -->|"indexes words"| node_pacer_index
node_reader -->|"loads positions"| node_cloud_docs
node_doc_state -->|"opens library books"| node_cloud_docs
node_reader -->|"uses account state"| node_auth
node_reader -->|"uses plan state"| node_subscription
node_auth -->|"authenticates"| node_supabase
node_auth -->|"sets user scope"| node_local_storage
node_subscription -->|"reads plan data"| node_supabase
node_pacer -->|"saves settings"| node_local_storage
node_cloud_docs -->|"reads cloud documents"| node_supabase
node_reader -->|"uses library"| node_library
node_admin -->|"manages profiles"| node_supabase
node_reader -->|"tracks events"| node_analytics
node_analytics -->|"writes events"| node_supabase
node_checkout -.->|"creates sessions"| node_stripe
node_billing_webhook -.->|"handles lifecycle"| node_stripe
node_supabase -->|"connects to"| node_supabase_service

click node_reader "https://github.com/doosemavis/tailormytext/blob/main/src/App.jsx"
click node_reader_ui "https://github.com/doosemavis/tailormytext/blob/main/src/components/DocumentBody.jsx"
click node_pacer "https://github.com/doosemavis/tailormytext/blob/main/src/hooks/usePacer.js"
click node_pacer_index "https://github.com/doosemavis/tailormytext/blob/main/src/utils/pacer/wordIndex.js"
click node_doc_state "https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useDocumentState.js"
click node_format_parsers "https://github.com/doosemavis/tailormytext/tree/main/src/utils"
click node_parser_worker "https://github.com/doosemavis/tailormytext/blob/main/src/utils/parserWorker.js"
click node_parser_worker_runtime "https://github.com/doosemavis/tailormytext/blob/main/src/workers/parser.worker.js"
click node_pdf_analysis "https://github.com/doosemavis/tailormytext/blob/main/src/workers/pdfAnalysis.js"
click node_markdown_parser "https://github.com/doosemavis/tailormytext/blob/main/src/utils/parseMarkdownTokens.js"
click node_text_structure "https://github.com/doosemavis/tailormytext/blob/main/src/utils/detectStructure.js"
click node_auth "https://github.com/doosemavis/tailormytext/blob/main/src/contexts/AuthContext.jsx"
click node_subscription "https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useSubscription.js"
click node_checkout "https://github.com/doosemavis/tailormytext/blob/main/supabase/functions/create-checkout-session/index.ts"
click node_billing_webhook "https://github.com/doosemavis/tailormytext/blob/main/supabase/functions/stripe-webhook/index.ts"
click node_cloud_docs "https://github.com/doosemavis/tailormytext/blob/main/src/utils/cloudDocs.js"
click node_supabase "https://github.com/doosemavis/tailormytext/blob/main/src/utils/supabase.js"
click node_local_storage "https://github.com/doosemavis/tailormytext/blob/main/src/utils/storage.js"
click node_library "https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useLibrary.js"
click node_admin "https://github.com/doosemavis/tailormytext/blob/main/src/pages/AdminPanel.jsx"
click node_analytics "https://github.com/doosemavis/tailormytext/blob/main/src/utils/track.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_reader,node_reader_ui,node_pacer,node_pacer_index toneBlue
class node_doc_state,node_format_parsers,node_parser_worker,node_parser_worker_runtime,node_pdf_analysis,node_markdown_parser,node_text_structure,node_supabase_service toneAmber
class node_auth,node_subscription,node_checkout,node_billing_webhook toneMint
class node_cloud_docs,node_supabase,node_local_storage toneRose
class node_library,node_admin,node_analytics,node_user,node_stripe toneIndigo
```

## Components

### Reading experience

- [Reader app](https://github.com/doosemavis/tailormytext/blob/main/src/App.jsx): `src/App.jsx`
- [Reader components](https://github.com/doosemavis/tailormytext/blob/main/src/components/DocumentBody.jsx): `src/components/DocumentBody.jsx`
- [Word pacer](https://github.com/doosemavis/tailormytext/blob/main/src/hooks/usePacer.js): `src/hooks/usePacer.js`
- [Word indexing](https://github.com/doosemavis/tailormytext/blob/main/src/utils/pacer/wordIndex.js): `src/utils/pacer/wordIndex.js`

### Document processing

- [Document state](https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useDocumentState.js): `src/hooks/useDocumentState.js`
- [Format parsers](https://github.com/doosemavis/tailormytext/tree/main/src/utils): `src/utils`
- [Parser worker bridge](https://github.com/doosemavis/tailormytext/blob/main/src/utils/parserWorker.js): `src/utils/parserWorker.js`
- [Parser worker](https://github.com/doosemavis/tailormytext/blob/main/src/workers/parser.worker.js): `src/workers/parser.worker.js`
- [PDF analysis](https://github.com/doosemavis/tailormytext/blob/main/src/workers/pdfAnalysis.js): `src/workers/pdfAnalysis.js`
- [Markdown parser](https://github.com/doosemavis/tailormytext/blob/main/src/utils/parseMarkdownTokens.js): `src/utils/parseMarkdownTokens.js`
- [Text structure detection](https://github.com/doosemavis/tailormytext/blob/main/src/utils/detectStructure.js): `src/utils/detectStructure.js`

### Accounts and plans

- [Authentication context](https://github.com/doosemavis/tailormytext/blob/main/src/contexts/AuthContext.jsx): `src/contexts/AuthContext.jsx`
- [Subscription state](https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useSubscription.js): `src/hooks/useSubscription.js`
- [Checkout sessions](https://github.com/doosemavis/tailormytext/blob/main/supabase/functions/create-checkout-session/index.ts): `supabase/functions/create-checkout-session/index.ts`
- [Billing lifecycle](https://github.com/doosemavis/tailormytext/blob/main/supabase/functions/stripe-webhook/index.ts): `supabase/functions/stripe-webhook/index.ts`

### Persistence and services

- [Cloud documents](https://github.com/doosemavis/tailormytext/blob/main/src/utils/cloudDocs.js): `src/utils/cloudDocs.js`
- [Supabase client](https://github.com/doosemavis/tailormytext/blob/main/src/utils/supabase.js): `src/utils/supabase.js`
- [Browser storage](https://github.com/doosemavis/tailormytext/blob/main/src/utils/storage.js): `src/utils/storage.js`

### Library and operations

- [Book library](https://github.com/doosemavis/tailormytext/blob/main/src/hooks/useLibrary.js): `src/hooks/useLibrary.js`
- [Admin panel](https://github.com/doosemavis/tailormytext/blob/main/src/pages/AdminPanel.jsx): `src/pages/AdminPanel.jsx`
- [Event tracking](https://github.com/doosemavis/tailormytext/blob/main/src/utils/track.js): `src/utils/track.js`

### Other components

- **Reader**
- **Supabase service**
- **Stripe**

## Connections

- Reader → Reader app: opens reader
- Reader app → Document state: manages documents (evidence: `src/App.jsx`)
- Document state → Format parsers: parses uploads (evidence: `src/hooks/useDocumentState.js`)
- Format parsers → Parser worker bridge: offloads parsing (evidence: `src/utils/index.js`)
- Parser worker bridge → Parser worker: dispatches jobs (evidence: `src/utils/parserWorker.js`)
- Parser worker → PDF analysis: analyzes PDFs (evidence: `src/workers/parser.worker.js`)
- Parser worker → Markdown parser: parses Markdown (evidence: `src/workers/parser.worker.js`)
- Parser worker → Text structure detection: structures text (evidence: `src/workers/parser.worker.js`)
- Reader app → Reader components: renders document (evidence: `src/App.jsx`)
- Reader app → Word pacer: controls pacing (evidence: `src/App.jsx`)
- Word pacer → Word indexing: indexes words (evidence: `src/hooks/usePacer.js`)
- Reader app → Cloud documents: loads positions (evidence: `src/App.jsx`)
- Document state → Cloud documents: opens library books (evidence: `src/hooks/useDocumentState.js`)
- Reader app → Authentication context: uses account state (evidence: `src/App.jsx`)
- Reader app → Subscription state: uses plan state (evidence: `src/App.jsx`)
- Authentication context → Supabase client: authenticates (evidence: `src/contexts/AuthContext.jsx`)
- Authentication context → Browser storage: sets user scope (evidence: `src/contexts/AuthContext.jsx`)
- Subscription state → Supabase client: reads plan data (evidence: `src/hooks/useSubscription.js`)
- Word pacer → Browser storage: saves settings (evidence: `src/hooks/usePacer.js`)
- Cloud documents → Supabase client: reads cloud documents (evidence: `src/utils/cloudDocs.js`)
- Reader app → Book library: uses library (evidence: `src/App.jsx`)
- Admin panel → Supabase client: manages profiles (evidence: `src/pages/AdminPanel.jsx`)
- Reader app → Event tracking: tracks events (evidence: `src/App.jsx`)
- Event tracking → Supabase client: writes events (evidence: `src/utils/track.js`)
- Checkout sessions → Stripe: creates sessions (evidence: `README.md`)
- Billing lifecycle → Stripe: handles lifecycle (evidence: `README.md`)
- Supabase client → Supabase service: connects to (evidence: `src/utils/supabase.js`)
