# yousefdg005/terms-web architecture

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

- Interactive diagram: https://gitdiagram.com/yousefdg005/terms-web
- Repository: https://github.com/yousefdg005/terms-web

## Overview

AI Legal Workspace is a Streamlit application for aligning Arabic–English legal text and extracting structured legal terminology. Users upload documents, prepare aligned bilingual units in the interactive studio, then provide the alignment to AI extraction and export terminology or translation-memory results. The implementation is concentrated in app.py; the README documents additional export and model capabilities. The excerpts show parts of the alignment and extraction flow, but not every parser, prompt, or export implementation.

Main entry points: [`app.py`](https://github.com/yousefdg005/terms-web/blob/main/app.py) (Streamlit workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Document preparation"]
  node_workspace["Streamlit workspace<br/>[app.py]"]
  node_pdf_extract["PDF text extraction<br/>[app.py]"]
  node_segment["Text segmentation<br/>[app.py]"]
end

subgraph group_align["Alignment studio"]
  node_alignment_ui["Alignment editor<br/>[app.py]"]
  node_alignment_state[("Aligned pairs<br/>[app.py]")]
  node_tmx_export["TMX generation<br/>[app.py]"]
end

subgraph group_terms["AI terminology"]
  node_tmx_upload["TMX parsing<br/>[app.py]"]
  node_prompting["Legal prompt<br/>[app.py]"]
  node_ai_extraction["Term extraction<br/>[app.py]"]
end

subgraph group_outputs["Export and presentation"]
  node_term_results[("Term results<br/>[app.py]")]
  node_excel_export["Excel glossary<br/>[app.py]"]
  node_pdf_cards["PDF term cards<br/>[app.py]"]
end

node_user(("Workspace user"))
node_openrouter{{"OpenRouter models"}}

node_user -->|"uses"| node_workspace
node_workspace -->|"accepts PDFs"| node_pdf_extract
node_pdf_extract -->|"extracts text"| node_segment
node_workspace -->|"prepares text"| node_segment
node_workspace -->|"opens studio"| node_alignment_ui
node_segment -->|"provides segments"| node_alignment_ui
node_alignment_ui -->|"updates pairs"| node_alignment_state
node_workspace -->|"exports alignment"| node_tmx_export
node_alignment_state -->|"serializes pairs"| node_tmx_export
node_workspace -->|"accepts TMX"| node_tmx_upload
node_tmx_export -.->|"supplies alignment"| node_tmx_upload
node_workspace -->|"prepares instructions"| node_prompting
node_workspace -->|"runs extraction"| node_ai_extraction
node_tmx_upload -.->|"provides bilingual pairs"| node_ai_extraction
node_prompting -->|"guides extraction"| node_ai_extraction
node_ai_extraction -.->|"queries models"| node_openrouter
node_ai_extraction -->|"parses terms"| node_term_results
node_workspace -->|"exports glossary"| node_excel_export
node_term_results -.->|"formats terms"| node_excel_export
node_workspace -->|"exports cards"| node_pdf_cards
node_term_results -.->|"renders terms"| node_pdf_cards

click node_workspace "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_pdf_extract "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_segment "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_alignment_ui "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_alignment_state "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_tmx_export "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_tmx_upload "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_prompting "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_ai_extraction "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_term_results "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_excel_export "https://github.com/yousefdg005/terms-web/blob/main/app.py"
click node_pdf_cards "https://github.com/yousefdg005/terms-web/blob/main/app.py"

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_workspace,node_pdf_extract,node_segment,node_user toneBlue
class node_alignment_ui,node_alignment_state,node_tmx_export toneAmber
class node_tmx_upload,node_prompting,node_ai_extraction,node_openrouter toneMint
class node_term_results,node_excel_export,node_pdf_cards toneRose
```

## Components

### Document preparation

- [Streamlit workspace](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [PDF text extraction](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [Text segmentation](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`

### Alignment studio

- [Alignment editor](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [Aligned pairs](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [TMX generation](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`

### AI terminology

- [TMX parsing](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [Legal prompt](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [Term extraction](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`

### Export and presentation

- [Term results](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [Excel glossary](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`
- [PDF term cards](https://github.com/yousefdg005/terms-web/blob/main/app.py): `app.py`

### Other components

- **Workspace user**
- **OpenRouter models**

## Connections

- Workspace user → Streamlit workspace: uses (evidence: `README.md`)
- Streamlit workspace → PDF text extraction: accepts PDFs (evidence: `app.py`)
- PDF text extraction → Text segmentation: extracts text (evidence: `app.py`)
- Streamlit workspace → Text segmentation: prepares text (evidence: `app.py`)
- Streamlit workspace → Alignment editor: opens studio (evidence: `app.py`)
- Text segmentation → Alignment editor: provides segments (evidence: `app.py`)
- Alignment editor → Aligned pairs: updates pairs (evidence: `app.py`)
- Streamlit workspace → TMX generation: exports alignment (evidence: `app.py`)
- Aligned pairs → TMX generation: serializes pairs (evidence: `README.md`)
- Streamlit workspace → TMX parsing: accepts TMX (evidence: `README.md`)
- TMX generation → TMX parsing: supplies alignment (evidence: `README.md`)
- Streamlit workspace → Legal prompt: prepares instructions (evidence: `README.md`)
- Streamlit workspace → Term extraction: runs extraction (evidence: `app.py`)
- TMX parsing → Term extraction: provides bilingual pairs (evidence: `README.md`)
- Legal prompt → Term extraction: guides extraction (evidence: `README.md`)
- Term extraction → OpenRouter models: queries models (evidence: `README.md`)
- Term extraction → Term results: parses terms (evidence: `app.py`)
- Streamlit workspace → Excel glossary: exports glossary (evidence: `README.md`)
- Term results → Excel glossary: formats terms (evidence: `README.md`)
- Streamlit workspace → PDF term cards: exports cards (evidence: `README.md`)
- Term results → PDF term cards: renders terms (evidence: `README.md`)
