# mouryaveer/docgen-integrated-t2l architecture

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

- Interactive diagram: https://gitdiagram.com/mouryaveer/docgen-integrated-t2l
- Repository: https://github.com/mouryaveer/docgen-integrated-t2l

## Overview

Turn2Law is a legal-document platform: users choose a template or upload an input, provide document details and branding, generate and preview a PDF, then optionally validate a certificate and sign it. The README documents this workflow and the two-service proxy arrangement; sampled source confirms wizard persistence, frontend API calls, proxy security checks, and backend generation/branding behavior. Backend API wiring and several documented capabilities are represented at the documented level because their implementation was not sampled.

Main entry points: [`documentGeneration-master/docgen/app.py`](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/app.py) (Generation core), [`documentGeneration-master/docgen/api.py`](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/api.py) (FastAPI endpoints), [`T2L-site-main/app/components/DocEngineStandalone/DocEngineStandaloneApp.tsx`](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DocEngineStandalone/DocEngineStandaloneApp.tsx) (Document wizard), [`T2L-site-main/app/services/docengine.ts`](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/services/docengine.ts) (Engine API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend workflow"]
  node_wizard["Document wizard"]
  node_dashboard["Dashboard workspace"]
  node_persistence["Document records"]
  node_store["Local document store<br/>[documentStore.ts]"]
  node_service["Engine API client<br/>[docengine.ts]"]
end

subgraph group_gateway["API gateway"]
  node_api_route["Engine API route<br/>[route.ts]"]
  node_file_route["File route<br/>[route.ts]"]
  node_proxy["Secure engine proxy<br/>[engine-proxy.ts]"]
end

subgraph group_document["Document engine"]
  node_backend_api["FastAPI endpoints<br/>[api.py]"]
  node_core["Generation core<br/>[app.py]"]
  node_classify["Input classification<br/>[classify.py]"]
  node_extract["Document extractors"]
  node_render["PDF generation<br/>[generate.py]"]
  node_branding["Branding engine<br/>[branding_engine.py]"]
  node_signing["PDF signatures<br/>[signer.py]"]
  node_pdf_files["Generated PDFs"]
end

subgraph group_other["Other product tools"]
  node_introspector_ui["Document introspector"]
  node_introspector_route["Introspector API route<br/>[route.ts]"]
  node_introspector_service["Introspector service"]
  node_resources["Legal resource hub<br/>[Resources.tsx]"]
end

node_user(("User"))
node_gemini{{"Google Gemini"}}
node_xelatex{{"XeLaTeX"}}

node_user -->|"enters details"| node_wizard
node_user -->|"opens workspace"| node_dashboard
node_wizard -->|"requests engine"| node_service
node_dashboard -->|"requests engine"| node_service
node_service -->|"sends API calls"| node_api_route
node_api_route -->|"dispatches request"| node_proxy
node_file_route -->|"dispatches file request"| node_proxy
node_proxy -->|"forwards request"| node_backend_api
node_backend_api -->|"invokes generation"| node_core
node_core -->|"extracts input text"| node_extract
node_core -->|"classifies input"| node_classify
node_classify -.->|"requests classification"| node_gemini
node_core -->|"resolves branding"| node_branding
node_core -->|"renders document"| node_render
node_render -->|"compiles LaTeX"| node_xelatex
node_backend_api -->|"signs requested PDF"| node_signing
node_backend_api -->|"stores and serves PDFs"| node_pdf_files
node_pdf_files -->|"returns PDF files"| node_file_route
node_wizard -->|"emits document events"| node_persistence
node_persistence -->|"updates records"| node_store
node_user -->|"submits query"| node_introspector_ui
node_introspector_ui -->|"sends query"| node_introspector_route
node_introspector_route -->|"forwards query"| node_introspector_service
node_user -->|"browses resources"| node_resources

click node_wizard "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DocEngineStandalone/DocEngineStandaloneApp.tsx"
click node_dashboard "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DashboardDocEngine/DocEngineWorkspace.tsx"
click node_persistence "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DocEngine/DocEngineExperience.tsx"
click node_store "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/store/documentStore.ts"
click node_service "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/services/docengine.ts"
click node_api_route "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/api/docengine/%5B...path%5D/route.ts"
click node_file_route "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/files/%5B...path%5D/route.ts"
click node_proxy "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/lib/engine-proxy.ts"
click node_backend_api "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/api.py"
click node_core "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/app.py"
click node_classify "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/classifier/classify.py"
click node_extract "https://github.com/mouryaveer/docgen-integrated-t2l/tree/main/documentGeneration-master/docgen/extractors"
click node_render "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/generators/generate.py"
click node_branding "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/branding/branding_engine.py"
click node_signing "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/digital_signature/signer.py"
click node_pdf_files "https://github.com/mouryaveer/docgen-integrated-t2l/tree/main/documentGeneration-master/docgen"
click node_introspector_ui "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/Introspector/IntrospectorChat.tsx"
click node_introspector_route "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/api/introspector/route.ts"
click node_resources "https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/pages/Resources.tsx"

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_wizard,node_dashboard,node_persistence,node_store,node_service,node_user toneBlue
class node_api_route,node_file_route,node_proxy toneAmber
class node_backend_api,node_core,node_classify,node_extract,node_render,node_branding,node_signing,node_pdf_files toneMint
class node_introspector_ui,node_introspector_route,node_introspector_service,node_resources toneRose
class node_gemini,node_xelatex toneIndigo
```

## Components

### Frontend workflow

- [Document wizard](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DocEngineStandalone/DocEngineStandaloneApp.tsx): `T2L-site-main/app/components/DocEngineStandalone/DocEngineStandaloneApp.tsx`
- [Dashboard workspace](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DashboardDocEngine/DocEngineWorkspace.tsx): `T2L-site-main/app/components/DashboardDocEngine/DocEngineWorkspace.tsx`
- [Document records](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/DocEngine/DocEngineExperience.tsx): `T2L-site-main/app/components/DocEngine/DocEngineExperience.tsx`
- [Local document store](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/store/documentStore.ts): `T2L-site-main/app/store/documentStore.ts`
- [Engine API client](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/services/docengine.ts): `T2L-site-main/app/services/docengine.ts`

### API gateway

- [Engine API route](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/api/docengine/%5B...path%5D/route.ts): `T2L-site-main/app/api/docengine/[...path]/route.ts`
- [File route](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/files/%5B...path%5D/route.ts): `T2L-site-main/app/files/[...path]/route.ts`
- [Secure engine proxy](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/lib/engine-proxy.ts): `T2L-site-main/lib/engine-proxy.ts`

### Document engine

- [FastAPI endpoints](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/api.py): `documentGeneration-master/docgen/api.py`
- [Generation core](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/app.py): `documentGeneration-master/docgen/app.py`
- [Input classification](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/classifier/classify.py): `documentGeneration-master/docgen/classifier/classify.py`
- [Document extractors](https://github.com/mouryaveer/docgen-integrated-t2l/tree/main/documentGeneration-master/docgen/extractors): `documentGeneration-master/docgen/extractors`
- [PDF generation](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/generators/generate.py): `documentGeneration-master/docgen/generators/generate.py`
- [Branding engine](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/branding/branding_engine.py): `documentGeneration-master/docgen/branding/branding_engine.py`
- [PDF signatures](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/documentGeneration-master/docgen/digital_signature/signer.py): `documentGeneration-master/docgen/digital_signature/signer.py`
- [Generated PDFs](https://github.com/mouryaveer/docgen-integrated-t2l/tree/main/documentGeneration-master/docgen): `documentGeneration-master/docgen`

### Other product tools

- [Document introspector](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/components/Introspector/IntrospectorChat.tsx): `T2L-site-main/app/components/Introspector/IntrospectorChat.tsx`
- [Introspector API route](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/api/introspector/route.ts): `T2L-site-main/app/api/introspector/route.ts`
- **Introspector service**
- [Legal resource hub](https://github.com/mouryaveer/docgen-integrated-t2l/blob/main/T2L-site-main/app/pages/Resources.tsx): `T2L-site-main/app/pages/Resources.tsx`

### Other components

- **User**
- **Google Gemini**
- **XeLaTeX**

## Connections

- User → Document wizard: enters details
- User → Dashboard workspace: opens workspace
- Document wizard → Engine API client: requests engine
- Dashboard workspace → Engine API client: requests engine
- Engine API client → Engine API route: sends API calls
- Engine API route → Secure engine proxy: dispatches request
- File route → Secure engine proxy: dispatches file request
- Secure engine proxy → FastAPI endpoints: forwards request
- FastAPI endpoints → Generation core: invokes generation
- Generation core → Document extractors: extracts input text
- Generation core → Input classification: classifies input
- Input classification → Google Gemini: requests classification
- Generation core → Branding engine: resolves branding
- Generation core → PDF generation: renders document
- PDF generation → XeLaTeX: compiles LaTeX
- FastAPI endpoints → PDF signatures: signs requested PDF
- FastAPI endpoints → Generated PDFs: stores and serves PDFs
- Generated PDFs → File route: returns PDF files
- Document wizard → Document records: emits document events
- Document records → Local document store: updates records
- User → Document introspector: submits query
- Document introspector → Introspector API route: sends query
- Introspector API route → Introspector service: forwards query
- User → Legal resource hub: browses resources
