# sirrom2005/law architecture

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

- Interactive diagram: https://gitdiagram.com/sirrom2005/law
- Repository: https://github.com/sirrom2005/law

## Overview

LegalDocs is a web product for assembling jurisdiction-aware legal documents, selling them, and providing paid-document access. The main customer journey runs from catalog discovery through guided answers, preview, checkout, and PDF retrieval; execution guidance is included, but signing is physical rather than electronic. The graph also captures account/library and content-review capabilities evident in the tree and sampled pages. Several routes and integrations are unsampled, so uncertain wiring is omitted.

Main entry points: [`apis/db.php`](https://github.com/sirrom2005/law/blob/master/apis/db.php) (Application Database), [`preview.php`](https://github.com/sirrom2005/law/blob/master/preview.php) (Document Preview), [`legal-document-builder/builder.php`](https://github.com/sirrom2005/law/blob/master/legal-document-builder/builder.php) (Guided Questionnaire), [`legal-document-builder/index.php`](https://github.com/sirrom2005/law/blob/master/legal-document-builder/index.php) (Select Jurisdiction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery &amp; Accounts"]
  node_catalog["Document Catalog<br/>[catalog.php]"]
  node_document_info["Document Details<br/>[document.php]"]
  node_account["Account &amp; Login<br/>[account.php]"]
end

subgraph group_drafting["Document Drafting"]
  node_builder_start["Select Jurisdiction<br/>[index.php]"]
  node_builder["Guided Questionnaire<br/>[builder.php]"]
  node_questions_api["Question Data<br/>[questions.php]"]
  node_answer_tracking["Answer Session<br/>[track-answer.php]"]
  node_jurisdiction_api["Country Data<br/>[countries.php]"]
  node_preview["Document Preview<br/>[preview.php]"]
  node_template_api["Template Data<br/>[template.php]"]
  node_signing_api["Signing Requirements"]
  node_save_draft["Save Draft API<br/>[save-draft.php]"]
  node_document_persistence["Document Persistence<br/>[document-save.php]"]
end

subgraph group_commerce["Orders &amp; Delivery"]
  node_checkout["Checkout<br/>[checkout.php]"]
  node_payment["Payment Handling<br/>[payment.php]"]
  node_payment_provider["Payment Provider"]
  node_orders["Orders<br/>[orders.php]"]
  node_library["Document Library<br/>[library.php]"]
  node_pdf["PDF Generation<br/>[pdf.php]"]
  node_pdf_route["PDF Download<br/>[document-pdf.php]"]
end

subgraph group_operations["Content Operations"]
  node_admin_templates["Template Management<br/>[templates.php]"]
  node_admin_review["Legal Review<br/>[review.php]"]
end

node_customer(("Customer"))
node_database[("Application Database<br/>[db.php]")]

node_customer -->|"browse"| node_catalog
node_catalog -->|"view details"| node_document_info
node_customer -->|"start drafting"| node_builder_start
node_builder_start -->|"loads countries"| node_jurisdiction_api
node_builder_start -->|"records selection"| node_answer_tracking
node_builder -->|"loads questions"| node_questions_api
node_builder -->|"records answers"| node_answer_tracking
node_builder -->|"saves draft"| node_save_draft
node_builder -->|"opens preview"| node_preview
node_preview -->|"loads template"| node_template_api
node_preview -->|"loads requirements"| node_signing_api
node_preview -->|"saves preview"| node_save_draft
node_save_draft -->|"persists document"| node_document_persistence
node_document_persistence -->|"writes drafts and orders"| node_database
node_preview -->|"continues to checkout"| node_checkout
node_checkout -->|"initiates payment"| node_payment
node_payment -.->|"processes payment"| node_payment_provider
node_payment -->|"records payment"| node_database
node_customer -->|"manages account"| node_account
node_customer -->|"views orders"| node_orders
node_customer -->|"opens documents"| node_library
node_library -->|"reads saved documents"| node_database
node_pdf_route -->|"generates PDF"| node_pdf
node_pdf -->|"reads document data"| node_database
node_customer -->|"downloads document"| node_pdf_route
node_admin_templates -->|"manages templates"| node_database
node_admin_review -->|"reviews versions"| node_database

click node_catalog "https://github.com/sirrom2005/law/blob/master/catalog.php"
click node_document_info "https://github.com/sirrom2005/law/blob/master/document.php"
click node_account "https://github.com/sirrom2005/law/blob/master/account.php"
click node_builder_start "https://github.com/sirrom2005/law/blob/master/legal-document-builder/index.php"
click node_builder "https://github.com/sirrom2005/law/blob/master/legal-document-builder/builder.php"
click node_questions_api "https://github.com/sirrom2005/law/blob/master/apis/questions.php"
click node_answer_tracking "https://github.com/sirrom2005/law/blob/master/legal-document-builder/track-answer.php"
click node_jurisdiction_api "https://github.com/sirrom2005/law/blob/master/apis/countries.php"
click node_preview "https://github.com/sirrom2005/law/blob/master/preview.php"
click node_template_api "https://github.com/sirrom2005/law/blob/master/apis/template.php"
click node_signing_api "https://github.com/sirrom2005/law/blob/master/apis/signing_requirements.php"
click node_save_draft "https://github.com/sirrom2005/law/blob/master/apis/save-draft.php"
click node_document_persistence "https://github.com/sirrom2005/law/blob/master/includes/document-save.php"
click node_checkout "https://github.com/sirrom2005/law/blob/master/checkout.php"
click node_payment "https://github.com/sirrom2005/law/blob/master/includes/payment.php"
click node_orders "https://github.com/sirrom2005/law/blob/master/orders.php"
click node_library "https://github.com/sirrom2005/law/blob/master/library.php"
click node_pdf "https://github.com/sirrom2005/law/blob/master/includes/pdf.php"
click node_pdf_route "https://github.com/sirrom2005/law/blob/master/document-pdf.php"
click node_admin_templates "https://github.com/sirrom2005/law/blob/master/admin/templates.php"
click node_admin_review "https://github.com/sirrom2005/law/blob/master/admin/review.php"
click node_database "https://github.com/sirrom2005/law/blob/master/apis/db.php"

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_catalog,node_document_info,node_account toneBlue
class node_builder_start,node_builder,node_questions_api,node_answer_tracking,node_jurisdiction_api,node_preview,node_template_api,node_signing_api,node_save_draft,node_document_persistence,node_database toneAmber
class node_checkout,node_payment,node_payment_provider,node_orders,node_library,node_pdf,node_pdf_route toneMint
class node_admin_templates,node_admin_review toneRose
class node_customer toneIndigo
```

## Components

### Discovery & Accounts

- [Document Catalog](https://github.com/sirrom2005/law/blob/master/catalog.php): `catalog.php`
- [Document Details](https://github.com/sirrom2005/law/blob/master/document.php): `document.php`
- [Account & Login](https://github.com/sirrom2005/law/blob/master/account.php): `account.php`

### Document Drafting

- [Select Jurisdiction](https://github.com/sirrom2005/law/blob/master/legal-document-builder/index.php): `legal-document-builder/index.php`
- [Guided Questionnaire](https://github.com/sirrom2005/law/blob/master/legal-document-builder/builder.php): `legal-document-builder/builder.php`
- [Question Data](https://github.com/sirrom2005/law/blob/master/apis/questions.php): `apis/questions.php`
- [Answer Session](https://github.com/sirrom2005/law/blob/master/legal-document-builder/track-answer.php): `legal-document-builder/track-answer.php`
- [Country Data](https://github.com/sirrom2005/law/blob/master/apis/countries.php): `apis/countries.php`
- [Document Preview](https://github.com/sirrom2005/law/blob/master/preview.php): `preview.php`
- [Template Data](https://github.com/sirrom2005/law/blob/master/apis/template.php): `apis/template.php`
- [Signing Requirements](https://github.com/sirrom2005/law/blob/master/apis/signing_requirements.php): `apis/signing_requirements.php`
- [Save Draft API](https://github.com/sirrom2005/law/blob/master/apis/save-draft.php): `apis/save-draft.php`
- [Document Persistence](https://github.com/sirrom2005/law/blob/master/includes/document-save.php): `includes/document-save.php`

### Orders & Delivery

- [Checkout](https://github.com/sirrom2005/law/blob/master/checkout.php): `checkout.php`
- [Payment Handling](https://github.com/sirrom2005/law/blob/master/includes/payment.php): `includes/payment.php`
- **Payment Provider**
- [Orders](https://github.com/sirrom2005/law/blob/master/orders.php): `orders.php`
- [Document Library](https://github.com/sirrom2005/law/blob/master/library.php): `library.php`
- [PDF Generation](https://github.com/sirrom2005/law/blob/master/includes/pdf.php): `includes/pdf.php`
- [PDF Download](https://github.com/sirrom2005/law/blob/master/document-pdf.php): `document-pdf.php`

### Content Operations

- [Template Management](https://github.com/sirrom2005/law/blob/master/admin/templates.php): `admin/templates.php`
- [Legal Review](https://github.com/sirrom2005/law/blob/master/admin/review.php): `admin/review.php`

### Other components

- **Customer**
- [Application Database](https://github.com/sirrom2005/law/blob/master/apis/db.php): `apis/db.php`

## Connections

- Customer → Document Catalog: browse
- Document Catalog → Document Details: view details
- Customer → Select Jurisdiction: start drafting
- Select Jurisdiction → Country Data: loads countries
- Select Jurisdiction → Answer Session: records selection
- Guided Questionnaire → Question Data: loads questions
- Guided Questionnaire → Answer Session: records answers
- Guided Questionnaire → Save Draft API: saves draft
- Guided Questionnaire → Document Preview: opens preview
- Document Preview → Template Data: loads template
- Document Preview → Signing Requirements: loads requirements
- Document Preview → Save Draft API: saves preview
- Save Draft API → Document Persistence: persists document
- Document Persistence → Application Database: writes drafts and orders
- Document Preview → Checkout: continues to checkout
- Checkout → Payment Handling: initiates payment
- Payment Handling → Payment Provider: processes payment
- Payment Handling → Application Database: records payment
- Customer → Account & Login: manages account
- Customer → Orders: views orders
- Customer → Document Library: opens documents
- Document Library → Application Database: reads saved documents
- PDF Download → PDF Generation: generates PDF
- PDF Generation → Application Database: reads document data
- Customer → PDF Download: downloads document
- Template Management → Application Database: manages templates
- Legal Review → Application Database: reviews versions
