par-term 0.30.3

Cross-platform GPU-accelerated terminal emulator with inline graphics support (Sixel, iTerm2, Kitty)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
# Documentation Style Guide

This guide establishes standards and best practices for creating and maintaining documentation in the Par Terminal Emulator project. It ensures consistency, clarity, and professionalism across all technical documentation.

## Table of Contents
- [Quick Reference]#quick-reference
- [Document Structure]#document-structure
- [Writing Style]#writing-style
- [Diagram Standards]#diagram-standards
- [Color Scheme]#color-scheme
- [Code Examples]#code-examples
- [API Documentation]#api-documentation
- [File Organization]#file-organization
- [Maintenance]#maintenance
- [Review Checklist]#review-checklist

## Quick Reference

### Essential Rules
- **Never use ASCII art** - Always use Mermaid diagrams
- **Always include a TOC** for documents > 500 words
- **Use dark backgrounds** with white text in diagrams
- **Specify language** in all code blocks
- **Test all examples** before documenting
- **Update cross-references** when modifying content
- **Never use line numbers** in file references - They're brittle and hard to maintain
- **Do not store package versions** in documentation - Version numbers are brittle and difficult to maintain

## Document Structure

### Required Elements

Every documentation file MUST include:

1. **Title (H1)**: Clear, descriptive title that immediately identifies the document's purpose
2. **Brief Description**: 1-2 sentence summary immediately after the title
3. **Table of Contents**: Required for documents > 500 words or > 3 main sections
4. **Overview Section**: Context and scope of the document
5. **Main Content**: Logical sections with proper hierarchy
6. **Related Documentation**: Links to relevant resources at the end

### Document Template

```markdown
# Document Title

Brief description of what this document covers and its intended audience.

## Table of Contents
- [Overview]#overview
- [Prerequisites]#prerequisites
- [Main Topic]#main-topic
  - [Subtopic 1]#subtopic-1
  - [Subtopic 2]#subtopic-2
- [Examples]#examples
- [Troubleshooting]#troubleshooting
- [Related Documentation]#related-documentation

## Overview

Detailed introduction providing context, scope, and objectives...

## Prerequisites

What the reader needs to know or have before proceeding...

[Main content sections...]

## Related Documentation

- [Relevant Doc 1]../docs/relevant-doc-1.md - Brief description
- [Relevant Doc 2]../docs/relevant-doc-2.md - Brief description
```

### Section Hierarchy

| Level | Usage | Markdown | Example |
|-------|-------|----------|---------|
| H1 | Document title only | `#` | `# API Documentation` |
| H2 | Main sections | `##` | `## Authentication` |
| H3 | Subsections | `###` | `### OAuth Flow` |
| H4 | Minor divisions | `####` | `#### Error Codes` |
| H5+ | Avoid if possible | `#####` | Use lists instead |

### Information Architecture Flow

```mermaid
graph TD
    Title[Document Title - H1]
    Overview[Overview - H2]
    Main[Main Content - H2]
    Sub1[Subsection 1 - H3]
    Sub2[Subsection 2 - H3]
    Details[Details - H4]
    Examples[Examples - H2]
    Trouble[Troubleshooting - H2]
    Related[Related Docs - H2]

    Title --> Overview
    Overview --> Main
    Main --> Sub1
    Main --> Sub2
    Sub1 --> Details
    Main --> Examples
    Examples --> Trouble
    Trouble --> Related

    style Title fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style Overview fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    style Main fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    style Sub1 fill:#37474f,stroke:#78909c,stroke-width:2px,color:#ffffff
    style Sub2 fill:#37474f,stroke:#78909c,stroke-width:2px,color:#ffffff
    style Details fill:#37474f,stroke:#78909c,stroke-width:1px,color:#ffffff
    style Examples fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
    style Trouble fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#ffffff
    style Related fill:#880e4f,stroke:#c2185b,stroke-width:2px,color:#ffffff
```

## Diagram Standards

### Always Use Mermaid

**NEVER use ASCII art diagrams.** Always use Mermaid for:
- Architecture diagrams
- Flow charts
- Sequence diagrams
- State diagrams
- Entity relationship diagrams

### Mermaid Diagram Template

```markdown
```mermaid
graph TD
    Component1[Component Name]
    Component2[Another Component]

    Component1 --> Component2

    style Component1 fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style Component2 fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
```

## Color Scheme

### High-Contrast Colors for Dark Mode Compatibility

All diagrams MUST use dark backgrounds with white text (`color:#ffffff`) for maximum contrast and readability in both light and dark modes.

### Component Color Mapping

| Component Type | Fill Color | Stroke Color | Stroke Width | Text Color | Usage |
|---------------|------------|--------------|--------------|------------|--------|
| **Primary/Main** | `#e65100` | `#ff9800` | 3px | `#ffffff` | Main components, load balancers, orchestrators |
| **Active/Healthy** | `#1b5e20` | `#4caf50` | 2px | `#ffffff` | Active backends, healthy services |
| **Success State** | `#2e7d32` | `#66bb6a` | 2px | `#ffffff` | Successful operations, active components |
| **Failed/Unhealthy** | `#b71c1c` | `#f44336` | 2px | `#ffffff` | Failed components, error states |
| **Error/Alert** | `#d32f2f` | `#ef5350` | 2px | `#ffffff` | Errors, crashed services |
| **Data Storage** | `#0d47a1` | `#2196f3` | 2px | `#ffffff` | Redis, cache layers |
| **Database** | `#1a237e` | `#3f51b5` | 2px | `#ffffff` | PostgreSQL, persistent storage |
| **Client/External** | `#4a148c` | `#9c27b0` | 2px | `#ffffff` | CLI, TUI, API clients |
| **Special/Events** | `#880e4f` | `#c2185b` | 2px | `#ffffff` | WebSocket, special protocols |
| **Neutral/Info** | `#37474f` | `#78909c` | 2px | `#ffffff` | Stopped services, info boxes |
| **Warning** | `#ff6f00` | `#ffa726` | 2px | `#ffffff` | Decision points, warnings |

### Example Color Application

```mermaid
graph TD
    LB[Load Balancer]
    Backend[Active Backend]
    Failed[Failed Backend]
    Redis[Redis Cache]
    PG[PostgreSQL]
    Client[CLI Client]

    style LB fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style Backend fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    style Failed fill:#b71c1c,stroke:#f44336,stroke-width:2px,color:#ffffff
    style Redis fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    style PG fill:#1a237e,stroke:#3f51b5,stroke-width:2px,color:#ffffff
    style Client fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
```

## Writing Style

### Core Principles

| Principle | Do | Don't |
|-----------|-----|-------|
| **Clarity** | "Click the Submit button" | "The submission interface should be utilized" |
| **Conciseness** | "Install dependencies: `npm install`" | "To install the required dependencies, run the npm install command" |
| **Active Voice** | "The API returns JSON data" | "JSON data is returned by the API" |
| **Specificity** | "Set timeout to 30 seconds" | "Set an appropriate timeout value" |
| **Consistency** | Use the same terms throughout | Mix "endpoint", "route", and "path" |

### Voice and Tone

- **Professional but approachable**: Technical accuracy without unnecessary jargon
- **Direct and actionable**: Focus on what the reader needs to do
- **Inclusive language**: Use "you" for instructions, avoid assumptions about expertise
- **Present tense**: Describe current behavior ("The system uses..." not "The system will use...")

### Formatting Standards

| Element | Format | Example | Usage |
|---------|--------|---------|-------|
| **Bold** | `**text**` | **Important:** | Key concepts, warnings, emphasis |
| *Italics* | `*text*` | *Note:* | Subtle emphasis, first use of terms |
| `Code` | `` `text` `` | `npm run dev` | Commands, file names, variables |
| ~~Strike~~ | `~~text~~` | ~~Deprecated~~ | Outdated information |
| > Quote | `> text` | > Best practice | Callouts, tips, notes |

### Text Elements

#### Commands and Code
- File paths: `/Users/bob/Repos/my-project/`
- Commands: `docker-compose up -d`
- Functions: `processEvent()`
- Classes: `WebSocketProvider`
- Variables: `DASHBOARD_SERVER_URL`
- Ports: `port 8080`

#### File References

**IMPORTANT**: When referencing files in documentation, **DO NOT include line numbers**. Line numbers are brittle and difficult to maintain as code changes.

**Good examples:**
- "The `Terminal` class in `src/terminal.rs`"
- "See the implementation in `src/python_bindings/terminal.rs`"
- "The `export_text()` method in `Terminal`"

**Bad examples:**
- ❌ "See `src/terminal.rs:816`" - line numbers change with code edits
- ❌ "Located at `/Users/probello/Repos/par-term-emu-rust/Cargo.toml:3`" - overly specific and fragile
- ❌ "The fix is in `terminal.rs` lines 100-150" - ranges become outdated quickly

**Exception**: Line numbers may be included in:
- Temporary debugging notes (marked clearly as temporary)
- Issue reports with specific commit SHA references
- Code review comments (ephemeral by nature)

#### Package Versions

**IMPORTANT**: Do not store package version numbers in documentation. Versions are brittle and difficult to maintain as dependencies are updated.

**Good examples:**
- "Requires Python 3.12+" - minimum version requirement only
- "Uses Textual framework for the TUI"
- "Built with par-term-emu-core-rust (Rust backend)"
- "Dependencies managed via pyproject.toml"

**Bad examples:**
- ❌ "Textual 6.6.0+" - specific version that will become outdated
- ❌ "PyYAML 6.0.3 for configuration" - unnecessarily specific
- ❌ "par-term-emu-core-rust 0.4.0 or later" - maintenance burden

**Why avoid version numbers:**
- Dependencies update frequently
- Documentation becomes stale and misleading
- Creates maintenance burden across all docs
- Version requirements are already defined in package manifests (pyproject.toml, requirements.txt, etc.)
- Users should reference the canonical source (package files) for version info

**Where versions ARE appropriate:**
- Release notes and changelogs
- Migration guides (e.g., "Upgrading from v1.x to v2.x")
- Troubleshooting specific version-related bugs
- Package manifest files (pyproject.toml, requirements.txt)

**Best practice**: Reference the package manifest location instead:
- "See `pyproject.toml` for current dependency versions"
- "Minimum Python version specified in `pyproject.toml`"

#### Emoji in Headings

Avoid emoji in section headings within standard documentation files (guides, references, architecture docs). Use the callout box format below for emphasis instead.

**Exception**: The `README.md` What's New / changelog sections use emoji category labels (e.g., "### Security & Safety", "### New Features") as a deliberate visual convention for the release notes format. This is an accepted exception for that specific context. New What's New sections in README.md should continue this pattern; all other documentation files should not use emoji in headings.

#### Callout Boxes

Use blockquotes with emoji indicators for different types of information:

> **📝 Note:** Additional context or information

> **⚠️ Warning:** Important caution about potential issues

> **✅ Tip:** Helpful suggestion or best practice

> **🚫 Deprecated:** Feature or method no longer recommended

> **🔒 Security:** Security-related information

### Lists and Sequences

#### Unordered Lists (Features, Options)
- Use for non-sequential items
- Keep items parallel in structure
- Start with capital letters
- End without punctuation (unless full sentences)

#### Ordered Lists (Instructions, Steps)
1. Use for sequential procedures
2. Write as complete sentences
3. Include expected outcomes where helpful
4. Number all steps (don't mix with bullets)

#### Nested Lists
- Main item
  - Sub-item with 2-space indent
    - Further nesting with 4-space indent
  - Another sub-item
- Next main item

### Acronyms and Terminology

| First Use | Subsequent Uses |
|-----------|-----------------|
| Application Programming Interface (API) | API |
| WebSocket (WS) | WS or WebSocket |
| Personally Identifiable Information (PII) | PII |
| Real-Time (RT) | RT or real-time |

### Writing Patterns

#### Describing Features
```markdown
## Feature Name

**Purpose:** One-line description of what it does

**When to use:** Specific scenarios where this feature applies

**How it works:**
1. Step-by-step explanation
2. Of the feature's operation
3. With clear outcomes

**Example:** Practical demonstration
```

#### Documenting Procedures
```markdown
### How to [Task Name]

**Prerequisites:**
- Required software installed
- Necessary permissions
- Configuration completed

**Steps:**
1. **Start the service**
   ```bash
   command to execute
   ```
   Expected output or result

2. **Configure settings**
   Description of what to configure and why

3. **Verify operation**
   How to confirm success
```

## Code Examples

### Code Block Guidelines

#### Language Specification
Always specify the language for proper syntax highlighting:

````markdown
```python
# Python with type hints
async def process_event(event: dict[str, Any]) -> EventResponse:
    """Process incoming event and return response."""
    return EventResponse(status="success", data=event)
```

```typescript
// TypeScript with interfaces
interface EventData {
  id: string;
  timestamp: Date;
  payload: Record<string, unknown>;
}
```

```bash
#!/bin/bash
# Shell script with error handling
set -euo pipefail
docker-compose up -d || exit 1
```

#### Code Annotations

Use comments to explain complex logic:

```python
# Good: Explains why, not what
cache_ttl = 300  # 5 minutes - balances freshness with API rate limits

# Avoid: Obvious comments
x = x + 1  # Increment x
```

### Command-Line Examples

#### Basic Format
```bash
# Description of what the command does
$ command --with-options

# Expected output (if relevant)
Output line 1
Output line 2
```

#### Interactive Sessions
```bash
# Start interactive session
$ python
>>> import sys
>>> sys.version
'3.12.0 (main, Oct  2 2024, 00:00:00) [GCC 11.2.0]'
>>> exit()

# Return to shell
$
```

#### Multi-Step Procedures
```bash
# Step 1: Clone the repository
$ git clone https://github.com/user/repo.git
Cloning into 'repo'...

# Step 2: Install dependencies
$ cd repo
$ npm install
added 150 packages in 3.5s

# Step 3: Run tests
$ npm test
✓ All tests passed (42 passing)
```

### Configuration Examples

#### YAML with Comments
```yaml
# Service configuration
services:
  dashboard:
    image: dashboard:latest
    ports:
      - "8080:8080"  # External:Internal port mapping
    environment:
      DEBUG: "false"  # Set to "true" for verbose logging
      DATABASE_URL: ${DATABASE_URL}  # From .env file
    volumes:
      - ./data:/app/data:rw  # Persistent storage
```

#### JSON with Schema
```json
{
  "$schema": "https://example.com/schema/v1",
  "name": "example-config",
  "version": "1.0.0",
  "settings": {
    "timeout": 30,
    "retries": 3
  }
}
```

### Error Examples

Always show both error cases and solutions:

```python
# Common error
try:
    result = risky_operation()
except SpecificError as e:
    # Bad: Silent failure
    pass

# Better approach
try:
    result = risky_operation()
except SpecificError as e:
    logger.error(f"Operation failed: {e}")
    # Provide fallback or re-raise with context
    raise OperationError(f"Could not complete task: {e}") from e
```

## API Documentation

### Endpoint Documentation Template

```markdown
### Endpoint Name

**Purpose:** Brief description of what the endpoint does

**Method:** `GET` | `POST` | `PUT` | `DELETE` | `PATCH`

**Path:** `/api/v1/resource/{id}`

**Authentication:** Required | Optional | None

#### Request

**Headers:**
| Header | Required | Description |
|--------|----------|-------------|
| Authorization | Yes | Bearer token |
| Content-Type | Yes | application/json |

**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | Resource identifier |

**Query Parameters:**
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| limit | integer | 10 | Maximum results |
| offset | integer | 0 | Pagination offset |

**Request Body:**
```json
{
  "field1": "value",
  "field2": 123
}
```

#### Response

**Success Response (200 OK):**
```json
{
  "status": "success",
  "data": {
    "id": "abc123",
    "field1": "value"
  }
}
```

**Error Response (400 Bad Request):**
```json
{
  "status": "error",
  "message": "Invalid input",
  "errors": [
    {
      "field": "field1",
      "message": "Field is required"
    }
  ]
}
```

#### Examples

**cURL:**
```bash
curl -X POST https://api.example.com/v1/resource \
  -H "Authorization: Bearer token123" \
  -H "Content-Type: application/json" \
  -d '{"field1": "value"}'
```

**Python:**
```python
import requests

response = requests.post(
    "https://api.example.com/v1/resource",
    headers={"Authorization": "Bearer token123"},
    json={"field1": "value"}
)
```

### API Flow Diagrams

```mermaid
sequenceDiagram
    participant C as Client
    participant A as API
    participant D as Database
    participant Q as Queue

    C->>A: POST /api/events
    A->>A: Validate request
    A->>D: Store event
    A->>Q: Queue for processing
    A-->>C: 202 Accepted
    Q->>D: Process async
```

## File Organization

### Actual Layout: Flat docs/ Directory

> **Project-specific deviation**: par-term uses a flat `docs/` directory rather than the
> subdirectory structure described in the generic template below. This is a conscious
> choice: the project has 50+ documentation files that cover a wide variety of topics,
> and a flat layout makes every file directly discoverable from `docs/README.md` without
> requiring contributors to navigate a nested hierarchy. All files live at `docs/*.md`
> with no subdirectories. Do not create subdirectories inside `docs/` — add new files at
> the top level and link them from `docs/README.md`.

```
docs/
├── README.md                    # Documentation index — link all new docs here
├── DOCUMENTATION_STYLE_GUIDE.md # This guide
├── ARCHITECTURE.md
├── CONTRIBUTING.md              # At repo root, linked from docs/README.md
├── CONFIG_REFERENCE.md
├── GETTING_STARTED.md
└── ... (50+ files, all flat)
```

### Generic Template (for reference only)

The subdirectory structure below is included for projects that prefer topic-based
organization. **It does not describe par-term's actual layout.**

```
docs/
├── README.md                    # Documentation index
├── DOCUMENTATION_STYLE_GUIDE.md # This guide
├── architecture/                # System design documents
│   ├── SYSTEM_OVERVIEW.md
│   ├── DATABASE_SCHEMA.md
│   └── API_ARCHITECTURE.md
├── guides/                      # How-to and tutorials
│   ├── QUICKSTART.md
│   ├── DEPLOYMENT_GUIDE.md
│   └── TROUBLESHOOTING.md
├── api/                        # API documentation
│   ├── REST_API.md
│   ├── WEBSOCKET_API.md
│   └── examples/
└── diagrams/                   # Standalone diagram sources
    └── system-flow.mmd
```

### File Naming Conventions

File name should be uppercase with lowercase extension.

| Type | Pattern | Example | Description |
|------|---------|---------|-------------|
| **Guides** | `*_GUIDE.md` | `DEPLOYMENT_GUIDE.md` | Step-by-step instructions |
| **Architecture** | `*_ARCHITECTURE.md` | `SYSTEM_ARCHITECTURE.md` | Design documents |
| **API Docs** | `*_API.md` | `REST_API.md` | API references |
| **Reference** | `*_REFERENCE.md` | `CONFIG_REFERENCE.md` | Configuration/settings |
| **Troubleshooting** | `TROUBLESHOOTING_*.md` | `TROUBLESHOOTING_DOCKER.md` | Problem-solving |

### Standard Files

#### Root Level Documentation
- `README.md` - Project overview and entry point
- `CHANGELOG.md` - Version history and releases
- `CONTRIBUTING.md` - Contribution guidelines
- `LICENSE.md` - License information
- `SECURITY.md` - Security policies and reporting

#### Project-Specific
- `CLAUDE.md` - AI assistant instructions (if using Claude)
- `QUICKSTART.md` - Getting started quickly
- `ARCHITECTURE.md` - High-level system design
- `API_DOCUMENTATION.md` - Complete API reference
- `TROUBLESHOOTING.md` - Common issues and solutions

### Documentation Hierarchy

```mermaid
graph TD
    README[README.md - Entry Point]
    QS[QUICKSTART.md]
    ARCH[ARCHITECTURE.md]
    API[API_DOCUMENTATION.md]
    GUIDE[Guides/]
    TROUBLE[TROUBLESHOOTING.md]
    REF[References/]

    README --> QS
    README --> ARCH
    README --> API
    README --> GUIDE
    README --> TROUBLE
    ARCH --> REF
    API --> REF
    GUIDE --> TROUBLE

    style README fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style QS fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    style ARCH fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    style API fill:#1a237e,stroke:#3f51b5,stroke-width:2px,color:#ffffff
    style GUIDE fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
    style TROUBLE fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#ffffff
    style REF fill:#37474f,stroke:#78909c,stroke-width:2px,color:#ffffff
```

## Maintenance

### Documentation Lifecycle

```mermaid
graph LR
    Create[Create/Update]
    Review[Peer Review]
    Test[Test Examples]
    Publish[Publish]
    Monitor[Monitor]
    Update[Update]

    Create --> Review
    Review --> Test
    Test --> Publish
    Publish --> Monitor
    Monitor --> Update
    Update --> Review

    style Create fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    style Review fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    style Test fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#ffffff
    style Publish fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style Monitor fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
    style Update fill:#880e4f,stroke:#c2185b,stroke-width:2px,color:#ffffff
```

### Version Management

#### Version Annotations
```markdown
<!-- Added in v1.0.0 -->
**New Feature:** WebSocket auto-reconnection

<!-- Changed in v1.2.0 -->
**Updated:** Connection timeout increased to 30s (was 10s)

<!-- Deprecated in v2.0.0 -->
> **⚠️ DEPRECATED:** Use `newMethod()` instead. Will be removed in v3.0.0.

<!-- Removed in v3.0.0 -->
~~Old feature documentation removed~~
```

#### Breaking Changes
```markdown
> **🚨 Breaking Change in v2.0.0**
>
> The API endpoint structure has changed:
> - Old: `/api/resource`
> - New: `/api/v2/resources`
>
> Migration guide: See `MIGRATION_V2.md` (example filename — replace with actual migration guide path)
```

### Cross-Reference Management

#### Update Checklist
When modifying documentation:

1. **Identify Dependencies**
   - List all documents that reference the current one
   - Note sections that might be affected

2. **Update Links**
   - Fix broken internal links
   - Update anchor links if headings changed
   - Verify external links still work

3. **Synchronize Examples**
   - Ensure code examples match current implementation
   - Update configuration samples
   - Test command-line examples

4. **Version Consistency**
   - Update version numbers where referenced
   - Add changelog entries
   - Mark deprecated features

### Documentation Testing

#### Automated Checks
- Link validation (internal and external)
- Markdown linting (proper syntax)
- Code block syntax validation
- Mermaid diagram rendering

#### Manual Verification
- Technical accuracy review
- Example functionality testing
- Screenshot currency (if applicable)
- Flow diagram accuracy

## Review Checklist

### Pre-Commit Checklist

#### Structure & Format
- [ ] **Title**: Clear, descriptive H1 heading
- [ ] **Description**: Brief summary after title
- [ ] **TOC**: Present for documents > 500 words
- [ ] **Sections**: Logical hierarchy (H2 → H3 → H4)
- [ ] **Headings**: Descriptive and action-oriented

#### Content Quality
- [ ] **Clarity**: Simple, direct language
- [ ] **Completeness**: All necessary information included
- [ ] **Accuracy**: Technical details verified
- [ ] **Consistency**: Terminology matches project standards
- [ ] **Examples**: Practical and tested

#### Visual Elements
- [ ] **Diagrams**: Mermaid (not ASCII art)
- [ ] **Colors**: High contrast with white text
- [ ] **Tables**: Properly formatted with headers
- [ ] **Images**: Alt text provided (if any)
- [ ] **Code blocks**: Language specified

#### Code & Commands
- [ ] **Syntax**: Proper highlighting language set
- [ ] **Testing**: All examples executed successfully
- [ ] **Output**: Expected results documented
- [ ] **Errors**: Common errors and solutions included
- [ ] **Versions**: Compatible with current project version

#### Links & References
- [ ] **Internal links**: All working and accurate
- [ ] **External links**: Verified and accessible
- [ ] **Cross-references**: Updated in related docs
- [ ] **Related docs**: Section included at end
- [ ] **API refs**: Match current implementation

#### Metadata & Maintenance
- [ ] **File name**: Follows naming conventions
- [ ] **Location**: In appropriate directory
- [ ] **Version info**: Included where relevant
- [ ] **Deprecations**: Clearly marked
- [ ] **Changelog**: Entry added (if applicable)

### Review Process

```mermaid
stateDiagram-v2
    [*] --> Draft: Create/Update
    Draft --> Review: Submit PR
    Review --> Revise: Changes Requested
    Revise --> Review: Re-submit
    Review --> Approved: LGTM
    Approved --> Merged: Merge PR
    Merged --> Published: Deploy
    Published --> [*]

    note right of Review
        - Technical accuracy
        - Style compliance
        - Example testing
    end note

    note right of Approved
        - All checks passed
        - Examples verified
        - Links validated
    end note
```

### Quality Metrics

| Metric | Target | Measurement |
|--------|--------|-------------|
| **Readability** | Grade 8-10 | Flesch-Kincaid score |
| **Completeness** | 100% | All sections populated |
| **Accuracy** | 100% | Technical review passed |
| **Link Health** | 100% | No broken links |
| **Example Success** | 100% | All examples run |
| **Update Frequency** | < 6 months | Last modification date |

## Example Templates

### Complete Feature Documentation

```markdown
# Feature Name

One-line description of the feature's purpose and value.

## Table of Contents
- [Overview]#overview
- [Architecture]#architecture
- [Installation]#installation
- [Configuration]#configuration
- [Usage]#usage
- [API Reference]#api-reference
- [Troubleshooting]#troubleshooting
- [Performance]#performance
- [Security]#security
- [Related Documentation]#related-documentation

## Overview

**Purpose:** What problem does this solve?

**Key Features:**
- Feature 1: Brief description
- Feature 2: Brief description
- Feature 3: Brief description

**Requirements:**
- System requirement 1
- System requirement 2

## Architecture

### System Design

```mermaid
graph TB
    subgraph "Feature Components"
        A[Input Handler]
        B[Processing Engine]
        C[Output Manager]
    end

    subgraph "External Systems"
        D[Database]
        E[Cache]
        F[Message Queue]
    end

    A --> B
    B --> C
    B --> D
    B --> E
    C --> F

    style A fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    style B fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    style C fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    style D fill:#1a237e,stroke:#3f51b5,stroke-width:2px,color:#ffffff
    style E fill:#880e4f,stroke:#c2185b,stroke-width:2px,color:#ffffff
    style F fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
```

### Data Flow

Description of how data moves through the system...

## Installation

### Prerequisites

```bash
# Check required versions
$ node --version
v20.17.0
$ npm --version
10.0.0
```

### Setup Steps

1. **Install dependencies**
   ```bash
   npm install feature-package
   ```

2. **Configure environment**
   ```bash
   cp .env.example .env
   # Edit .env with your settings
   ```

3. **Initialize feature**
   ```bash
   npm run feature:init
   ```

## Configuration

### Basic Configuration

```yaml
feature:
  enabled: true
  mode: production
  options:
    timeout: 30
    retries: 3
```

### Advanced Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `cache.enabled` | boolean | true | Enable caching |
| `cache.ttl` | integer | 3600 | Cache TTL in seconds |
| `log.level` | string | "info" | Logging level |

## Usage

### Basic Example

```javascript
import { Feature } from 'feature-package';

const feature = new Feature({
  apiKey: 'your-api-key'
});

const result = await feature.process(data);
```

### Advanced Usage

```javascript
// With error handling and options
try {
  const result = await feature.process(data, {
    timeout: 5000,
    retryOnFailure: true
  });
  console.log('Success:', result);
} catch (error) {
  console.error('Failed:', error.message);
}
```

## API Reference

See `API_DOCUMENTATION.md` for complete reference (example filename — replace with actual API docs path).

## Troubleshooting

### Common Issues

#### Issue: Connection timeout
**Symptom:** Error: ETIMEDOUT
**Solution:** Increase timeout in configuration
```yaml
feature:
  options:
    timeout: 60  # Increase from default 30
```

#### Issue: Authentication failed
**Symptom:** 401 Unauthorized
**Solution:** Verify API key is correct and has required permissions

## Performance

### Benchmarks

| Operation | Average Time | Throughput |
|-----------|--------------|------------|
| Process small | 50ms | 20 req/s |
| Process large | 200ms | 5 req/s |
| Batch process | 1000ms | 100 items/s |

### Optimization Tips

- Enable caching for repeated queries
- Use batch operations for multiple items
- Implement connection pooling

## Security

### Best Practices

- Store sensitive configuration in environment variables
- Rotate API keys regularly
- Enable rate limiting
- Use HTTPS for all connections

### Security Headers

```javascript
app.use(helmet({
  contentSecurityPolicy: {
    directives: {
      defaultSrc: ["'self'"],
      styleSrc: ["'self'", "'unsafe-inline'"]
    }
  }
}));
```

## Related Documentation

- [System Architecture]ARCHITECTURE.md - Overall system design
- [API Documentation]API_DOCUMENTATION.md - Complete API reference
- [Deployment Guide]DEPLOYMENT_GUIDE.md - Production deployment
- [Troubleshooting Guide]TROUBLESHOOTING.md - Extended troubleshooting

## Summary

This style guide ensures consistency and quality across all project documentation. Following these guidelines will result in documentation that is:

- **Clear and concise** - Easy to understand and navigate
- **Visually enhanced** - Effective use of diagrams and formatting
- **Technically accurate** - Verified examples and information
- **Well-maintained** - Regular updates and cross-reference management
- **Professional** - Consistent style and presentation

Remember: Good documentation is an investment in your project's success and your team's productivity.