allframe 0.1.28

Complete Rust web framework with built-in HTTP/2 server, REST/GraphQL/gRPC, compile-time DI, CQRS - TDD from day zero
Documentation
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
# PRD: Router + API Documentation System

**Status**: 📝 DRAFT
**Created**: 2025-11-26
**Owner**: AllFrame Core Team
**Priority**: P0 (Next Major Phase)

---

## Executive Summary

Build a **best-in-class, protocol-agnostic routing and documentation system** that automatically generates beautiful, interactive API documentation for REST, GraphQL, and gRPC endpoints. This system must be **lighter weight and better than anything on the market** while maintaining AllFrame's zero-boilerplate philosophy.

### Key Goals

1. **Unified Router**: Single routing abstraction that works across REST, GraphQL, gRPC
2. **Best-in-Class Docs**:
   - REST → [Scalar]https://scalar.com/ (modern, lightweight OpenAPI docs)
   - GraphQL → GraphiQL playground + auto-generated documentation
   - gRPC → Protocol documentation + reflection
3. **Contract Testing**: Built-in contract testing helpers for all protocols
4. **Zero Config**: Documentation generated automatically from code
5. **Developer Experience**: Better than Swagger/ReDoc/Postman combined

---

## Problem Statement

### Current Pain Points

**1. Documentation Fragmentation**
- REST uses Swagger UI (outdated, heavy, slow)
- GraphQL has multiple tools (GraphiQL, Apollo Studio, etc.)
- gRPC has no standard documentation solution
- No unified experience across protocols

**2. Manual Documentation Effort**
- Developers manually maintain OpenAPI specs
- Schema drift between code and docs
- Documentation becomes outdated quickly
- No single source of truth

**3. Poor Developer Experience**
- Swagger UI is slow and outdated (built 2015)
- No modern dark mode, poor mobile support
- Lacks modern features (search, examples, validation)
- Heavy JavaScript bundles (100KB+ gzipped)

**4. Testing Complexity**
- Contract testing requires separate tools
- No built-in testing UI
- Hard to verify API contracts
- Manual test case generation

### Why This Matters

**For API Consumers**:
- Need beautiful, accurate, interactive documentation
- Want to try APIs without writing code
- Expect modern UX (dark mode, search, mobile)

**For API Developers**:
- Don't want to maintain separate docs
- Need docs to stay in sync with code
- Want contract testing built-in

**For AllFrame**:
- Router is core to framework value proposition
- Documentation is often the first touchpoint
- Best-in-class docs = competitive advantage

---

## Success Criteria

### Must Have (P0)

1. **Unified Router Core**
   - Protocol-agnostic routing abstraction
   - Zero-cost abstraction overhead
   - Type-safe route registration
   - Compile-time route validation

2. **REST Documentation (Scalar)**
   - Automatic OpenAPI 3.1 generation from code
   - Beautiful, modern UI via Scalar
   - Interactive API testing
   - <50KB bundle size (vs 100KB+ for Swagger)

3. **GraphQL Documentation**
   - GraphiQL playground embedded
   - Auto-generated schema documentation
   - Interactive query builder
   - Subscription support

4. **gRPC Documentation**
   - Protocol documentation generation
   - gRPC reflection API
   - Service explorer UI
   - Request/response examples

5. **Contract Testing**
   - Built-in contract test generators
   - Schema validation helpers
   - Mock server generation
   - Test report generation

### Should Have (P1)

1. **Advanced Features**
   - Multi-language code examples (cURL, JavaScript, Python, Rust)
   - Request/response recording
   - API versioning support
   - Deprecation warnings

2. **Developer Tools**
   - VS Code extension for route preview
   - CLI for documentation export
   - Offline documentation mode
   - PDF/Markdown export

3. **Performance**
   - Server-side rendering option
   - Static site generation
   - CDN-friendly assets
   - Progressive web app (PWA)

### Nice to Have (P2)

1. **Ecosystem Integration**
   - Postman collection export
   - Insomnia workspace export
   - OpenAPI tools compatibility
   - GraphQL Playground compatibility

2. **Analytics**
   - API usage tracking
   - Popular endpoints highlighting
   - Deprecation analytics
   - Error rate tracking

---

## Technical Architecture

### 1. Router Core

```rust
// Core routing abstraction
pub trait Router: Send + Sync {
    /// Register a route handler
    fn route<H: Handler>(&mut self, path: &str, handler: H);

    /// Get route metadata for documentation
    fn routes(&self) -> Vec<RouteMetadata>;

    /// Generate protocol-specific config
    fn to_protocol<P: Protocol>(&self) -> P::Config;
}

// Protocol abstraction
pub trait Protocol {
    type Config;
    type Handler;

    fn name(&self) -> &str;
    fn generate_docs(&self, config: Self::Config) -> Documentation;
}
```

**Key Design Principles**:
- **Protocol-agnostic**: Router knows nothing about HTTP, GraphQL, gRPC
- **Zero-cost**: Compile-time protocol selection, no runtime overhead
- **Type-safe**: Routes validated at compile time
- **Extensible**: Third-party protocols via trait implementation

---

### 2. REST Documentation (Scalar)

**Why Scalar?**
- ✅ Modern, beautiful UI (built 2023)
- ✅ Lightweight (<50KB vs 100KB+ for Swagger UI)
- ✅ Dark mode by default
- ✅ Mobile-friendly
- ✅ Better search and navigation
- ✅ OpenAPI 3.1 support
- ✅ Free and open source

**Architecture**:
```rust
#[api_handler]
async fn create_user(req: CreateUserRequest) -> Result<User, ApiError> {
    // Business logic
}

// Automatic OpenAPI generation:
// POST /users
// Request: CreateUserRequest (JSON schema)
// Response: User (JSON schema)
// Errors: ApiError variants
```

**Features**:
- Automatic OpenAPI 3.1 spec generation
- JSON Schema derivation from Rust types
- Example generation from doc comments
- Request/response validation
- Interactive "Try It" functionality

**Example Output**:
```yaml
openapi: 3.1.0
info:
  title: My API
  version: 1.0.0
paths:
  /users:
    post:
      summary: Create a new user
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
```

---

### 3. GraphQL Documentation

**Stack**:
- **GraphiQL**: Interactive playground (industry standard)
- **Schema introspection**: Auto-generated schema docs
- **Explorer**: Visual query builder

**Architecture**:
```rust
#[graphql_object]
impl User {
    /// Get the user's email
    async fn email(&self) -> String {
        self.email.clone()
    }

    /// Get the user's posts
    async fn posts(&self) -> Vec<Post> {
        // Logic here
    }
}

// Automatic schema generation:
// type User {
//   email: String!
//   posts: [Post!]!
// }
```

**Features**:
- GraphiQL playground embedded
- Schema documentation sidebar
- Query auto-completion
- Subscription testing
- Mutation testing
- Query history

---

### 4. gRPC Documentation

**Challenge**: gRPC has no standard documentation solution

**AllFrame Solution**:
1. **gRPC Reflection**: Expose service definitions at runtime
2. **Custom UI**: Build lightweight gRPC explorer
3. **Proto Documentation**: Generate docs from .proto files

**Architecture**:
```rust
#[grpc_service]
impl UserService {
    /// Create a new user
    #[grpc_method]
    async fn create_user(&self, req: CreateUserRequest) -> Result<User, Status> {
        // Logic here
    }
}

// Automatic .proto generation + reflection API
// service UserService {
//   rpc CreateUser(CreateUserRequest) returns (User);
// }
```

**Features**:
- gRPC reflection API (industry standard)
- Interactive service explorer UI
- Request builder with syntax highlighting
- Response viewer
- Stream testing (server/client/bidirectional)

**Inspiration**:
- Postman gRPC client
- grpcurl CLI tool
- BloomRPC UI

---

### 5. Contract Testing

**Goal**: Make API contract testing effortless

**Architecture**:
```rust
#[test]
async fn test_create_user_contract() {
    // Automatic contract test generation
    let contract = Router::generate_contract_test("POST /users");

    // Validates:
    // - Request schema matches OpenAPI spec
    // - Response schema matches OpenAPI spec
    // - Status codes match spec
    // - Headers match spec

    contract.run().await.expect("Contract test failed");
}
```

**Features**:
1. **Schema Validation**
   - Request/response against OpenAPI spec
   - GraphQL query against schema
   - gRPC message against proto

2. **Mock Generation**
   - Generate mock servers from specs
   - Realistic fake data
   - Error scenario testing

3. **Test Reports**
   - Coverage report (% of endpoints tested)
   - Schema drift detection
   - Breaking change detection

4. **CI/CD Integration**
   - `cargo test --contract-tests`
   - JUnit XML output
   - GitHub Actions workflow

---

## Implementation Plan

### Phase 6.1: Router Core ✅ COMPLETE (2025-11-27)

**Goal**: Build protocol-agnostic routing foundation

**Delivered**:
1. ✅ Route metadata extraction (`RouteMetadata`)
2. ✅ Type-safe route registration (`router.get()`, etc.)
3. ✅ JSON Schema generation (`ToJsonSchema` trait)
4. ✅ OpenAPI 3.1 spec generation
5. ✅ Route builder API
6. ✅ Documentation serving

**Results**:
- 60 tests added (100% coverage)
- Zero runtime overhead achieved
- Zero breaking changes
- All success metrics exceeded

**Documentation**: [PHASE6_1_COMPLETE.md](../phases/PHASE6_1_COMPLETE.md)

---

### Phase 6.2: REST + Scalar Integration (2 weeks)

**Goal**: Best-in-class REST API documentation

**Deliverables**:
1. OpenAPI 3.1 generation from Rust types
2. Scalar UI integration (<50KB bundle)
3. Interactive "Try It" functionality
4. JSON Schema derivation
5. Example generation from doc comments

**Tests**:
- OpenAPI spec validation
- JSON Schema correctness
- UI integration tests
- Bundle size assertions (<50KB)

**Success Metrics**:
- 100% automatic spec generation
- <50KB JavaScript bundle
- Mobile-friendly UI
- Dark mode by default

---

### Phase 6.3: GraphQL Documentation (2 weeks)

**Goal**: Beautiful GraphQL API documentation

**Deliverables**:
1. GraphiQL playground integration
2. Schema introspection API
3. Query auto-completion
4. Subscription testing UI
5. Schema documentation sidebar

**Tests**:
- Schema generation correctness
- GraphiQL integration tests
- Subscription testing
- Query validation

**Success Metrics**:
- 100% schema auto-generation
- Interactive playground works
- Subscription support
- Query history

---

### Phase 6.4: gRPC Documentation (2 weeks)

**Goal**: First-class gRPC documentation

**Deliverables**:
1. gRPC reflection API
2. Service explorer UI
3. Proto file generation
4. Request builder UI
5. Stream testing (all types)

**Tests**:
- Reflection API correctness
- UI integration tests
- Stream handling tests
- Proto generation tests

**Success Metrics**:
- gRPC reflection working
- Interactive UI for all RPC types
- Stream testing supported
- Proto docs generated

---

### Phase 6.5: Contract Testing (2 weeks)

**Goal**: Effortless API contract testing

**Deliverables**:
1. Contract test generators
2. Schema validation helpers
3. Mock server generation
4. Test report generation
5. CI/CD integration

**Tests**:
- Contract validation tests
- Mock server tests
- Breaking change detection
- Report generation tests

**Success Metrics**:
- 1-line contract test generation
- 100% schema validation
- Automatic mock servers
- CI/CD ready

---

## User Experience

### REST API Developer Flow

```rust
use allframe::prelude::*;

#[tokio::main]
async fn main() {
    let mut router = Router::new();

    // Type-safe route registration (Phase 6.1 ✅)
    router.get("/users", || async { "User list".to_string() });
    router.post("/users", || async { "User created".to_string() });
    router.get("/users/{id}", || async { "User details".to_string() });

    // Generate OpenAPI 3.1 spec (Phase 6.1 ✅)
    let spec = router.to_openapi("My API", "1.0.0");

    // Serve OpenAPI JSON (Phase 6.1 ✅)
    let json = router.openapi_json("My API", "1.0.0");

    // Serve basic HTML docs (Phase 6.1 ✅)
    let config = router.docs_config("/docs", "My API", "1.0.0");
    let html = router.docs_html(&config);

    // Future: Scalar integration (Phase 6.2)
    // router.serve_with_scalar("0.0.0.0:3000", "/docs").await;
}
```

**Developer sees**:
1. Navigate to `http://localhost:3000/docs`
2. Beautiful Scalar UI with dark mode
3. All routes auto-documented
4. "Try It" button to test endpoints
5. JSON schemas auto-generated
6. Example requests from doc comments

**Zero configuration. Zero manual work.**

---

### GraphQL API Developer Flow

```rust
// Future: Phase 6.3 - GraphQL Documentation

use allframe::prelude::*;

#[graphql_object]
impl Query {
    /// Get a user by ID
    async fn user(&self, id: String) -> Option<User> {
        // Logic here
    }
}

#[tokio::main]
async fn main() {
    let schema = Schema::build(Query, Mutation, Subscription).finish();

    let router = Router::new();
    router.graphql("/graphql", schema);

    // Serve GraphQL + GraphiQL at /graphql (Phase 6.3)
    router.serve_with_graphiql("0.0.0.0:3000", "/graphql").await;
}
```

**Developer sees**:
1. Navigate to `http://localhost:3000/graphql`
2. GraphiQL playground loads
3. Schema docs in sidebar
4. Query auto-completion works
5. "Run" button to test queries
6. Subscription testing UI

**Zero configuration. Zero manual work.**

---

### gRPC API Developer Flow

```rust
// Future: Phase 6.4 - gRPC Documentation

use allframe::prelude::*;

#[grpc_service]
impl UserService {
    /// Create a new user
    async fn create_user(&self, req: CreateUserRequest) -> Result<User, Status> {
        // Logic here
    }
}

#[tokio::main]
async fn main() {
    let router = Router::new();
    router.grpc("/", UserService);

    // Serve gRPC + reflection + docs (Phase 6.4)
    router.serve_with_grpc_reflection("0.0.0.0:50051", "/docs").await;
}
```

**Developer sees**:
1. Navigate to `http://localhost:50051/docs`
2. gRPC service explorer UI
3. All methods documented
4. Request builder with syntax highlighting
5. "Send" button to test RPCs
6. Stream testing (server/client/bidirectional)

**Zero configuration. Zero manual work.**

---

### Contract Testing Flow

```rust
#[test]
async fn contract_tests() {
    let router = Router::new();
    router.post("/users", create_user);

    // Generate contract tests automatically
    let tests = router.generate_contract_tests();

    // Run all contract tests
    tests.run().await.expect("Contract tests failed");
}
```

**Tests validate**:
- ✅ Request schemas match OpenAPI spec
- ✅ Response schemas match OpenAPI spec
- ✅ Status codes are correct
- ✅ Headers are correct
- ✅ Error responses match spec

**Output**:
```
✅ POST /users - Request schema valid
✅ POST /users - Response schema valid
✅ POST /users - Status codes correct
✅ GET /users/{id} - Request schema valid
✅ GET /users/{id} - Response schema valid

Contract Tests: 5/5 passed (100%)
Schema Coverage: 100%
```

---

## Competitive Analysis

### Swagger UI vs Scalar

| Feature | Swagger UI | Scalar | AllFrame + Scalar |
|---------|-----------|--------|-------------------|
| **Bundle Size** | ~100KB gzipped | <50KB gzipped | <50KB gzipped |
| **UI Design** | Outdated (2015) | Modern (2023) | Modern (2023) |
| **Dark Mode** | Addon required | Built-in | Built-in |
| **Mobile** | Poor | Excellent | Excellent |
| **Performance** | Slow on large APIs | Fast | Fast |
| **Search** | Basic | Advanced | Advanced |
| **Auto-generation** | Manual | Manual | **Automatic** |
| **Contract Tests** ||| **** |

**Verdict**: Scalar is objectively better, AllFrame makes it automatic.

---

### GraphQL Playground vs GraphiQL

| Feature | Playground | GraphiQL | AllFrame + GraphiQL |
|---------|-----------|----------|---------------------|
| **Maintenance** | Deprecated | Active | Active |
| **UI** | Modern but heavy | Classic, lighter | Classic, lighter |
| **Bundle Size** | ~200KB | ~100KB | ~100KB |
| **Features** | Rich | Essential | Essential + Auto-gen |
| **Auto-generation** | Manual | Manual | **Automatic** |
| **Contract Tests** ||| **** |

**Verdict**: GraphiQL is industry standard, AllFrame makes it automatic.

---

### gRPC Documentation

| Feature | grpcurl | BloomRPC | Postman | AllFrame |
|---------|---------|----------|---------|----------|
| **Type** | CLI | Desktop app | Desktop app | Web UI |
| **Bundle** | Binary | ~100MB | ~500MB | <50KB |
| **Auto-docs** |||| **** |
| **Reflection** |||||
| **Stream Testing** |||||
| **Contract Tests** |||| **** |

**Verdict**: No good web-based solution exists. AllFrame fills the gap.

---

## Risk Mitigation

### Risk 1: Bundle Size Creep

**Risk**: Documentation UIs become too heavy

**Mitigation**:
- Strict bundle size budgets (<50KB for REST, <100KB for GraphQL)
- CI/CD checks for bundle size
- Tree-shaking optimization
- Lazy-loading for heavy components
- CDN delivery for static assets

---

### Risk 2: Scalar/GraphiQL Breaking Changes

**Risk**: Third-party dependencies break

**Mitigation**:
- Pin exact versions in Cargo.toml
- Version compatibility tests in CI/CD
- Fallback to basic HTML if UI fails
- Vendor critical assets if needed

---

### Risk 3: gRPC Documentation Complexity

**Risk**: Building gRPC UI from scratch is hard

**Mitigation**:
- Phase 6.4 is P1, not P0 (can defer if needed)
- Start with reflection API only (easy)
- Build minimal UI incrementally
- Consider embedding grpcurl CLI as fallback

---

### Risk 4: OpenAPI Generation Accuracy

**Risk**: Auto-generated OpenAPI specs are wrong

**Mitigation**:
- Extensive test coverage (>100 tests)
- Property-based testing for schema generation
- OpenAPI validation tools in CI/CD
- Manual review of generated specs
- User feedback loop

---

## Success Metrics

### Technical Metrics

1. **Performance**
   - Router overhead: <10ns per request
   - OpenAPI generation: <1ms for 100 routes
   - Bundle sizes: REST <50KB, GraphQL <100KB, gRPC <50KB

2. **Quality**
   - Test coverage: >90% for all router code
   - Contract test coverage: 100% of endpoints
   - Zero breaking changes to existing APIs

3. **Developer Experience**
   - Zero configuration required
   - 100% automatic documentation generation
   - 1-line contract test generation

### Adoption Metrics

1. **Documentation Usage**
   - % of AllFrame users serving docs
   - Time spent in documentation UI
   - "Try It" usage rate

2. **Contract Testing**
   - % of projects using contract tests
   - Number of breaking changes caught
   - CI/CD integration rate

---

## Open Questions

1. **Q**: Should we support OpenAPI 2.0 (Swagger 2.0)?
   **A**: No. OpenAPI 3.1 only. 2.0 is legacy (2014).

2. **Q**: Should we build our own GraphQL playground?
   **A**: No. GraphiQL is industry standard and actively maintained.

3. **Q**: How do we handle API versioning?
   **A**: Phase 6.6 (P1). Support `/v1/users`, `/v2/users` routing.

4. **Q**: Should we support AsyncAPI for async/event APIs?
   **A**: Phase 7 (P2). Focus on REST/GraphQL/gRPC first.

5. **Q**: How do we handle authentication in docs?
   **A**: Support OAuth2, API keys, JWT in "Try It" functionality.

---

## Timeline

| Phase | Duration | Deliverable |
|-------|----------|-------------|
| 6.1 | 3 weeks | Router Core |
| 6.2 | 2 weeks | REST + Scalar |
| 6.3 | 2 weeks | GraphQL Docs |
| 6.4 | 2 weeks | gRPC Docs |
| 6.5 | 2 weeks | Contract Testing |
| **Total** | **11 weeks** | **Complete Router + Docs** |

**Target Completion**: Q1 2025

---

## Appendix

### A. Technology Stack

**Router Core**:
- Pure Rust, no external dependencies
- Proc macros for route registration
- Compile-time route validation

**REST Documentation**:
- Scalar (https://scalar.com/)
- OpenAPI 3.1 spec generation
- JSON Schema derivation

**GraphQL Documentation**:
- GraphiQL (https://github.com/graphql/graphiql)
- Schema introspection
- async-graphql integration

**gRPC Documentation**:
- gRPC reflection API (tonic)
- Custom web UI (Svelte or vanilla JS)
- Proto documentation generation

**Contract Testing**:
- JSON Schema validation
- GraphQL query validation
- gRPC message validation
- JUnit XML output

---

### B. Prior Art

**REST**:
- Swagger UI: https://swagger.io/tools/swagger-ui/
- ReDoc: https://redocly.com/redoc
- Scalar: https://scalar.com/**Our choice**
- RapiDoc: https://rapidocweb.com/

**GraphQL**:
- GraphiQL: https://github.com/graphql/graphiql**Our choice**
- GraphQL Playground: https://github.com/graphql/graphql-playground (deprecated)
- Apollo Studio: https://studio.apollographql.com/ (commercial)

**gRPC**:
- grpcurl: https://github.com/fullstorydev/grpcurl (CLI only)
- BloomRPC: https://github.com/bloomrpc/bloomrpc (desktop app)
- Postman: https://www.postman.com/ (commercial)
- **No good web solution exists****Opportunity for AllFrame**

**Contract Testing**:
- Pact: https://pact.io/ (complex setup)
- Dredd: https://dredd.org/ (OpenAPI only)
- Prism: https://stoplight.io/open-source/prism (mock server only)
- **No Rust-native solution****Opportunity for AllFrame**

---

### C. References

- OpenAPI 3.1 Spec: https://spec.openapis.org/oas/v3.1.0
- GraphQL Spec: https://spec.graphql.org/
- gRPC Reflection: https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
- Scalar Documentation: https://github.com/scalar/scalar
- GraphiQL Documentation: https://graphiql-test.netlify.app/

---

**END OF PRD**

---

## Approval

- [ ] Engineering Lead
- [ ] Product Owner
- [ ] Architecture Review
- [ ] Security Review

**Next Steps**:
1. Review and approve PRD
2. Create Phase 6.1 tasks
3. Begin Router Core implementation