-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengineering_manual.html
More file actions
1214 lines (1136 loc) · 72.6 KB
/
engineering_manual.html
File metadata and controls
1214 lines (1136 loc) · 72.6 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grapthway v2.0 :: Engineering Manual</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
<style>
:root {
--primary: #3b82f6; /* blue-500 */
--secondary: #10b981; /* green-500 */
--dark: #111827; /* gray-900 */
--light: #f9fafb; /* gray-50 */
--gray: #4b5563; /* gray-600 */
--danger: #ef4444;
--warning: #f59e0b;
}
html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background-color: var(--light); color: var(--gray); }
.feature-card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
border: 1px solid #e5e7eb;
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}
.nav-link.active {
border-left: 4px solid var(--primary);
color: var(--primary);
background-color: rgba(59, 130, 246, 0.05);
font-weight: 600;
}
.nav-link {
transition: all 0.2s ease-in-out;
}
pre {
border-radius: 8px;
overflow-x: auto;
padding: 1.5rem;
background-color: #1e293b; /* slate-800 */
color: #f8fafc; /* slate-50 */
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}
.code-block { position: relative; }
.copy-btn {
position: absolute;
top: 12px;
right: 12px;
background-color: #334155; /* slate-700 */
color: white;
border: none;
border-radius: 6px;
padding: 6px 12px;
cursor: pointer;
opacity: 0.7;
transition: all 0.3s;
font-size: 0.875rem;
}
.copy-btn:hover { opacity: 1; background-color: #475569; }
.section-title {
border-bottom: 2px solid #e5e7eb;
padding-bottom: 0.75rem;
}
.diagram-container {
background: white;
padding: 20px;
border-radius: 10px;
margin: 20px 0;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.step-card {
transition: all 0.3s ease;
border-left: 4px solid var(--primary);
}
.step-card:hover {
transform: translateY(-3px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.tip-box {
background-color: #dbeafe;
border-left: 4px solid var(--primary);
padding: 1.5rem;
border-radius: 0 8px 8px 0;
}
.warning-box {
background-color: #fef3c7;
border-left: 4px solid var(--warning);
padding: 1.5rem;
border-radius: 0 8px 8px 0;
}
.troubleshooting-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
.issue-card {
background-color: white;
border-radius: 8px;
padding: 1.5rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.issue-card h4 {
margin-top: 0;
display: flex;
align-items: center;
}
.issue-card h4 i {
margin-right: 0.5rem;
}
.grid-cols-responsive {
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.edition-card {
background: white;
border-radius: 12px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.3s ease;
display: flex;
flex-direction: column;
}
.edition-card:hover {
transform: translateY(-5px);
}
.edition-card.featured {
transform: scale(1.05);
border: 2px solid var(--primary);
z-index: 10;
}
.edition-card.featured:hover {
transform: scale(1.07);
}
.feature-list {
flex-grow: 1;
}
.feature-list li {
margin-bottom: 0.75rem;
display: flex;
align-items: flex-start;
}
.feature-list li i {
color: var(--primary);
margin-right: 0.75rem;
margin-top: 0.2rem;
flex-shrink: 0;
}
.example-tabs {
display: flex;
flex-wrap: wrap;
border-bottom: 2px solid #e5e7eb;
margin-bottom: 1rem;
}
.example-tab {
padding: 0.75rem 1.5rem;
cursor: pointer;
border-bottom: 3px solid transparent;
transition: all 0.3s;
font-weight: 500;
}
.example-tab.active {
border-bottom-color: var(--primary);
color: var(--primary);
background-color: rgba(59, 130, 246, 0.05);
}
.example-content {
display: none;
}
.example-content.active {
display: block;
}
.architecture-diagrams {
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
margin-bottom: 2rem;
}
.api-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 2rem;
}
.api-table th, .api-table td {
border: 1px solid #e5e7eb;
padding: 0.75rem 1rem;
text-align: left;
}
.api-table th {
background-color: #f9fafb;
font-weight: 600;
}
.api-table .method {
font-weight: 700;
border-radius: 4px;
padding: 2px 6px;
font-size: 0.8em;
color: white;
white-space: nowrap;
}
.method-get { background-color: #2563eb; }
.method-post { background-color: #16a34a; }
@media (min-width: 1024px) {
.architecture-diagrams {
grid-template-columns: 1fr 1fr;
}
}
</style>
</head>
<body class="bg-gray-50 text-gray-800">
<div class="flex min-h-screen">
<aside class="w-72 bg-white shadow-lg p-6 hidden md:block sticky top-0 h-screen overflow-y-auto">
<div class="text-center mb-12">
<h1 class="text-3xl font-bold text-gray-800">
<i class="fas fa-project-diagram text-blue-500 mr-2"></i>Grapthway
</h1>
<p class="text-sm text-gray-500 mt-1">Engineering Manual v2.0</p>
</div>
<nav>
<ul class="space-y-2">
<li><a href="#overview" class="block py-2.5 px-4 rounded nav-link active">Overview</a></li>
<li><a href="#architecture" class="block py-2.5 px-4 rounded nav-link">Architecture</a></li>
<li><a href="#installation" class="block py-2.5 px-4 rounded nav-link">Installation</a></li>
<li><a href="#service-registration" class="block py-2.5 px-4 rounded nav-link">Service Registration</a></li>
<li><a href="#pipelines" class="block py-2.5 px-4 rounded nav-link">Orchestration Pipelines</a></li>
<li><a href="#stitching" class="block py-2.5 px-4 rounded nav-link">Schema Stitching</a></li>
<li><a href="#observability" class="block py-2.5 px-4 rounded nav-link">Observability</a></li>
<li><a href="#api-reference" class="block py-2.5 px-4 rounded nav-link">API Reference</a></li>
<li><a href="#editions" class="block py-2.5 px-4 rounded nav-link">Editions & Limits</a></li>
<li><a href="#diagnostics" class="block py-2.5 px-4 rounded nav-link">Diagnostics</a></li>
</ul>
</nav>
</aside>
<main class="flex-1 p-6 md:p-12 overflow-y-auto">
<header class="mb-16 text-center">
<h1 class="text-4xl md:text-5xl font-extrabold text-dark mb-4 tracking-tight">
Grapthway v2.0 Engineering Manual
</h1>
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
The complete guide to orchestrating your GraphQL and REST microservices with the Grapthway declarative gateway.
</p>
<div class="mt-8 flex flex-wrap justify-center gap-4">
<a href="#installation" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-lg transition-transform hover:scale-105 shadow-lg">
<i class="fas fa-rocket mr-2"></i>Quick Start
</a>
<a href="https://github.com/farisbahdlor/grapthway" target="_blank" class="bg-gray-800 hover:bg-gray-900 text-white font-bold py-3 px-6 rounded-lg transition-transform hover:scale-105 shadow-lg">
<i class="fab fa-github mr-2"></i>View on GitHub
</a>
</div>
</header>
<section id="overview" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">Overview</h2>
<p class="mb-6 text-gray-600 mx-auto">
Grapthway is an advanced API gateway designed for declarative microservices orchestration. It unifies both GraphQL and REST services under a single, coherent entrypoint, providing dynamic schema composition, protocol-agnostic middleware pipelines, and comprehensive observability tools to manage complex distributed systems.
</p>
<div class="bg-blue-50 p-6 rounded-xl border border-blue-200 mb-12">
<h3 class="font-bold text-lg mb-3 text-blue-700 flex items-center">
<i class="fas fa-star mr-2"></i>What's New in v2.0?
</h3>
<ul class="list-disc pl-5 mt-2 text-gray-700 space-y-2">
<li><b>Unified Pipeline Engine:</b> A refactored core engine handles orchestration for both GraphQL and REST, ensuring consistent behavior and reducing code duplication.</li>
<li><b>REST Pipeline Orchestration:</b> Apply the same powerful pre- and post-processing pipelines to your REST endpoints, enabling unified auth, enrichment, and transactional logic.</li>
<li><b>Declarative Request Body Mapping:</b> A `bodyMapping` option in pipeline steps allows you to construct JSON request bodies for downstream REST calls, mapping data from the pipeline context or using static values.</li>
<li><b>Comprehensive Observability Engine:</b> A new high-performance, asynchronous logging system captures the full request/response lifecycle for every transaction, including all pipeline steps, rollbacks, and concurrent executions.</li>
<li><b>Hardware Monitoring:</b> A new monitoring subsystem and dashboard tab provide real-time visibility into the container's CPU, memory, network, and disk I/O usage and limits.</li>
<li><b>Revamped Admin Dashboard:</b> A completely redesigned UI with live log streaming, advanced historical log search, persistent filters, and a polished user experience.</li>
<li><b>Enterprise Redis Resume:</b> Enterprise gateways using Redis can now restart and resume their previous state (including tokens) without needing to re-run the `/start` command, enabling better high-availability patterns.</li>
</ul>
</div>
<h3 class="text-2xl font-semibold text-dark mb-6">Core Features</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
<div class="bg-white p-8 rounded-xl feature-card">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mb-6 ring-8 ring-blue-50">
<i class="fas fa-puzzle-piece text-blue-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-dark mb-3">Declarative Pipelines</h3>
<p class="text-gray-600">
Define complex, multi-step workflows for both GraphQL and REST endpoints in simple JSON—no custom gateway code required.
</p>
</div>
<div class="bg-white p-8 rounded-xl feature-card">
<div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-6 ring-8 ring-green-50">
<i class="fas fa-code-branch text-green-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-dark mb-3">Dynamic Schema Stitching</h3>
<p class="text-gray-600">
Automatically compose a unified GraphQL schema from multiple microservices. Grapthway adapts in real-time as services register, update, or go offline.
</p>
</div>
<div class="bg-white p-8 rounded-xl feature-card">
<div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mb-6 ring-8 ring-purple-50">
<i class="fas fa-binoculars text-purple-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-dark mb-3">Deep Observability</h3>
<p class="text-gray-600">
Gain critical insights with a real-time admin dashboard, live log streaming, hardware monitoring, and a powerful historical log search engine.
</p>
</div>
<div class="bg-white p-8 rounded-xl feature-card">
<div class="w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mb-6 ring-8 ring-yellow-50">
<i class="fas fa-bolt text-yellow-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-dark mb-3">Protocol Agnostic & Scalable</h3>
<p class="text-gray-600">
Manage both GraphQL and REST services. Choose between in-memory storage for development or Redis for production-grade persistence and scalability.
</p>
</div>
</div>
</section>
<section id="architecture" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">System Architecture (v2.0)</h2>
<p class="mb-6 text-gray-600">The v2.0 architecture introduces a unified Pipeline Executor at its core. This central component is responsible for orchestrating workflows for both GraphQL and REST requests, ensuring consistent logic for tasks like authentication, data enrichment, and logging. For REST routes without a defined pipeline, the gateway bypasses the executor and uses a high-performance reverse proxy to minimize latency.</p>
<div class="architecture-diagrams">
<div class="bg-white p-8 rounded-xl shadow-lg border">
<h3 class="text-xl font-semibold mb-4">Unified Request Flow</h3>
<div class="mermaid text-center">
graph TD
A[Client Request] --> B{Protocol Detection};
B -- GraphQL --> C[GraphQL Handler];
B -- REST --> D[REST Proxy Handler];
C --> E{Pipeline Configured?};
D --> E;
E -- Yes --> F[Unified Pipeline Executor];
F -- Pre-Pipeline --> G[Proxy to Downstream Service];
G -- Response --> F;
F -- Post-Pipeline --> H[Compose Final Response];
E -- No (REST Only) --> I[High-Speed Reverse Proxy];
I --> G;
H --> Z[Client Response];
</div>
</div>
<div class="bg-white p-8 rounded-xl shadow-lg border">
<h3 class="text-xl font-semibold mb-4">Pipeline Executor Logic</h3>
<div class="mermaid text-center">
sequenceDiagram
participant Handler as Request Handler
participant Executor as Pipeline Executor
participant Service as Downstream Service
Handler->>Executor: ExecutePrePipeline(config, context)
Executor->>Service: Execute Step 1 (e.g., Auth)
Service-->>Executor: Step 1 Response
Executor->>Executor: Update Context
Executor->>Service: Execute Step 2 (e.g., Get Data)
Service-->>Executor: Step 2 Response
Executor-->>Handler: Return Pipeline Context
Handler->>Service: Main Request
Service-->>Handler: Main Response
Handler->>Executor: ExecutePostPipeline(config, mainResponse)
Executor->>Service: Enrichment Call
Service-->>Executor: Enrichment Data
Executor-->>Handler: Merged Final Data
</div>
</div>
</div>
</section>
<section id="installation" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">Installation & Setup</h2>
<h3 class="text-2xl font-semibold text-dark mt-10 mb-4">1. Run with Docker</h3>
<p class="mb-6 text-gray-600">Choose the edition that fits your needs. The Community Edition is perfect for getting started, while the Enterprise Edition is built for production scale.</p>
<div class="code-block mb-4">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-bash"># Community Edition (In-memory storage)
docker run -d -p 5000:5000 --name grapthway-ce farisbahdlor/grapthway:community-v2.0
</code></pre>
</div>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-bash"># Enterprise Edition (Requires Redis)
docker run -d -p 5000:5000 \
-e STORAGE_TYPE=redis \
-e REDIS_ADDR=your-redis-host:6379 \
--name grapthway-ee farisbahdlor/grapthway:enterprise-v2.0
</code></pre>
</div>
<h3 class="text-2xl font-semibold text-dark mt-10 mb-4">2. Obtain Access Tokens</h3>
<p class="mb-6 text-gray-600">On first launch, you must generate your unique admin tokens. These are required to access protected administrative endpoints. <b>Store them securely.</b></p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-bash">curl http://localhost:5000/start</code></pre>
</div>
<div class="tip-box mb-8">
<p class="text-blue-800">
<i class="fas fa-lightbulb mr-2"></i>
<strong>Enterprise Tip:</strong> If using Redis, the gateway will persist its "started" state and tokens. On a container restart, it will automatically resume its session without needing to hit <code>/start</code> again.
</p>
</div>
<h3 class="text-2xl font-semibold text-dark mt-10 mb-4">3. Register Your Microservices</h3>
<p class="mb-6 text-gray-600">From your microservice, periodically send a `POST` request to the gateway's `/admin/health` endpoint. This allows Grapthway to discover your service, retrieve its schema (if applicable), and keep its status updated. This process is the same for both GraphQL and REST services.</p>
</section>
<section id="service-registration" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">Service Registration</h2>
<p class="mb-6 text-gray-600">Service registration is the mechanism by which the gateway becomes aware of your downstream services. You must send a `POST` request to `/admin/health` every 30 seconds to keep the service alive in the gateway's registry. The payload contains all the configuration for the service.</p>
<div class="example-tabs mb-6">
<div class="example-tab active" data-target="reg-gql">GraphQL-Only Service</div>
<div class="example-tab" data-target="reg-rest">REST-Only Service</div>
<div class="example-tab" data-target="reg-hybrid">Hybrid Service</div>
</div>
<div class="example-content active" id="reg-gql">
<h4 class="text-lg font-semibold text-gray-700 mb-3">GraphQL-Only Service</h4>
<p class="mb-4 text-gray-600">An example registration for a service that only exposes a GraphQL API.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// POST /admin/health?token=<your_token>
{
"service": "auth-service", // The unique name of your service.
"url": "http://auth-internal:4001/graphql", // The internal address of your service.
"type": "graphql", // The primary type of this service.
"subgraph": "auth", // The logical group this service's schema belongs to.
"schema": "type User { ... } type Mutation { login(user: String!): String }", // The GraphQL schema definition.
// Defines pipelines for specific GraphQL fields.
"middlewareMap": {
"login": { // This pipeline attaches to the 'login' mutation.
"pre": [
{
"service": "rate-limiter-rest", // Call a REST service before the main mutation.
"method": "POST",
"path": "/check",
"onError": { "stop": true } // If the rate-limiter fails, stop the entire request.
}
]
}
},
// Defines how to "stitch" fields from this service onto types from other services.
"stitchingConfig": {
"User": { // Extend the 'User' type.
"authInfo": { // With a new field called 'authInfo'.
"service": "auth-service", // This service will provide the data.
"resolverField": "getUserById", // By calling its 'getUserById' query.
"argsMapping": { "id": "id" } // Map the parent User's 'id' to the resolver's 'id' argument.
}
}
}
}</code></pre>
</div>
</div>
<div class="example-content" id="reg-rest">
<h4 class="text-lg font-semibold text-gray-700 mb-3">REST-Only Service</h4>
<p class="mb-4 text-gray-600">An example for a legacy service that only exposes REST endpoints.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// POST /admin/health?token=<your_token>
{
"service": "inventory-api", // The unique name for the REST service.
"url": "http://inventory-legacy:3000", // The base URL for the service.
"type": "rest", // The service type is REST.
"path": "/v1/inventory", // The base path prefix for all routes from this service.
// Defines pipelines for specific REST routes.
"restPipelines": {
"POST /v1/inventory/update": { // Attaches to the 'POST' method on this specific route.
"pre": [
{
"service": "auth-service", // A GraphQL service used for auth.
"field": "verifyAdmin", // Call this GraphQL field.
"passHeaders": ["Authorization"], // Pass the auth header from the original request.
"onError": { "stop": true } // If auth fails, stop the request.
}
]
}
}
}</code></pre>
</div>
</div>
<div class="example-content" id="reg-hybrid">
<h4 class="text-lg font-semibold text-gray-700 mb-3">Hybrid Service</h4>
<p class="mb-4 text-gray-600">A single service can register both GraphQL and REST capabilities in one payload.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// POST /admin/health?token=<your_token>
{
"service": "products-service",
"url": "http://products-service-internal:8000",
"type": "graphql", // The primary type. REST routes are an addition.
"subgraph": "products",
"schema": "type Query { getProduct(id: ID!): Product } type Product { id: ID name: String }",
// Pipelines for GraphQL fields.
"middlewareMap": {
"getProduct": {
"pre": [{
"service": "auth-service",
"field": "validateSession",
"onError": { "stop": true }
}]
}
},
// Pipelines for REST endpoints also served by this service.
"restPipelines": {
"POST /products/{id}/inventory": {
"pre": [{
"service": "auth-service",
"field": "verifyAdmin",
"onError": { "stop": true }
}]
}
},
// Schema stitching configuration.
"stitchingConfig": {
"Order": { // Extends the 'Order' type (defined in another service).
"productDetails": { // Adds a 'productDetails' field.
"service": "products-service", // This service resolves the field.
"resolverField": "getProduct", // Using its 'getProduct' query.
"argsMapping": { "id": "productId" } // Maps the parent Order's 'productId' to the 'id' argument.
}
}
}
}</code></pre>
</div>
</div>
</section>
<section id="pipelines" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">Orchestration Pipelines</h2>
<p class="mb-10 text-gray-600">Pipelines are the core of Grapthway's orchestration engine. They allow you to define declarative, multi-step workflows that execute before (`pre`) and after (`post`) your main service call. As of v2.0, pipelines work for both GraphQL fields and specific REST endpoints, and can even mix calls to GraphQL and REST services within a single workflow.</p>
<div class="tip-box mb-8">
<p class="text-blue-800"><i class="fas fa-info-circle mr-2"></i><strong>Note on Backward Compatibility:</strong> Your existing v1.5 `middlewareMap` configurations for GraphQL pipelines are fully compatible with v2.0 and will continue to work without any changes.</p>
</div>
<h3 class="text-2xl font-semibold text-dark mb-4">The Pipeline Context & Data Access</h3>
<p class="mb-6 text-gray-600">
The key to using pipelines effectively is understanding the <strong>pipeline context</strong>. This is an in-memory JSON object that is created at the start of a request and passed through each step. You use it to get initial data (like request arguments) and to pass data between steps.
</p>
<div class="info-box mb-8">
<h4 class="font-bold text-blue-800 mb-2"><i class="fas fa-lightbulb mr-2"></i>Data Access Syntax</h4>
<p class="text-blue-800">You access data from the context using <strong>dot notation</strong>. For example, to get the `email` from a `user` object in the context, you would use the string <code>"user.email"</code>.</p>
</div>
<h4 class="text-xl font-semibold text-gray-800 mb-3">Initial Context (<code class="text-md">pre</code> pipeline)</h4>
<p class="mb-4 text-gray-600">Before the <code class="text-sm">pre</code> pipeline runs, the gateway populates the context with data from the original request:</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-6">
<li>
<strong>For GraphQL requests:</strong> All incoming arguments (variables) are placed in an object under the key <code>args</code>. You can access them with <code>"args.yourArgumentName"</code>.
</li>
<li>
<strong>For REST requests:</strong> The JSON request body is parsed and placed in an object under the key <code>request.body</code>. You can access its fields with <code>"request.body.yourFieldName"</code>.
</li>
</ul>
<div class="tip-box-alt mb-8">
<p class="text-purple-800"><i class="fas fa-wrench mr-2"></i><strong>Note on URL Path Parameters:</strong> The current implementation does not automatically parse URL path parameters (like <code>/users/{id}</code>) into the pipeline context. Data must be sourced from either the GraphQL arguments or the REST request body. Example 5 has been updated to reflect a working approach where the ID is retrieved from the main handler's response in the <code>post</code> pipeline instead.</p>
</div>
<h4 class="text-xl font-semibold text-gray-800 mb-3">Merged Context (<code class="text-md">post</code> pipeline)</h4>
<p class="mb-4 text-gray-600">After your main service logic runs, the gateway creates a new, <strong>merged context</strong> for the <code>post</code> pipeline. This context contains:</p>
<ul class="list-disc list-inside space-y-2 text-gray-600">
<li>All data from the final <code>pre</code> pipeline context (e.g., anything you saved with <code>assign</code>).</li>
<li>All top-level fields from the main service's JSON response.</li>
</ul>
<p class="text-gray-600 mb-8">This allows you to easily use both the initial session data and the result of the core operation in your follow-up tasks, as shown in the examples.</p>
<h3 class="text-2xl font-semibold text-dark mb-4">Pipeline Step Configuration</h3>
<p class="mb-6 text-gray-600">Each step in a pipeline is a JSON object with the following properties:</p>
<div class="bg-white rounded-lg border p-6 mb-10">
<ul class="list-none space-y-4">
<li><code><strong>service</strong>: string</code> <span class="text-gray-500">- The name of the registered service to call.</span></li>
<li><code><strong>field</strong>: string</code> <span class="text-gray-500">- (GraphQL only) The query or mutation to execute.</span></li>
<li><code><strong>operation</strong>: string</code> <span class="text-gray-500">- (GraphQL only) Defines the operation type (e.g., "mutation"). The system now infers this automatically, but the field is kept for backward compatibility.</span></li>
<li><code><strong>selection</strong>: string[]</code> <span class="text-gray-500">- (GraphQL only) Specifies which fields to return from the step's response, reducing payload size. Supports nested selections.</span></li>
<li><code><strong>method</strong>: string</code> <span class="text-gray-500">- (REST only) The HTTP method (e.g., "POST").</span></li>
<li><code><strong>path</strong>: string</code> <span class="text-gray-500">- (REST only) The endpoint path for the downstream service.</span></li>
<li><code><strong>argsMapping</strong>: object</code> <span class="text-gray-500">- (GraphQL only) Maps data to arguments for the downstream call. Values can be dynamic from the context (e.g., <code>"userId": "user.id"</code>) or static/hardcoded (e.g., <code>"source": "gateway"</code>).</span></li>
<li><code><strong>bodyMapping</strong>: object</code> <span class="text-gray-500">- (REST only) Maps data to the JSON request body. Also supports both dynamic context values and static values (e.g., <code>"status": "PROCESSED"</code>).</span></li>
<li><code><strong>passHeaders</strong>: string[]</code> <span class="text-gray-500">- An array of headers to pass from the original client request to this step's service.</span></li>
<li><code><strong>assign</strong>: object</code> <span class="text-gray-500">- (Blocking steps only) Maps response data from this step into the pipeline context. Use <code>"key": "fieldName"</code> to get a specific field or <code>"key": "*"</code> to get the entire result object.</span></li>
<li><code><strong>concurrent</strong>: boolean</code> <span class="text-gray-500">- If true, the gateway executes this step without waiting (fire-and-forget) and cannot assign data back to the context. Defaults to false.</span></li>
<li><code><strong>onError</strong>: object</code> <span class="text-gray-500">- Defines failure behavior. <code>"stop": true</code> aborts the request. A <code>"rollback"</code> array defines compensating steps to run if this blocking step fails.</span></li>
</ul>
</div>
<div class="warning-box mb-12">
<h4 class="font-bold text-yellow-800 mb-2"><i class="fas fa-exclamation-triangle mr-2"></i>Important: Scope of `onError` and `rollback`</h4>
<p class="text-yellow-800">The <code>onError</code> configuration is scoped to a specific <strong>pipeline step</strong>. It is designed to trigger compensating transactions (rollbacks) for actions taken in *previous, successful `pre` steps* if a *subsequent blocking `pre` step* fails. It does <strong>not</strong> apply to failures in the main service resolver/handler itself. This design separates the orchestration logic from the core business logic of the downstream service.</p>
</div>
<h3 class="text-2xl font-semibold text-dark mt-12 mb-4">Advanced Mixed-Protocol Examples</h3>
<p class="mb-6 text-gray-600">The true power of v2.0 is the ability to seamlessly orchestrate workflows across different protocols. These examples demonstrate how to combine GraphQL, REST, and various pipeline features to build robust, real-world applications.</p>
<div class="example-tabs mb-6">
<div class="example-tab active" data-target="ex1">E-commerce Order</div>
<div class="example-tab" data-target="ex2">Social Media Post</div>
<div class="example-tab" data-target="ex3">Financial Transaction w/ Rollback</div>
<div class="example-tab" data-target="ex4">IoT Data Ingestion</div>
<div class="example-tab" data-target="ex5">Profile Update w/ Avatar</div>
</div>
<div class="example-content active" id="ex1">
<h4 class="text-lg font-semibold text-gray-700 mb-3">1. E-commerce Order Placement</h4>
<p class="mb-4 text-gray-600">A user places an order via a GraphQL mutation. The pipeline first validates the user's session (GraphQL), then checks stock at a legacy inventory API (REST). After the main `placeOrder` mutation succeeds, it makes two concurrent calls: one to a REST service to send a confirmation email, and another to a GraphQL service to update user analytics.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// Attached to GraphQL mutation: placeOrder(items: [ItemInput!]): Order
// The main `placeOrder` resolver is assumed to return an object like: { "id": "ord_123", "buyerId": "usr_456", "total": 99.99 }
{
"placeOrder": {
"pre": [
{
"service": "auth-service-gql", // Call a GraphQL service for authentication.
"field": "validateSession", // The specific query/mutation to run.
"passHeaders": ["Authorization"], // Pass the Authorization header from the client's request.
"selection": ["user { id email }"], // Specify which fields to get back from the auth service.
"assign": { "userContext": "user" }, // Take the 'user' object from the response and save it as 'userContext' in the pipeline's memory.
"onError": { "stop": true } // If auth fails, abort the entire request.
},
{
"service": "inventory-api-rest", // Call a REST service to check stock.
"method": "POST", // Use the POST method.
"path": "/v1/stock/check-availability", // At this specific path.
"bodyMapping": {
"items_to_check": "args.items" // Get the 'items' from the original GraphQL mutation's arguments and use them to build the request body.
},
"onError": { "stop": true } // If stock check fails, abort.
}
],
"post": [
{
"service": "email-api-rest", // After the order is placed, call a REST service to send an email.
"method": "POST",
"path": "/v2/send/order-confirmation",
"bodyMapping": {
"recipient_email": "userContext.email", // Get the email from the context we saved in the 'pre' step.
"order_id": "id", // Get the 'id' field from the main `placeOrder` mutation's response.
"order_total": "total" // Get the 'total' field from the main `placeOrder` mutation's response.
},
"concurrent": true // Send the email and don't wait for a response (fire-and-forget).
},
{
"service": "analytics-service-gql", // Also, update analytics with another GraphQL call.
"operation": "mutation",
"field": "incrementOrderCount",
"argsMapping": {
"userId": "buyerId" // Get the 'buyerId' from the main `placeOrder` mutation's response and use it as an argument.
},
"concurrent": true // Also fire-and-forget.
}
]
}
}</code></pre>
</div>
</div>
<div class="example-content" id="ex2">
<h4 class="text-lg font-semibold text-gray-700 mb-3">2. Social Media Post Creation (REST-first)</h4>
<p class="mb-4 text-gray-600">A user creates a new post via a `POST` request to a REST endpoint. The pipeline validates the session (GraphQL), runs the post content through a legacy REST-based content moderation service, and after the main REST call succeeds, it notifies followers (GraphQL) and triggers a fan-out task (REST).</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// Attached to REST endpoint: POST /v3/posts
// The main REST handler is assumed to return a response like: { "id": "post_789", "authorId": "usr_456" }
{
"POST /v3/posts": {
"pre": [
{
"service": "user-session-gql", // Authenticate the user with a GraphQL service.
"field": "getActiveUser",
"passHeaders": ["Authorization"],
"selection": ["id"], // We only need the user's ID.
"assign": { "user": "" }, // Assign the entire response (e.g., { "id": "usr_456" }) to the 'user' key in the context.
"onError": { "stop": true }
},
{
"service": "moderation-api-rest", // Run content moderation with a REST service.
"method": "POST",
"path": "/filter/text",
"bodyMapping": {
"text_content": "request.body.content" // Get the 'content' field from the original POST request's body.
},
"onError": { "stop": true }
}
],
"post": [
{
"service": "notification-gql", // After the post is created, send notifications via a GraphQL mutation.
"operation": "mutation",
"field": "notifyFollowersOfNewPost",
"argsMapping": {
"postId": "id", // Get the 'id' from the main REST response.
"authorId": "user.id" // Get the user ID from the context we saved in the 'pre' step.
},
"concurrent": true // Fire-and-forget.
},
{
"service": "fanout-worker-rest", // Also, trigger a background task via a REST call.
"method": "POST",
"path": "/enqueue-feed-update",
"bodyMapping": {
"postId": "id", // Use the post ID from the main REST response.
"authorId": "authorId" // Use the author ID from the main REST response.
},
"concurrent": true
}
]
}
}</code></pre>
</div>
</div>
<div class="example-content" id="ex3">
<h4 class="text-lg font-semibold text-gray-700 mb-3">3. Financial Transaction with Rollback</h4>
<p class="mb-4 text-gray-600">A complex financial workflow. The `pre` pipeline authorizes a payment with a third-party provider (REST). The main operation, `reserveTickets` (GraphQL), is assumed to fail. This triggers the `onError` block, which executes a compensating `rollback` step. The rollback calls the payment provider's `void` endpoint, using `bodyMapping` to send the necessary transaction ID from the context and a static reason code.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// Attached to GraphQL mutation: reserveTickets(showId: ID!, quantity: Int!, ticketPrice: Float!, paymentToken: String!)
{
"reserveTickets": {
"pre": [
{
"service": "payment-provider-api", // 1. Authorize a payment hold with a REST API.
"method": "POST",
"path": "/v1/authorize_payment",
"bodyMapping": {
"amount": "args.ticketPrice", // Use the price from the mutation's arguments.
"currency": "USD", // Use a hardcoded static value.
"card_token": "args.paymentToken" // Use the payment token from the arguments.
},
"assign": { "paymentAuth": "" }, // Store the entire response (e.g., { transactionId: 'txn_abc' }) as 'paymentAuth' in the context.
"onError": { "stop": true } // If this fails, no rollback is needed yet, just stop.
},
{
"service": "ticketing-service-gql", // 2. Attempt to create the ticket reservation. We assume this step will fail.
"field": "createReservation",
"argsMapping": { "showId": "args.showId" },
"assign": { "reservation": ""},
"onError": {
"stop": true, // Stop the execution since this critical step failed.
"rollback": [ // Because it failed, execute these compensating actions.
{
"service": "payment-provider-api", // Call the same payment API to void the transaction.
"method": "POST",
"path": "/v1/void_authorization",
"bodyMapping": {
"authorization_id": "paymentAuth.transactionId", // Get the ID from the context we saved in the first step.
"reason_code": "INVENTORY_UNAVAILABLE" // Send a static reason for the void.
}
}
]
}
}
],
"post": []
}
}</code></pre>
</div>
</div>
<div class="example-content" id="ex4">
<h4 class="text-lg font-semibold text-gray-700 mb-3">4. IoT Data Ingestion & Alerting</h4>
<p class="mb-4 text-gray-600">An IoT device sends telemetry data to a REST endpoint. A `pre` step validates the device token. After the data is ingested by the main service, a `post` pipeline concurrently sends the raw data to a time-series DB (REST) and checks for anomalies (GraphQL). The anomaly check is blocking; if it returns an alert, a final step sends a notification to a Slack webhook (REST).</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// Attached to REST endpoint: POST /ingest/telemetry
// The main REST handler is assumed to return a response like: { "payload": { ... }, "status": "ok" }
{
"POST /ingest/telemetry": {
"pre": [{
"service": "device-auth-api", // 1. Validate the device token before anything else.
"method": "POST",
"path": "/token/introspect",
"passHeaders": ["X-Device-Token"],
"assign": { "device": "" }, // Store the device info (e.g., { id: 'dev_123' }) in the context.
"onError": { "stop": true }
}],
"post": [
{
"service": "timeseries-db-api", // 2. Concurrently archive the raw data to a time-series database.
"method": "POST",
"path": "/metrics/raw",
"bodyMapping": {
"payload": "payload", // Get the 'payload' field from the main REST response.
"deviceId": "device.id" // Get the device ID from the context.
},
"concurrent": true // Fire-and-forget.
},
{
"service": "anomaly-detection-gql", // 3. In parallel, run a blocking GraphQL query to check for anomalies.
"field": "analyzeTelemetry",
"argsMapping": { "payload": "payload" }, // Use the 'payload' from the main REST response as an argument.
"selection": ["alert { level message }"], // We only need the alert details back.
"assign": { "anomalyResult": "" }, // Store the result as 'anomalyResult' in the context.
"concurrent": false // This is a blocking call; the pipeline waits for it to finish.
},
{
"service": "slack-webhook-rest", // 4. This step runs after the anomaly check completes.
"method": "POST",
"path": "/T012345/B67890/xyz...",
"bodyMapping": {
// Get the message from the result of the previous step.
// Note: If no alert was found, this might be null. The receiving service should handle this gracefully.
"text": "anomalyResult.alert.message"
},
"concurrent": true
}
]
}
}</code></pre>
</div>
</div>
<div class="example-content" id="ex5">
<h4 class="text-lg font-semibold text-gray-700 mb-3">5. Profile Update with Avatar</h4>
<p class="mb-4 text-gray-600">A user updates their profile and uploads a new avatar via a multipart/form-data request to a REST endpoint. A `pre` step verifies ownership (GraphQL). After the main handler saves the profile text and the file path, a `post` step triggers a REST-based image processing service to create thumbnails (concurrent).</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// Attached to REST endpoint: POST /users/profile/update
// Main handler returns: { "id": "usr_456", "avatarUrl": "https://cdn.com/path/to/image.jpg" }
{
"POST /users/profile/update": {
"pre": [
{
"service": "auth-gql", // 1. Verify the user is authenticated before allowing an update.
"field": "validateSession",
"passHeaders": ["Authorization"],
"assign": { "user": "user" }, // Save user context
"onError": { "stop": true }
}
],
"post": [
{
"service": "image-processor-api", // 2. After profile update, process the new avatar.
"method": "POST",
"path": "/process/new-avatar",
"bodyMapping": {
// Get the public URL of the avatar from the main REST response.
"source_url": "avatarUrl",
// Get the user's ID from the main REST response.
"user_id": "id"
},
"concurrent": true // Fire-and-forget.
}
]
}
}</code></pre>
</div>
</div>
</section>
<section id="stitching" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">GraphQL Schema Stitching</h2>
<p class="mb-10 text-gray-600">Schema stitching allows you to extend types defined in one service with fields resolved by another, creating a rich, interconnected data graph. This feature is specific to GraphQL services.</p>
<div class="diagram-container mb-10">
<div class="mermaid">
graph TD
subgraph "Unified Schema (in Gateway)"
C["type User { id: ID, name: String, orderHistory: [Order] }"]
end
subgraph "user-service"
A["type User { id: ID, name: String }"]
end
subgraph "order-service"
B["type Query { getOrdersByUserId(userId: ID!): [Order] }"]
end
C -- Stitched from --> A;
C -- Extended with field resolved by --> B;
</div>
</div>
<h3 class="text-2xl font-semibold text-dark mb-4">Example: Extending User with Order History</h3>
<p class="mb-6 text-gray-600">Imagine your `user-service` defines the `User` type. You want to add an `orderHistory` field to it, but that data lives in the `order-service`. You can declare this relationship in the `order-service`'s registration payload.</p>
<div class="code-block mb-8">
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<pre><code class="language-javascript">// This configuration is sent in the `stitchingConfig` during the order-service's registration.
const STITCHING_CONFIG = {
// We are extending the "User" type, which is defined in another service.
"User": {
// Add a new field called "orderHistory" to the User type in the unified schema.
"orderHistory": {
"service": "order-service", // This service (the order-service) will be responsible for resolving this new field.
"resolverField": "getOrdersByUserId", // To resolve it, the gateway should call the 'getOrdersByUserId' query from this service's schema.
// The resolver needs a 'userId' argument. We tell the gateway to get this value from the 'id' field of the parent User object.
"argsMapping": { "userId": "id" }
}
}
};</code></pre>
</div>
</section>
<section id="observability" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">Observability</h2>
<p class="mb-10 text-gray-600">Grapthway v2.0 introduces a state-of-the-art, non-blocking logging engine and a completely redesigned admin dashboard, providing unparalleled insight into every transaction flowing through your gateway. This system is designed for complete operational awareness, allowing you to monitor, debug, and manage the entire gateway from a single pane of glass.</p>
<div class="bg-white p-8 rounded-xl border shadow-lg mb-10">
<h3 class="text-2xl font-semibold text-dark mb-4 flex items-center"><i class="fas fa-cogs text-blue-500 mr-3"></i>The Asynchronous Logging Engine</h3>
<p class="text-gray-600 mb-4">Performance is paramount. Our new logging system operates <b>fully asynchronously</b>, ensuring that comprehensive tracing has zero impact on request latency. Every log entry is now enriched with a unique <b>Trace ID</b>, allowing you to follow a single request's entire lifecycle across all services and pipeline steps.</p>
<h4 class="font-semibold text-gray-800 mb-2">What's Logged?</h4>
<ul class="list-disc pl-5 mt-2 text-gray-600 space-y-2">
<li><b>Client Interaction:</b> Full headers and payloads for the initial request from the client and the final response sent back.</li>
<li><b>Main Resolver/Endpoint:</b> The complete request and response for the primary downstream service call, whether it's GraphQL or REST.</li>
<li><b>Every Pipeline Step:</b> Detailed request/response data (headers, body) for every single step in your `pre` and `post` pipelines.</li>
<li><b>Concurrent & Rollback Actions:</b> We now capture logs for all concurrent (fire-and-forget) executions and every compensating transaction in your rollback chains.</li>
<li><b>Admin & Schema Changes:</b> A full audit trail for administrative actions and any updates made to the GraphQL schema.</li>
</ul>
</div>
<div class="bg-white p-8 rounded-xl border shadow-lg mb-10">
<h3 class="text-2xl font-semibold text-dark mb-4 flex items-center"><i class="fas fa-tachometer-alt text-blue-500 mr-3"></i>The Admin Dashboard</h3>
<p class="text-gray-600 mb-4">The monitoring dashboard has been rebuilt from the ground up to harness the power of the new logging engine. It provides a centralized hub for managing and observing your gateway's health and activity.</p>
<div class="mb-6">
<h4 class="font-semibold text-gray-800 mb-2">Status Overview & Management</h4>
<ul class="list-disc pl-5 mt-2 text-gray-600 space-y-2">
<li><b>Health Overview:</b> Get a high-level summary of your gateway's health, including the total number of services, instances, pipelines, and overall uptime.</li>
<li><b>Services Management:</b> Visualize all registered services and their instances, grouped by subgraph. See health status and connection details at a glance.</li>
<li><b>Pipelines Configuration:</b> Inspect the complete configuration for every pipeline, for both GraphQL and REST, in an easy-to-read format.</li>
</ul>
</div>
<div class="mb-6">
<h4 class="font-semibold text-gray-800 mb-2">Hardware Monitoring</h4>
<p class="text-gray-600">A new "Hardware" tab provides real-time visibility into the gateway container's resource consumption, reading directly from the container's cgroup filesystem. This is essential for performance tuning and capacity planning.</p>
<ul class="list-disc pl-5 mt-2 text-gray-600 space-y-2">
<li><b>Resource Allocation:</b> View the CPU core and memory limits allocated to the container.</li>
<li><b>Live CPU & Memory Usage:</b> See real-time usage percentages for both CPU and RAM.</li>
<li><b>Live I/O Statistics:</b> Monitor the current rate of network and disk I/O (bytes per second).</li>
</ul>
</div>
<div class="mb-6">
<h4 class="font-semibold text-gray-800 mb-2">Advanced Logging Interface</h4>
<ul class="list-disc pl-5 mt-2 text-gray-600 space-y-2">
<li><b>Unified Logging Views:</b> A central "Logging" section with multiple views:
<ul class="list-circle pl-5 mt-1">
<li><b>Live Logs:</b> A real-time, WebSocket-powered stream of logs as they happen.</li>
<li><b>Historical Logs:</b> A paginated, searchable interface for deep-diving into past requests, with separate tabs for Gateway, Schema, and Admin events.</li>
</ul>
</li>
<li><b>Powerful Filtering & Searching:</b>
<ul class="list-circle pl-5 mt-1">
<li><b>Filter by Endpoint/Schema:</b> Instantly narrow down logs to a specific GraphQL subgraph or REST endpoint path.</li>
<li><b>Timeframe Selection:</b> Quickly select common timeframes (e.g., "Last 5 minutes", "Last 24 hours").</li>
<li><b>Full-Text Search:</b> A global keyword search that scans the entire content of log entries—including headers, payloads, and Trace IDs.</li>
<li><b>Persistent Search:</b> Search terms are remembered across sessions.</li>
</ul>
</li>
</ul>
</div>
<div>
<h4 class="font-semibold text-gray-800 mb-2">Interactive Schema Explorer</h4>
<p class="text-gray-600">Browse, test, and interact with your unified GraphQL schema directly from the dashboard, providing a convenient way to validate and explore your API.</p>
</div>
</div>
</section>
<section id="api-reference" class="mb-24">
<h2 class="text-3xl font-bold text-dark mb-8 section-title">API Reference</h2>
<p class="mb-6 text-gray-600">This section details the administrative endpoints for managing the Grapthway gateway.</p>
<h3 class="text-2xl font-semibold text-dark mb-4">Public Endpoints</h3>
<div class="overflow-x-auto bg-white rounded-lg border">
<table class="api-table">
<thead><tr><th>Endpoint</th><th>Description</th><th>Response</th></tr></thead>
<tbody>
<tr>
<td><span class="method method-get">GET</span> /start</td>
<td>Initializes the gateway and generates admin tokens. Should only be called once. Enterprise Edition with Redis can resume without this call.</td>
<td><pre class="!p-2 !text-sm"><code>{\n "message": "grapthway started...",\n "tokens": ["..."],\n "backupTokens": ["..."]\n}</code></pre></td>
</tr>
<tr>
<td><span class="method method-get">GET</span> /status</td>
<td>A simple, public-facing health check.</td>
<td><pre class="!p-2 !text-sm"><code>🚀 grapthway Gateway is running</code></pre></td>
</tr>
</tbody>
</table>