go-duck-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +130 -0
  2. package/generators/cache.js +107 -0
  3. package/generators/config.js +173 -0
  4. package/generators/devops.js +212 -0
  5. package/generators/docs.js +74 -0
  6. package/generators/graphql.js +38 -0
  7. package/generators/kratos.js +157 -0
  8. package/generators/logger.js +68 -0
  9. package/generators/metering.js +143 -0
  10. package/generators/migrations.js +240 -0
  11. package/generators/mqtt.js +87 -0
  12. package/generators/multitenancy.js +130 -0
  13. package/generators/postgrest.js +115 -0
  14. package/generators/repository.js +28 -0
  15. package/generators/resilience.js +69 -0
  16. package/generators/security.js +168 -0
  17. package/generators/swagger.js +145 -0
  18. package/generators/telemetry.js +121 -0
  19. package/generators/websocket.js +162 -0
  20. package/index.js +592 -0
  21. package/package.json +23 -0
  22. package/parser/gdl.js +162 -0
  23. package/templates/application.yml.hbs +18 -0
  24. package/templates/docs/gin_bottle.png +0 -0
  25. package/templates/docs/index.html.hbs +226 -0
  26. package/templates/docs/intro.mp4 +0 -0
  27. package/templates/docs/kratos_mark.png +0 -0
  28. package/templates/docs/layout.hbs +106 -0
  29. package/templates/docs/logo.png +0 -0
  30. package/templates/docs/pages/audit.hbs +39 -0
  31. package/templates/docs/pages/cli.hbs +83 -0
  32. package/templates/docs/pages/gdl.hbs +223 -0
  33. package/templates/docs/pages/graphql.hbs +51 -0
  34. package/templates/docs/pages/grpc.hbs +100 -0
  35. package/templates/docs/pages/index.hbs +181 -0
  36. package/templates/docs/pages/integrations.hbs +83 -0
  37. package/templates/docs/pages/observability.hbs +34 -0
  38. package/templates/docs/pages/realtime.hbs +43 -0
  39. package/templates/docs/pages/rest.hbs +149 -0
  40. package/templates/docs/pages/security.hbs +31 -0
  41. package/templates/go/controller.go.hbs +236 -0
  42. package/templates/go/entity.go.hbs +34 -0
  43. package/templates/go/enum.go.hbs +7 -0
  44. package/templates/go/main.go.hbs +186 -0
  45. package/templates/graphql/resolver.go.hbs +50 -0
  46. package/templates/graphql/schema.graphql.hbs +64 -0
  47. package/templates/kratos/service.go.hbs +104 -0
  48. package/templates/proto/entity.proto.hbs +95 -0
  49. package/test_parser.js +9 -0
@@ -0,0 +1,181 @@
1
+ <div class="mb-16 text-center lg:text-left relative">
2
+ <div class="flex flex-col lg:flex-row items-center justify-center lg:justify-start mb-8 gap-8">
3
+ <div class="relative group">
4
+ <div class="absolute -inset-1 bg-gradient-to-r from-indigo-500 to-purple-600 rounded-2xl blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div>
5
+ <img src="logo.png" alt="GO-DUCK" class="h-28 w-auto drop-shadow-2xl relative bg-white/50 backdrop-blur-sm rounded-2xl p-2 border border-white/50 animate-bounce-slow">
6
+ </div>
7
+ <div>
8
+ <h1 class="text-6xl lg:text-8xl font-extrabold text-slate-900 tracking-tighter leading-tight mb-2">GO-DUCK</h1>
9
+ <p class="text-2xl text-transparent bg-clip-text bg-gradient-to-r from-indigo-600 to-purple-600 font-bold tracking-widest uppercase">The Evolutionary Architecture Factory</p>
10
+ </div>
11
+ </div>
12
+ <p class="text-xl lg:text-3xl text-slate-600 max-w-4xl leading-relaxed font-light">Where high-velocity <strong>Gophers</strong> meet the versatile wisdom of the <strong>Duck</strong> to scaffold microservices that thrive in chaos.</p>
13
+ </div>
14
+
15
+ <section id="the-story" class="mb-24 relative">
16
+ <div class="bg-white rounded-[2.5rem] p-10 md:p-16 border border-slate-200 shadow-2xl shadow-indigo-100/50 relative overflow-hidden">
17
+ <!-- Background Accents -->
18
+ <div class="absolute top-0 right-0 w-[40rem] h-[40rem] bg-indigo-50/50 rounded-full blur-[100px] -mr-48 -mt-48"></div>
19
+ <div class="absolute bottom-0 left-0 w-[30rem] h-[30rem] bg-purple-50/50 rounded-full blur-[100px] -ml-32 -mb-32"></div>
20
+
21
+ <div class="relative z-10">
22
+ <h2 class="text-4xl font-extrabold text-slate-900 mb-6 flex items-center tracking-tight">
23
+ <span class="w-12 h-12 rounded-2xl bg-gradient-to-tr from-orange-400 to-rose-400 text-white flex items-center justify-center mr-5 shadow-lg animate-pulse">🦆</span>
24
+ The Legend of the Century
25
+ </h2>
26
+
27
+ <!-- Cinematic Introduction -->
28
+ <div class="mb-16 relative group">
29
+ <div class="absolute -inset-2 bg-gradient-to-r from-indigo-500 to-purple-600 rounded-[2rem] blur opacity-15 group-hover:opacity-25 transition duration-1000"></div>
30
+ <div class="relative bg-black rounded-[1.5rem] overflow-hidden shadow-2xl border border-white/10 aspect-video">
31
+ <video controls class="w-full h-full object-cover">
32
+ <source src="intro.mp4" type="video/mp4">
33
+ Your browser does not support the video tag.
34
+ </video>
35
+ <div class="absolute bottom-0 left-0 right-0 p-6 bg-gradient-to-t from-black/80 to-transparent pointer-events-none">
36
+ <span class="text-white/70 text-sm font-medium tracking-widest uppercase">Cinematic Introduction</span>
37
+ <h4 class="text-white text-xl font-bold">The Trailer of the Epic</h4>
38
+ </div>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="space-y-16">
43
+ <!-- Chapter 1 -->
44
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center">
45
+ <div class="order-2 lg:order-1">
46
+ <h3 class="text-2xl font-bold text-slate-800 mb-4 font-serif italic text-indigo-700">Chapter I: The Encounter at the Crossroads</h3>
47
+ <p class="text-slate-600 leading-relaxed text-lg">In the legendary Silicon Valley of Code, a nomadic <strong>Gopher</strong>—lightning-fast and known for his tireless concurrency—crossed paths with a <strong>Duck</strong> from the Great Persistence Bayou. The Duck held the wisdom of adaptability and the secret to navigating ever-shifting business tides. They realized that while the Gopher built fast, the Duck built to survive. Together, they forged a pact to create the <strong>Generator of Kings</strong>.</p>
48
+ </div>
49
+ <div class="order-1 lg:order-2 flex justify-center">
50
+ <img src="logo.png" alt="Partnership" class="w-64 h-64 object-contain filter drop-shadow-2xl hover:scale-105 transition-transform duration-500">
51
+ </div>
52
+ </div>
53
+
54
+ <!-- Chapter 2 -->
55
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center">
56
+ <div class="flex justify-center">
57
+ <div class="relative group cursor-zoom-in" onclick="openLightbox('gin_bottle.png')">
58
+ <img src="gin_bottle.png" alt="The Brew" class="w-80 h-80 object-contain filter drop-shadow-2xl group-hover:rotate-6 transition-transform duration-500">
59
+ <div class="absolute -bottom-4 -right-4 bg-white px-4 py-2 rounded-xl shadow-lg border border-slate-100 font-bold text-indigo-600 text-sm">Gin Gonic Tonic</div>
60
+ </div>
61
+ </div>
62
+ <div>
63
+ <h3 class="text-2xl font-bold text-slate-800 mb-4 font-serif italic text-fuchsia-700">Chapter II: The Refreshment of Performance</h3>
64
+ <p class="text-slate-600 leading-relaxed text-lg">To fuel their grand design, they sought the <strong>Legendary Bottle of Gin</strong>. This magical brew wasn't just for hydration; it transformed their web routing into a crystalline, high-performance flow. Routes became fast, middleware became transparent, and the developer experience became as refreshing as a cold tonic on a summer's day. This gave GO-DUCK its distinctive, lightweight spirit.</p>
65
+ </div>
66
+ </div>
67
+
68
+ <!-- Chapter 3 -->
69
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center animate-fade-in-up">
70
+ <div class="order-2 lg:order-1">
71
+ <h3 class="text-2xl font-bold text-slate-800 mb-4 font-serif italic text-emerald-700">Chapter III: The Armor of the Divine</h3>
72
+ <p class="text-slate-600 leading-relaxed text-lg text-pretty">But speed without strength is a house made of cards. In the digital forge of the underworld, they recovered the <strong>Mark of Kratos</strong>. By stamping this sigil onto their internal services, they achieved gRPC industrial resilience. Every service became armored with strict Protocol Buffer contracts, ensuring that no matter how hard the system scaled, it would never break under the divine weight of technical debt.</p>
73
+ </div>
74
+ <div class="order-1 lg:order-2 flex justify-center">
75
+ <div class="relative group cursor-zoom-in" onclick="openLightbox('kratos_mark.png')">
76
+ <div class="absolute inset-0 bg-emerald-400 blur-3xl opacity-20 group-hover:opacity-40 transition-opacity"></div>
77
+ <img src="kratos_mark.png" alt="The Sigil" class="w-80 h-80 object-contain relative z-10 group-hover:scale-110 transition-transform duration-700">
78
+ </div>
79
+ </div>
80
+ </div>
81
+
82
+ <!-- Chapter 4 -->
83
+ <div class="bg-slate-50 rounded-[2rem] p-8 md:p-12 border border-slate-100 text-center max-w-4xl mx-auto shadow-inner">
84
+ <h3 class="text-3xl font-extrabold text-slate-900 mb-6">Chapter IV: The GDL Genesis</h3>
85
+ <p class="text-slate-600 leading-relaxed text-xl mb-8">Thus, the <strong>GDL (Go-Duck Language)</strong> was hatched. A single, simple tongue that could command entire legions of code. From that day forth, every developer who whispered GDL into the CLI would see their architecture <strong>evolve</strong>—bringing the Gopher's speed, the Duck's wisdom, the Gin's clarity, and the Kratos' strength into a single, unified masterpiece.</p>
86
+ <div class="flex justify-center gap-6">
87
+ <img src="logo.png" class="h-12 w-auto opacity-50 grayscale hover:grayscale-0 transition-all cursor-help" title="Adaptability">
88
+ <img src="gin_bottle.png" class="h-12 w-auto opacity-50 grayscale hover:grayscale-0 transition-all cursor-help" title="Clarity">
89
+ <img src="kratos_mark.png" class="h-12 w-auto opacity-50 grayscale hover:grayscale-0 transition-all cursor-help" title="Resilience">
90
+ </div>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </section>
96
+
97
+ <section id="installation" class="mb-20">
98
+ <div class="flex flex-col lg:flex-row gap-10">
99
+ <div class="lg:w-1/2">
100
+ <h2 class="text-3xl font-bold text-slate-800 mb-8 flex items-center tracking-tight">
101
+ <span class="w-10 h-10 rounded-xl bg-slate-900 text-white flex items-center justify-center mr-4 shadow-md text-sm">đź’ľ</span>
102
+ Global Installation
103
+ </h2>
104
+ <div class="group relative">
105
+ <div class="absolute -inset-1 bg-gradient-to-r from-emerald-400 to-indigo-500 rounded-2xl blur opacity-25 group-hover:opacity-40 transition duration-1000"></div>
106
+ <div class="relative bg-slate-900 rounded-2xl overflow-hidden shadow-2xl border border-slate-800">
107
+ <div class="bg-slate-800/80 px-6 py-4 flex items-center justify-between border-b border-slate-700/50">
108
+ <div class="flex items-center space-x-2">
109
+ <div class="w-2.5 h-2.5 rounded-full bg-rose-500/50"></div>
110
+ <div class="w-2.5 h-2.5 rounded-full bg-amber-500/50"></div>
111
+ <div class="w-2.5 h-2.5 rounded-full bg-emerald-500/50"></div>
112
+ </div>
113
+ <span class="text-xs text-slate-500 font-mono tracking-widest uppercase">npm-registry</span>
114
+ </div>
115
+ <div class="p-8 font-mono text-lg">
116
+ <div class="flex items-center">
117
+ <span class="text-emerald-400 mr-4 select-none">❯</span>
118
+ <span class="text-slate-100">npm install -g <span class="text-indigo-400">go-duck-cli</span></span>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ <div class="lg:w-1/2 flex flex-col justify-center space-y-4 pt-10 lg:pt-0">
125
+ <div class="p-8 rounded-3xl bg-white border border-slate-200 shadow-sm transition-all hover:shadow-md hover:border-slate-300">
126
+ <h4 class="font-bold text-slate-900 mb-4 flex items-center text-lg leading-none">
127
+ <svg class="w-6 h-6 text-emerald-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
128
+ Environment Specs
129
+ </h4>
130
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
131
+ <div class="p-3 bg-slate-50 rounded-xl flex items-center"><span class="w-2 h-2 bg-indigo-500 rounded-full mr-3 shrink-0"></span><span class="text-slate-600 font-medium">Node.js 18+</span></div>
132
+ <div class="p-3 bg-slate-50 rounded-xl flex items-center"><span class="w-2 h-2 bg-indigo-500 rounded-full mr-3 shrink-0"></span><span class="text-slate-600 font-medium">Go 1.21+</span></div>
133
+ <div class="p-3 bg-slate-50 rounded-xl flex items-center"><span class="w-2 h-2 bg-indigo-500 rounded-full mr-3 shrink-0"></span><span class="text-slate-600 font-medium">Docker v20+</span></div>
134
+ <div class="p-3 bg-slate-50 rounded-xl flex items-center"><span class="w-2 h-2 bg-indigo-500 rounded-full mr-3 shrink-0"></span><span class="text-slate-600 font-medium">Composability v2+</span></div>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </section>
140
+
141
+ <section id="quick-start" class="mb-12">
142
+ <h2 class="text-2xl font-bold text-slate-800 mb-6 flex items-center">
143
+ <span class="w-8 h-8 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3 text-sm">🚀</span>
144
+ Scaffold & Run
145
+ </h2>
146
+
147
+ <div class="bg-slate-800 rounded-xl overflow-hidden shadow-lg mb-10">
148
+ <div class="bg-slate-900/50 px-4 py-3 border-b border-slate-700/50 flex items-center">
149
+ <div class="flex space-x-1.5 mr-4">
150
+ <div class="w-3 h-3 rounded-full bg-rose-500"></div>
151
+ <div class="w-3 h-3 rounded-full bg-amber-500"></div>
152
+ <div class="w-3 h-3 rounded-full bg-emerald-500"></div>
153
+ </div>
154
+ <span class="text-xs text-slate-400 font-mono">Scaffolding Command</span>
155
+ </div>
156
+ <div class="p-5">
157
+ <pre><code class="language-bash text-sm"># 1. Create a new microservice
158
+ go-duck create -o ./my-app -c config.yaml
159
+
160
+ # 2. Enter and run
161
+ cd my-app
162
+ docker-compose up -d
163
+ go run main.go</code></pre>
164
+ </div>
165
+ </div>
166
+
167
+ <h2 class="text-2xl font-bold text-slate-800 mb-6 mt-12 flex items-center">
168
+ <span class="w-8 h-8 rounded-lg bg-purple-100 text-purple-600 flex items-center justify-center mr-3 text-sm">✨</span>
169
+ Features Overview
170
+ </h2>
171
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-5 mb-8">
172
+ <div class="p-5 rounded-2xl border border-slate-200 bg-white hover:shadow-md transition-all duration-200 group">
173
+ <h3 class="font-bold text-slate-900 mb-2 flex items-center"><svg class="w-5 h-5 text-indigo-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"></path></svg>REST & Search</h3>
174
+ <p class="text-sm text-slate-600 leading-relaxed">Standard CRUD routes alongside a high-performance PostgREST-style RPC system.</p>
175
+ </div>
176
+ <div class="p-5 rounded-2xl border border-slate-200 bg-white hover:shadow-md transition-all duration-200 group">
177
+ <h3 class="font-bold text-slate-900 mb-2 flex items-center"><svg class="w-5 h-5 text-fuchsia-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 10l-2 1m0 0l-2-1m2 1v2.5M20 7l-2 1m2-1l-2-1m2 1v2.5M14 4l-2-1-2 1M4 7l2-1M4 7l2 1M4 7v2.5M12 21l-2-1m2 1l2-1m-2 1v-2.5M6 18l-2-1v-2.5M18 18l2-1v-2.5"></path></svg>GraphQL</h3>
178
+ <p class="text-sm text-slate-600 leading-relaxed">A complete Graph schema integrated natively with GORM data relations.</p>
179
+ </div>
180
+ </div>
181
+ </section>
@@ -0,0 +1,83 @@
1
+ <h1 class="text-4xl font-extrabold text-gray-900 mb-4">Frontend Integrations</h1>
2
+ <p class="text-lg text-gray-600 mb-8">Ready-to-use snippets to wire up leading frontend frameworks to your ultra-fast API backend seamlessly.</p>
3
+
4
+ <section class="mb-10">
5
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">1. Angular (TypeScript)</h2>
6
+ <p class="mb-4">Angular natively employs RxJS `HttpInterceptor` abstractions, making connecting to your GO-DUCK APIs simple.</p>
7
+
8
+ <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4 mb-6 rounded-r">
9
+ <p class="text-indigo-900"><strong>Note:</strong> We bypass typical manual HTTP Auth mapping by using Angular's pre-built <code>keycloak-angular</code> ecosystem package.</p>
10
+ </div>
11
+
12
+ <h3 class="font-semibold mb-2 mt-6">Creating a Service for {{capitalize (defaultStr (lookup entities "0.name") "Entity")}}</h3>
13
+ <pre><code class="language-typescript">import { Injectable } from '@angular/core';
14
+ import { HttpClient, HttpParams } from '@angular/common';
15
+ import { Observable } from 'rxjs';
16
+
17
+ export interface {{capitalize (defaultStr (lookup entities "0.name") "Entity")}} {
18
+ id: number;
19
+ {{#if entities.length}}
20
+ {{#each entities.0.fields}}
21
+ {{name}}: any;
22
+ {{/each}}
23
+ {{/if}}
24
+ }
25
+
26
+ @Injectable({ providedIn: 'root' })
27
+ export class {{capitalize (defaultStr (lookup entities "0.name") "Entity")}}Service {
28
+ private apiUrl = 'http://localhost:8080/api/{{toLowerCase (defaultStr (lookup entities "0.name") "entity")}}s';
29
+
30
+ constructor(private http: HttpClient) {}
31
+
32
+ // Standard REST Fetch with Pagination Parameters
33
+ getAll(page: number = 1, pageSize: number = 10): Observable&lt;any&gt; {
34
+ let params = new HttpParams()
35
+ .set('page', page.toString())
36
+ .set('pageSize', pageSize.toString());
37
+ return this.http.get&lt;any&gt;(this.apiUrl, { params });
38
+ }
39
+
40
+ // Example: Using the powerful Generic Search RPC Engine
41
+ search(queryField: string, operator: string, value: string): Observable&lt;any&gt; {
42
+ let params = new HttpParams().set(queryField, \`\${operator}.\${value}\`);
43
+ return this.http.get&lt;any&gt;('http://localhost:8080/api/rpc/{{toLowerCase (defaultStr (lookup entities "0.name") "entity")}}', { params });
44
+ }
45
+ }
46
+ </code></pre>
47
+ </section>
48
+
49
+ <section class="mb-10">
50
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">2. Flutter (Dart)</h2>
51
+ <p class="mb-4">Connecting a cross-platform mobile app requires managing state efficiently. Here's a raw HTTP Dart integration model you can bind to Provider, Riverpod, or BLoC patterns seamlessly over your Keycloak environment.</p>
52
+
53
+ <pre><code class="language-dart">import 'dart:convert';
54
+ import 'package:http/http.dart' as http;
55
+ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
56
+
57
+ class ApiProvider {
58
+ static const String baseUrl = "http://localhost:8080/api/{{toLowerCase (defaultStr (lookup entities "0.name") "entity")}}s";
59
+ final storage = const FlutterSecureStorage();
60
+
61
+ // Retrieve Keycloak Bearer token from secure storage
62
+ Future&lt;Map&lt;String, String&gt;&gt; _getHeaders() async {
63
+ String? token = await storage.read(key: 'jwt_token');
64
+ return {
65
+ 'Content-Type': 'application/json',
66
+ 'Authorization': 'Bearer $token',
67
+ 'X-Tenant-ID': 'default', // If using Multi-Tenancy module
68
+ };
69
+ }
70
+
71
+ // Fetch API collection
72
+ Future&lt;List&lt;dynamic&gt;&gt; fetch{{capitalize (defaultStr (lookup entities "0.name") "Entity")}}s() async {
73
+ final response = await http.get(Uri.parse(baseUrl), headers: await _getHeaders());
74
+ if (response.statusCode == 200) {
75
+ final data = json.decode(response.body);
76
+ return data['results'];
77
+ } else {
78
+ throw Exception('Failed to load data. Res code: \${response.statusCode}');
79
+ }
80
+ }
81
+ }
82
+ </code></pre>
83
+ </section>
@@ -0,0 +1,34 @@
1
+ <h1 class="text-4xl font-extrabold text-gray-900 mb-4">Total Observability Ecosystem</h1>
2
+ <p class="text-lg text-gray-600 mb-8">Metrics, Datadog streaming, and OpenTelemetry distributed tracing pre-configured natively inside your microservice architecture.</p>
3
+
4
+ <section class="mb-10">
5
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">1. OpenTelemetry Distributed Tracing (OTel)</h2>
6
+ <p class="mb-4">With multiple applications talking to each other, debugging an API timeout inside a black-box environment is devastating. GO-DUCK generated apps utilize full-stack <strong>OpenTelemetry</strong>.</p>
7
+
8
+ <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4 mb-6 rounded-r">
9
+ <p class="text-indigo-900"><strong>Note:</strong> Traces cover the entire round trip. They begin at the <code>otelgin</code> Router level, propagate securely via ctx context through your Controllers and Services, and are eventually finalized by the highly optimized <code>gorm.io/plugin/opentelemetry/tracing</code> hook at the Database execution level.</p>
10
+ </div>
11
+
12
+ <h3 class="font-semibold mb-2 mt-6">Where to view traces?</h3>
13
+ <p class="mb-4">The Go application pushes these <code>otlptracegrpc</code> trace chunks asynchronously out to an <strong>otel-collector</strong> container over port <code>4317</code>.</p>
14
+ <pre><code class="language-bash"># The pre-packaged docker-compose spins up a Jaeger UI node
15
+ # Point your browser to:
16
+ http://localhost:16686</code></pre>
17
+ </section>
18
+
19
+ <section class="mb-10">
20
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">2. Datadog Integration (Log Consolidation)</h2>
21
+ <p class="mb-4">If deployed to the cloud, GO-DUCK apps are compatible with Datadog's Agent endpoints immediately. Inside the <code>application-prod.yml</code>, flip the <code>enabled: true</code> config marker and supply an API key.</p>
22
+
23
+ <pre><code class="language-yaml"># Inside application.yml
24
+ go-duck:
25
+ logging:
26
+ datadog:
27
+ enabled: true
28
+ api-key: "YOUR_NATIVE_DD_AGENT_API_KEY_HERE"
29
+ site: "datadoghq.com"
30
+ service: "inventory-microservice"</code></pre>
31
+
32
+ <h3 class="font-semibold mb-2 mt-6">3. System Infrastructure Metrics (Statsd)</h3>
33
+ <p class="mb-4 text-gray-700">The <code>logger</code> package has a sidecar implementation for Datadog's <code>statsd</code>. A developer can quickly drop custom <code>logger.Count("api.hit")</code> or <code>logger.Histogram("db.latency")</code> functions into their services to populate dashboard charts.</p>
34
+ </section>
@@ -0,0 +1,43 @@
1
+ <h1 class="text-4xl font-extrabold text-gray-900 mb-4">WebSockets & MQTT Event Streaming</h1>
2
+ <p class="text-lg text-gray-600 mb-8">Execute REST requests securely over full-duplex WebSocket connections or subscribe to async CRUD event streaming.</p>
3
+
4
+ <section class="mb-10">
5
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">1. REST-over-WS Dispatcher</h2>
6
+ <p class="mb-4">Instead of traditional HTTP, you can pass highly efficient "Traced Envelopes" through our WebSocket endpoint at <code>ws://localhost:8080/ws</code>. The GO-DUCK generated engine unpacks the WS payload and routes it natively through Gin.</p>
7
+
8
+ <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4 mb-6 rounded-r">
9
+ <p class="text-indigo-900"><strong>Note:</strong> Token validation is done via query-param out of necessity due to websocket protocol limitations.</p>
10
+ </div>
11
+
12
+ <h3 class="font-semibold mb-2 mt-6">Browser/JS Connection Spec</h3>
13
+ <pre><code class="language-javascript">const token = "eyJhbGciOi..."; // Valid Keycloak Access Token
14
+
15
+ // Phase 1: Authentication happens precisely on the handshake (WSS Handshake via query param)
16
+ const ws = new WebSocket(\`ws://localhost:8080/ws?token=\${token}\`);
17
+
18
+ ws.onopen = () => {
19
+ // Phase 2: Send HMAC-SHA256 Encrypted / Signed Messages!
20
+ ws.send(JSON.stringify({
21
+ TraceID: "uuid-v4-frontend-req",
22
+ Method: "GET",
23
+ Path: "/api/{{toLowerCase (defaultStr (lookup entities "0.name") "entity")}}s",
24
+ Payload: "{}",
25
+ Signature: "2d7a221f7dbb2..." // Signature ensures Message Integrity
26
+ }));
27
+ };
28
+
29
+ ws.onmessage = (event) => console.log("Received via WS:", event.data);</code></pre>
30
+ </section>
31
+
32
+ <section class="mb-10">
33
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">2. Asynchronous MQTT Streaming</h2>
34
+ <p class="mb-4">Rather than relying entirely on synchronous API calls, every successful <code>CREATE / UPDATE / DELETE</code> on any GDL generated model emits an event to the unified MQTT broker configured in the `docker-compose.yml`.</p>
35
+
36
+ <h3 class="font-semibold mb-2">How to listen for specific webhooks</h3>
37
+ <pre><code class="language-bash"># mosquitto_sub listening to any mutation globally inside the microservice
38
+ mosquitto_sub -h localhost -p 1883 -t "go-duck/events/#" -u dev_user -P dev_password
39
+
40
+ # To listen ONLY when the {{capitalize (defaultStr (lookup entities "0.name") "Entity")}} object gets created
41
+ mosquitto_sub -h localhost -p 1883 -t "go-duck/events/{{toLowerCase (defaultStr (lookup entities "0.name") "entity")}}/CREATE" -u dev_user -P dev_password
42
+ </code></pre>
43
+ </section>
@@ -0,0 +1,149 @@
1
+ <div class="mb-10 text-center lg:text-left border-b border-slate-200 pb-8 text-neutral-900">
2
+ <div class="inline-flex items-center px-3 py-1 rounded-full bg-indigo-100 text-indigo-700 text-xs font-semibold tracking-wide uppercase mb-4">
3
+ Communication Layer
4
+ </div>
5
+ <h1 class="text-4xl lg:text-5xl font-extrabold text-slate-900 tracking-tight leading-tight mb-4">REST & Search API</h1>
6
+ <p class="text-lg lg:text-xl text-slate-600 max-w-2xl leading-relaxed">High-performance, tenant-aware JSON endpoints powered by Gin Gonic and GORM.</p>
7
+ </div>
8
+
9
+ <!-- Mode Overview -->
10
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
11
+ <div class="bg-gradient-to-br from-indigo-600 to-indigo-800 p-8 rounded-[2rem] text-white shadow-xl shadow-indigo-200/50">
12
+ <h3 class="text-xl font-bold mb-3 flex items-center">
13
+ <svg class="w-6 h-6 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path></svg>
14
+ Entity-Specific CRUD
15
+ </h3>
16
+ <p class="text-indigo-100 text-sm leading-relaxed mb-6">Standard strongly-typed controllers for every entity. Includes built-in caching, MQTT eventing, and multi-tenancy.</p>
17
+ <div class="text-xs font-mono bg-white/10 p-3 rounded-xl border border-white/20">
18
+ GET /api/articles<br>
19
+ GET /api/articles/:id?eager=true
20
+ </div>
21
+ </div>
22
+ <div class="bg-gradient-to-br from-slate-800 to-slate-900 p-8 rounded-[2rem] text-white shadow-xl shadow-slate-300/50">
23
+ <h3 class="text-xl font-bold mb-3 flex items-center">
24
+ <svg class="w-6 h-6 mr-3 text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
25
+ Generic Search RPC
26
+ </h3>
27
+ <p class="text-slate-300 text-sm leading-relaxed mb-6">A single, ultra-flexible engine mirroring PostgREST. Filter by any column using powerful operators WITHOUT writing code.</p>
28
+ <div class="text-xs font-mono bg-white/10 p-3 rounded-xl border border-white/20">
29
+ GET /api/rpc/articles?status=eq.PUBLISHED<br>
30
+ GET /api/rpc/articles?id=gt.100&order=id.desc
31
+ </div>
32
+ </div>
33
+ </div>
34
+
35
+ <section class="mb-12">
36
+ <h2 class="text-2xl font-bold text-slate-800 mb-6 flex items-center">
37
+ <span class="w-8 h-8 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-3 text-sm">
38
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path></svg>
39
+ </span>
40
+ Standard Controller Features
41
+ </h2>
42
+
43
+ <div class="space-y-8">
44
+ <!-- Relationship Loading -->
45
+ <div class="bg-white border border-slate-200 rounded-2xl p-6 shadow-sm">
46
+ <h4 class="font-bold text-slate-900 mb-3">📦 Eager vs. Lazy Loading</h4>
47
+ <p class="text-slate-600 text-sm mb-4 leading-relaxed">
48
+ By default, entities are loaded <strong>Lazily</strong> (IDs only for foreign keys). To perform a Join and fetch the full object graph, use the <code class="bg-slate-100 px-1 py-0.5 rounded text-indigo-600 font-mono">eager</code> parameter.
49
+ </p>
50
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
51
+ <div class="bg-slate-50 p-4 rounded-xl">
52
+ <span class="text-[10px] font-bold uppercase tracking-widest text-slate-400">Lazy (Default)</span>
53
+ <p class="font-mono text-xs mt-2 text-slate-700">GET /api/article/1</p>
54
+ </div>
55
+ <div class="bg-emerald-50 p-4 rounded-xl">
56
+ <span class="text-[10px] font-bold uppercase tracking-widest text-emerald-500">Eager (Joined)</span>
57
+ <p class="font-mono text-xs mt-2 text-slate-700">GET /api/article/1?eager=true</p>
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <!-- Pagination -->
63
+ <div class="bg-white border border-slate-200 rounded-2xl p-6 shadow-sm">
64
+ <h4 class="font-bold text-slate-900 mb-3">📏 Offset Pagination</h4>
65
+ <p class="text-slate-600 text-sm mb-4 leading-relaxed">
66
+ All collection endpoints support built-in pagination to keep your frontend lightning fast.
67
+ </p>
68
+ <table class="w-full text-xs text-left border-collapse">
69
+ <thead>
70
+ <tr class="text-slate-400 border-b border-slate-100">
71
+ <th class="py-2">Parameter</th>
72
+ <th class="py-2">Description</th>
73
+ <th class="py-2">Default</th>
74
+ </tr>
75
+ </thead>
76
+ <tbody class="text-slate-700">
77
+ <tr class="border-b border-slate-50"><td class="py-3 font-mono font-bold">page</td><td class="py-3">The index of the page to fetch</td><td class="py-3">0</td></tr>
78
+ <tr class="border-b border-slate-50"><td class="py-3 font-mono font-bold">size</td><td class="py-3">Number of records per page</td><td class="py-3">20</td></tr>
79
+ </tbody>
80
+ </table>
81
+ </div>
82
+
83
+ <!-- Distributed Caching -->
84
+ <div class="bg-gradient-to-r from-blue-500 to-indigo-600 rounded-2xl p-6 text-white text-sm shadow-lg">
85
+ <div class="flex items-start">
86
+ <div class="bg-white/20 p-2 rounded-lg mr-4">
87
+ <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>
88
+ </div>
89
+ <div>
90
+ <h4 class="font-bold mb-1">Distributed Redis Shield</h4>
91
+ <p class="text-blue-50 leading-relaxed">
92
+ Every <code class="bg-white/20 px-1 rounded">GetByID</code> request is automatically protected by a Redis cache layer. Mutations (Create/Update/Delete) trigger <strong>Automatic Cache Invalidation</strong> across the cluster, ensuring data consistency with zero effort.
93
+ </p>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </section>
99
+
100
+ <section class="mb-12">
101
+ <h2 class="text-2xl font-bold text-slate-800 mb-6 flex items-center">
102
+ <span class="w-8 h-8 rounded-lg bg-emerald-100 text-emerald-600 flex items-center justify-center mr-3 text-sm">
103
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
104
+ </span>
105
+ Generic Search RPC Engine
106
+ </h2>
107
+ <p class="mb-6 text-slate-600 leading-relaxed text-sm">Accessed via <code class="bg-slate-100 px-1 py-0.5 rounded text-indigo-600 font-mono">/api/rpc/:tableName</code>, this engine provides a dynamic interface to your database.</p>
108
+
109
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8 text-sm">
110
+ <div class="bg-slate-900 rounded-2xl p-6 text-slate-300 font-mono text-xs overflow-x-auto">
111
+ <span class="text-emerald-400"># Complex query example</span><br>
112
+ curl -X GET "http://localhost:8080/api/rpc/articles?status=eq.PUBLISHED&views=gt.500&order=views.desc&limit=5"
113
+ </div>
114
+ <div class="bg-slate-50 border border-slate-200 rounded-2xl p-6">
115
+ <h5 class="text-slate-900 font-bold mb-3">Supported Operators</h5>
116
+ <div class="grid grid-cols-2 gap-2 text-[11px] font-mono">
117
+ <div class="flex justify-between border-b pb-1"><span>eq</span><span class="text-indigo-600">Equals</span></div>
118
+ <div class="flex justify-between border-b pb-1"><span>neq</span><span class="text-indigo-600">Not Equals</span></div>
119
+ <div class="flex justify-between border-b pb-1"><span>gt / gte</span><span class="text-indigo-600">Greater Than</span></div>
120
+ <div class="flex justify-between border-b pb-1"><span>lt / lte</span><span class="text-indigo-600">Less Than</span></div>
121
+ <div class="flex justify-between border-b pb-1"><span>like</span><span class="text-indigo-600">Search (%)</span></div>
122
+ <div class="flex justify-between border-b pb-1"><span>ilike</span><span class="text-indigo-600">Case-Insensitive</span></div>
123
+ <div class="flex justify-between border-b pb-1"><span>in</span><span class="text-indigo-600">List (1,2,3)</span></div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ </section>
128
+
129
+ <section class="mb-12">
130
+ <h2 class="text-2xl font-bold text-slate-800 mb-6 flex items-center">
131
+ <span class="w-8 h-8 rounded-lg bg-rose-100 text-rose-600 flex items-center justify-center mr-3 text-sm">
132
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path></svg>
133
+ </span>
134
+ Security & Context
135
+ </h2>
136
+ <div class="bg-rose-50 border border-rose-100 rounded-2xl p-6 flex items-start">
137
+ <div class="bg-rose-100 p-2 rounded-lg mr-4">
138
+ <svg class="w-6 h-6 text-rose-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
139
+ </div>
140
+ <div>
141
+ <h4 class="font-bold text-rose-900 mb-1">Mandatory Headers</h4>
142
+ <p class="text-rose-700 text-sm leading-relaxed mb-4">Every Go-Duck API request must satisfy the Identity and Multi-Tenancy gatekeepers.</p>
143
+ <ul class="space-y-2 text-xs font-mono text-rose-800">
144
+ <li><span class="font-bold">Authorization:</span> Bearer &lt;Keycloak_JWT&gt;</li>
145
+ <li><span class="font-bold">X-Tenant-ID:</span> Subdomain or ID of the tenant dashboard</li>
146
+ </ul>
147
+ </div>
148
+ </div>
149
+ </section>
@@ -0,0 +1,31 @@
1
+ <h1 class="text-4xl font-extrabold text-gray-900 mb-4">Security & Resilience</h1>
2
+ <p class="text-lg text-gray-600 mb-8">Out-of-the-box infrastructure protecting your core microservices.</p>
3
+
4
+ <section class="mb-10">
5
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">1. Identity & Access Management (OIDC)</h2>
6
+ <p class="mb-4">GO-DUCK generated apps utilize strict Keycloak JWT Authorization. No entity router functions without traversing the <code>jwtAuthMiddleware</code> and extracting structural properties of the connected user from the signed payload utilizing the pre-configured realm secret.</p>
7
+
8
+ <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4 mb-6 rounded-r">
9
+ <p class="text-indigo-900"><strong>Golden Rule:</strong> In <code>application-dev.yml</code>, ensure your Keycloak Realm, ClientID, and Secret are accurately synced with the local running Docker Keycloak image.</p>
10
+ </div>
11
+
12
+ <h3 class="font-semibold mb-2 mt-6">2. Burst Protection (Rate Limiting)</h3>
13
+ <p class="mb-4">Using the standard <code>x/time/rate</code> package, a Token Bucket rate limiter is attached to the Gin Engine globally to mitigate DDOS vectors and abusive scripting.</p>
14
+ <pre><code class="language-yaml"># Inside your application-prod.yml
15
+ go-duck:
16
+ security:
17
+ rate-limit:
18
+ rps: 150.0 # Allow up to 150 Req/Sec
19
+ burst: 300 # Burstable tokens
20
+ </code></pre>
21
+ </section>
22
+
23
+ <section class="mb-10">
24
+ <h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">3. Sony/go-breaker (Circuit Breakers)</h2>
25
+ <p class="mb-4">When a Microservice starts rejecting requests globally due to a failing dependent macro-service (e.g. Redis node goes down / DB locks / MQTT broker drops), your application handles this gracefully by "tripping" an open Circuit Breaker to prevent Request Queue Pile-ups.</p>
26
+
27
+ <pre><code class="language-go">resilience.Execute(func() (interface{}, error) {
28
+ // Risky Network / DB Operations wrapped automatically!
29
+ return s.repo.DB.First(&entity, req.Id).Error
30
+ })</code></pre>
31
+ </section>