@bluealba/platform-cli 1.0.1 → 1.1.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 (52) hide show
  1. package/dist/index.js +278 -15
  2. package/docs/404.mdx +5 -0
  3. package/docs/architecture/api-explorer.mdx +478 -0
  4. package/docs/architecture/architecture-diagrams.mdx +12 -0
  5. package/docs/architecture/authentication-system.mdx +903 -0
  6. package/docs/architecture/authorization-system.mdx +886 -0
  7. package/docs/architecture/bootstrap.mdx +1442 -0
  8. package/docs/architecture/gateway-architecture.mdx +845 -0
  9. package/docs/architecture/multi-tenancy.mdx +1150 -0
  10. package/docs/architecture/overview.mdx +776 -0
  11. package/docs/architecture/scheduler.mdx +818 -0
  12. package/docs/architecture/shell.mdx +885 -0
  13. package/docs/architecture/ui-extension-points.mdx +781 -0
  14. package/docs/architecture/user-states.mdx +794 -0
  15. package/docs/development/overview.mdx +21 -0
  16. package/docs/development/workflow.mdx +914 -0
  17. package/docs/getting-started/core-concepts.mdx +892 -0
  18. package/docs/getting-started/installation.mdx +780 -0
  19. package/docs/getting-started/overview.mdx +83 -0
  20. package/docs/getting-started/quick-start.mdx +940 -0
  21. package/docs/guides/adding-documentation-sites.mdx +1367 -0
  22. package/docs/guides/creating-services.mdx +1736 -0
  23. package/docs/guides/creating-ui-modules.mdx +1860 -0
  24. package/docs/guides/identity-providers.mdx +1007 -0
  25. package/docs/guides/mermaid-diagrams.mdx +212 -0
  26. package/docs/guides/using-feature-flags.mdx +1059 -0
  27. package/docs/guides/working-with-rooms.mdx +566 -0
  28. package/docs/index.mdx +57 -0
  29. package/docs/platform-cli/commands.mdx +604 -0
  30. package/docs/platform-cli/overview.mdx +195 -0
  31. package/package.json +5 -2
  32. package/skills/ba-platform/platform-cli.skill.md +26 -0
  33. package/skills/ba-platform/platform.skill.md +35 -0
  34. package/templates/application-monorepo-template/gitignore +95 -0
  35. package/templates/bootstrap-service-template/Dockerfile.development +1 -1
  36. package/templates/bootstrap-service-template/gitignore +57 -0
  37. package/templates/bootstrap-service-template/package.json +1 -1
  38. package/templates/bootstrap-service-template/src/main.ts +6 -16
  39. package/templates/customization-ui-module-template/Dockerfile.development +1 -1
  40. package/templates/customization-ui-module-template/gitignore +73 -0
  41. package/templates/nestjs-service-module-template/Dockerfile.development +1 -1
  42. package/templates/nestjs-service-module-template/gitignore +56 -0
  43. package/templates/platform-init-template/{{platformName}}-core/gitignore +97 -0
  44. package/templates/platform-init-template/{{platformName}}-core/local/.env.example +1 -1
  45. package/templates/platform-init-template/{{platformName}}-core/local/platform-docker-compose.yml +1 -1
  46. package/templates/platform-init-template/{{platformName}}-core/local/{{platformName}}-core-docker-compose.yml +0 -1
  47. package/templates/react-ui-module-template/Dockerfile +1 -1
  48. package/templates/react-ui-module-template/Dockerfile.development +1 -3
  49. package/templates/react-ui-module-template/caddy/Caddyfile +1 -1
  50. package/templates/react-ui-module-template/gitignore +72 -0
  51. package/templates/react-ui-module-template/Dockerfile_nginx +0 -11
  52. package/templates/react-ui-module-template/nginx/default.conf +0 -23
@@ -0,0 +1,1367 @@
1
+ ---
2
+ title: Adding Documentation Sites
3
+ description: Complete guide to creating and deploying documentation sites using the documentation-template within the Blue Alba Platform
4
+ ---
5
+
6
+ import { Card, CardGrid, Aside, Tabs, TabItem } from '@astrojs/starlight/components';
7
+ import MermaidDiagram from '~/components/MermaidDiagram.astro';
8
+
9
+ The Blue Alba Platform includes a powerful documentation feature that enables you to seamlessly integrate documentation sites with your applications. This feature leverages a reusable Docker image called `pae-documentation-template`, making it simple to deploy modern, performant documentation sites alongside your application code.
10
+
11
+ ## Overview
12
+
13
+ The documentation system is built on a simple design philosophy: documentation files live with production code, ensuring documentation evolves alongside feature development and reducing the risk of outdated information.
14
+
15
+ ### Key Benefits
16
+
17
+ <CardGrid stagger>
18
+ <Card title="Zero Configuration" icon="seti:config">
19
+ The template abstracts all complexity. Just add your markdown files and configuration - no build setup required.
20
+ </Card>
21
+
22
+ <Card title="Modern Framework" icon="rocket">
23
+ Built on Starlight and Astro, providing a fast, accessible, and beautiful documentation experience.
24
+ </Card>
25
+
26
+ <Card title="Platform Integration" icon="puzzle">
27
+ Automatic discovery and navigation links in the platform shell. No manual integration needed.
28
+ </Card>
29
+
30
+ <Card title="Access Control" icon="lock">
31
+ Built-in authorization support. Control who can access which documentation using platform operations.
32
+ </Card>
33
+ </CardGrid>
34
+
35
+ ---
36
+
37
+ ## Architecture
38
+
39
+ The documentation system uses a layered architecture built around the reusable `pae-documentation-template` Docker image.
40
+
41
+ <MermaidDiagram
42
+ title="Documentation Architecture"
43
+ code={`graph LR
44
+ A[pae-documentation-template<br/>Docker Image]:::template --> B[app-documentation<br/>Application Layer]:::app
45
+ B --> C[app-documentation-site<br/>Generated Site]:::site
46
+ D[documentation<br/>files]:::content --> B
47
+ E[configuration<br/>config.json]:::content --> B
48
+
49
+ classDef template fill:#90EE90,color:#333
50
+ classDef app fill:#87CEEB,color:#333
51
+ classDef site fill:#FFB6C1,color:#333
52
+ classDef content fill:#FFD700,color:#333`}
53
+ />
54
+
55
+ ### Architecture Components
56
+
57
+ - **pae-documentation-template**: Base Docker image containing Starlight/Astro framework, Nginx server, and build tooling
58
+ - **app-documentation**: Your application layer combining the template with custom content and configuration
59
+ - **app-documentation-site**: The resulting generated documentation website served via Nginx
60
+ - **documentation files**: Your markdown (MDX) files containing the actual documentation content
61
+ - **configuration**: `config.json` file defining site structure, theme, navigation, and behavior
62
+
63
+ ---
64
+
65
+ ## Quick Start
66
+
67
+ Deploy a documentation site in three straightforward steps:
68
+
69
+ ### 1. Create the Documentation Application
70
+
71
+ Create a new application directory structure with your content:
72
+
73
+ ```bash
74
+ my-app-documentation/
75
+ ├── Dockerfile
76
+ ├── docs/ # Your MDX documentation files
77
+ │ ├── index.mdx
78
+ │ ├── guides/
79
+ │ │ ├── getting-started.mdx
80
+ │ │ └── advanced-usage.mdx
81
+ │ └── reference/
82
+ │ └── api.mdx
83
+ ├── assets/ # Images, diagrams, etc.
84
+ │ └── logo.svg
85
+ └── config.json # Site configuration
86
+ ```
87
+
88
+ ### 2. Register the Documentation Module
89
+
90
+ Configure a new module in the Applications Catalog with type `documentation`:
91
+
92
+ ```json
93
+ {
94
+ "name": "my-app-documentation",
95
+ "type": "documentation",
96
+ "displayName": "My App Documentation",
97
+ "description": "Complete documentation for My App",
98
+ "route": "/docs/my-app",
99
+ "application": "my-app"
100
+ }
101
+ ```
102
+
103
+ ### 3. Configure Service Deployment
104
+
105
+ Add the documentation service to your `docker-compose.yml`:
106
+
107
+ ```yaml
108
+ services:
109
+ my-app-documentation:
110
+ image: my-app-documentation:latest
111
+ container_name: my-app-documentation
112
+ ports:
113
+ - "8080:80"
114
+ environment:
115
+ - NODE_ENV=production
116
+ networks:
117
+ - platform-network
118
+ ```
119
+
120
+ That's it! Once deployed, the documentation site becomes immediately accessible through the platform.
121
+
122
+ ---
123
+
124
+ ## Creating Documentation Content
125
+
126
+ ### Step-by-Step Setup
127
+
128
+ <Tabs>
129
+ <TabItem label="1. Create Dockerfile">
130
+
131
+ Create a `Dockerfile` that extends the base template:
132
+
133
+ ```dockerfile
134
+ # Use the base documentation template image
135
+ FROM bluealba-ba-pae-releases-docker.jfrog.io/bluealba-pae-documentation-template:latest
136
+
137
+ # Copy your documentation content
138
+ COPY ./docs/ /app/src/content/docs/
139
+ COPY ./assets/ /app/src/assets
140
+ COPY ./config.json /app/src/config.json
141
+
142
+ # Optional: Customize via environment variables
143
+ ENV SITE_TITLE="My App Documentation"
144
+ ENV SITE_DESCRIPTION="Complete documentation for My App including guides and API reference"
145
+
146
+ # Optional: Add custom logo
147
+ COPY ./logo.svg /app/src/assets/logo.svg
148
+ ENV SITE_LOGO="./src/assets/logo.svg"
149
+
150
+ # Optional: Add GitHub link
151
+ ENV GITHUB_URL="https://github.com/myorg/my-app"
152
+ ```
153
+
154
+ **Key Points:**
155
+ - The base image contains all necessary build tools and frameworks
156
+ - You only need to add your content files and configuration
157
+ - Environment variables provide simple customization
158
+ - The entrypoint is inherited from the base image (validates, builds, serves)
159
+
160
+ </TabItem>
161
+
162
+ <TabItem label="2. Create config.json">
163
+
164
+ Create a `config.json` file to configure your documentation site:
165
+
166
+ ```json
167
+ {
168
+ "title": "My App Documentation",
169
+ "description": "Complete documentation for My App",
170
+ "logo": {
171
+ "src": "./src/assets/logo.svg",
172
+ "alt": "My App Logo"
173
+ },
174
+ "social": {
175
+ "github": "https://github.com/myorg/my-app"
176
+ },
177
+ "sidebar": [
178
+ {
179
+ "label": "Getting Started",
180
+ "items": [
181
+ { "label": "Introduction", "link": "/" },
182
+ { "label": "Installation", "link": "/guides/installation" },
183
+ { "label": "Quick Start", "link": "/guides/quick-start" }
184
+ ]
185
+ },
186
+ {
187
+ "label": "Guides",
188
+ "autogenerate": { "directory": "guides" }
189
+ },
190
+ {
191
+ "label": "API Reference",
192
+ "autogenerate": { "directory": "reference" }
193
+ }
194
+ ],
195
+ "customCss": [
196
+ "./src/styles/custom.css"
197
+ ],
198
+ "components": {
199
+ "Head": "./src/components/Head.astro"
200
+ }
201
+ }
202
+ ```
203
+
204
+ **Configuration Options:**
205
+
206
+ | Option | Description | Required |
207
+ |--------|-------------|----------|
208
+ | `title` | Site title (appears in header and browser tab) | Yes |
209
+ | `description` | Site description for SEO meta tags | Yes |
210
+ | `logo` | Site logo configuration (src and alt text) | No |
211
+ | `social` | Social media links (GitHub, Twitter, etc.) | No |
212
+ | `sidebar` | Navigation sidebar structure | Yes |
213
+ | `customCss` | Custom CSS files to apply | No |
214
+ | `components` | Custom Astro components to override | No |
215
+
216
+ </TabItem>
217
+
218
+ <TabItem label="3. Write Content">
219
+
220
+ Create your documentation files using MDX (Markdown with JSX):
221
+
222
+ ```mdx
223
+ ---
224
+ title: Getting Started
225
+ description: Learn how to get started with My App in 5 minutes
226
+ ---
227
+
228
+ import { Card, CardGrid, Aside } from '@astrojs/starlight/components';
229
+
230
+ Welcome to My App! This guide will help you get started quickly.
231
+
232
+ ## Installation
233
+
234
+ Install My App using npm:
235
+
236
+ \`\`\`bash
237
+ npm install my-app
238
+ \`\`\`
239
+
240
+ <Aside type="tip">
241
+ For production deployments, consider using Docker for better isolation and consistency.
242
+ </Aside>
243
+
244
+ ## Quick Example
245
+
246
+ Here's a simple example to get you started:
247
+
248
+ \`\`\`javascript
249
+ import { MyApp } from 'my-app';
250
+
251
+ const app = new MyApp({
252
+ apiKey: 'your-api-key',
253
+ environment: 'production'
254
+ });
255
+
256
+ await app.start();
257
+ console.log('App started successfully!');
258
+ \`\`\`
259
+
260
+ ## Next Steps
261
+
262
+ <CardGrid>
263
+ <Card title="Configuration" icon="setting">
264
+ Learn about all available configuration options
265
+ </Card>
266
+ <Card title="API Reference" icon="document">
267
+ Explore the complete API documentation
268
+ </Card>
269
+ </CardGrid>
270
+ ```
271
+
272
+ **MDX Features Available:**
273
+ - Full Markdown syntax (headings, lists, code blocks, tables)
274
+ - Syntax highlighting for code blocks (100+ languages)
275
+ - Starlight components (Card, Aside, Tabs, FileTree, etc.)
276
+ - Custom React components
277
+ - Mermaid diagrams for visualizations
278
+ - Frontmatter for page metadata
279
+
280
+ </TabItem>
281
+
282
+ <TabItem label="4. Build & Deploy">
283
+
284
+ Build and deploy your documentation:
285
+
286
+ ```bash
287
+ # Build the Docker image
288
+ docker build -t my-app-documentation:latest .
289
+
290
+ # Run locally for testing
291
+ docker run -p 8080:80 my-app-documentation:latest
292
+
293
+ # Access the documentation
294
+ open http://localhost:8080
295
+
296
+ # Check health endpoint
297
+ curl http://localhost:8080/health
298
+
299
+ # Push to registry
300
+ docker tag my-app-documentation:latest registry.example.com/my-app-documentation:latest
301
+ docker push registry.example.com/my-app-documentation:latest
302
+
303
+ # Deploy via docker-compose or orchestrator
304
+ docker-compose up -d my-app-documentation
305
+ ```
306
+
307
+ **Build Process:**
308
+ 1. Docker copies your content into the image
309
+ 2. Entrypoint validates content exists
310
+ 3. Astro builds the static site (optimized HTML, CSS, JS)
311
+ 4. Nginx serves the built site
312
+ 5. Health check endpoint available at `/health`
313
+
314
+ </TabItem>
315
+ </Tabs>
316
+
317
+ ---
318
+
319
+ ## Platform Integration
320
+
321
+ The Blue Alba Platform provides seamless integration for documentation modules, making them instantly discoverable and accessible.
322
+
323
+ ### Automatic Navigation Links
324
+
325
+ <MermaidDiagram
326
+ title="Documentation Discovery Flow"
327
+ code={`sequenceDiagram
328
+ participant User
329
+ participant Shell as Platform Shell
330
+ participant Catalog as Application Catalog
331
+ participant Docs as Documentation Module
332
+
333
+ User->>Shell: Load Application
334
+ Shell->>Catalog: Query modules for application
335
+ Catalog-->>Shell: Return all modules
336
+ Shell->>Shell: Filter modules by type="documentation"
337
+ Shell->>Shell: Generate navigation links
338
+ Shell-->>User: Display app with doc links
339
+ User->>Docs: Click documentation link
340
+ Docs-->>User: Open docs in new tab`}
341
+ />
342
+
343
+ The platform shell automatically:
344
+ 1. Detects documentation modules associated with each application
345
+ 2. Generates navigation links at the bottom of the application's navigation bar
346
+ 3. Opens documentation in a new tab for convenient reference
347
+ 4. Supports multiple documentation modules per application
348
+
349
+ **Multiple Documentation Modules:**
350
+
351
+ You can configure multiple documentation modules per application for logical separation:
352
+
353
+ ```json
354
+ // Technical documentation (developers only)
355
+ {
356
+ "name": "my-app-technical-docs",
357
+ "type": "documentation",
358
+ "displayName": "Technical Documentation",
359
+ "route": "/docs/my-app/technical",
360
+ "application": "my-app",
361
+ "operations": ["my-app::documentation::technical"]
362
+ }
363
+
364
+ // User documentation (all users)
365
+ {
366
+ "name": "my-app-user-docs",
367
+ "type": "documentation",
368
+ "displayName": "User Guide",
369
+ "route": "/docs/my-app/user-guide",
370
+ "application": "my-app",
371
+ "operations": ["my-app::documentation::user-guide"]
372
+ }
373
+
374
+ // Admin documentation (administrators only)
375
+ {
376
+ "name": "my-app-admin-docs",
377
+ "type": "documentation",
378
+ "displayName": "Admin Documentation",
379
+ "route": "/docs/my-app/admin",
380
+ "application": "my-app",
381
+ "operations": ["my-app::documentation::admin"]
382
+ }
383
+ ```
384
+
385
+ ### Authorization and Access Control
386
+
387
+ Documentation modules support the platform's built-in authorization system through operations.
388
+
389
+ <Aside type="tip" title="Operations-Based Access">
390
+ Assign operations to documentation modules to control visibility. Only users with the required operation will see the documentation link in the navigation.
391
+ </Aside>
392
+
393
+ **Access Control Flow:**
394
+
395
+ <MermaidDiagram
396
+ title="Documentation Authorization"
397
+ code={`graph TD
398
+ A[User loads application] --> B{Check user operations}
399
+ B --> C{Has doc operation?}
400
+ C -->|Yes| D[Show documentation link]
401
+ C -->|No| E[Hide documentation link]
402
+ D --> F[User clicks link]
403
+ F --> G{Gateway authorization check}
404
+ G -->|Authorized| H[Serve documentation]
405
+ G -->|Not authorized| I[Return 403 Forbidden]
406
+
407
+ style H fill:#90EE90,color:#333
408
+ style I fill:#FFB6C1,color:#333`}
409
+ />
410
+
411
+ **Example Use Cases:**
412
+
413
+ <CardGrid>
414
+ <Card title="Public Documentation" icon="open-book">
415
+ No operations required - visible to all application users. Perfect for general user guides.
416
+ </Card>
417
+
418
+ <Card title="Technical Documentation" icon="seti:config">
419
+ Assign `app::documentation::technical` - visible only to developers and technical staff.
420
+ </Card>
421
+
422
+ <Card title="Admin Documentation" icon="lock">
423
+ Assign `app::documentation::admin` - restricted to system administrators only.
424
+ </Card>
425
+
426
+ <Card title="Partner Documentation" icon="document">
427
+ Assign `app::documentation::partner` - accessible to partner organizations only.
428
+ </Card>
429
+ </CardGrid>
430
+
431
+ ---
432
+
433
+ ## Catalog Registration
434
+
435
+ Register your documentation module in the Application Catalog to integrate with the platform.
436
+
437
+ ### Via Admin UI
438
+
439
+ 1. Navigate to **Admin UI** → **Applications** → **Catalog**
440
+ 2. Click **Add Module**
441
+ 3. Fill in the form:
442
+ - **Name**: `my-app-documentation` (unique identifier)
443
+ - **Type**: Select `documentation`
444
+ - **Display Name**: `My App Documentation` (shown in navigation)
445
+ - **Description**: Brief description of the documentation
446
+ - **Route**: `/docs/my-app` (URL path to access documentation)
447
+ - **Application**: Select your application from dropdown
448
+ - **Operations**: Add operations for access control (optional)
449
+ 4. Click **Save**
450
+
451
+ ### Via API
452
+
453
+ ```bash
454
+ POST /api/catalog/modules
455
+ Content-Type: application/json
456
+ Authorization: Bearer <admin-jwt>
457
+
458
+ {
459
+ "name": "my-app-documentation",
460
+ "type": "documentation",
461
+ "displayName": "My App Documentation",
462
+ "description": "Complete documentation for My App including guides and API reference",
463
+ "route": "/docs/my-app",
464
+ "application": "my-app-id",
465
+ "operations": ["my-app::documentation::access"],
466
+ "metadata": {
467
+ "version": "1.0.0",
468
+ "tags": ["documentation", "guides", "api"]
469
+ },
470
+ "active": true
471
+ }
472
+ ```
473
+
474
+ ### Via Bootstrap Configuration
475
+
476
+ For automated deployments, include in your bootstrap configuration:
477
+
478
+ ```json
479
+ {
480
+ "modules": [
481
+ {
482
+ "name": "my-app-documentation",
483
+ "type": "documentation",
484
+ "displayName": "My App Documentation",
485
+ "description": "Complete documentation for My App",
486
+ "route": "/docs/my-app",
487
+ "application": "my-app",
488
+ "operations": ["my-app::documentation::access"],
489
+ "active": true
490
+ }
491
+ ]
492
+ }
493
+ ```
494
+
495
+ ---
496
+
497
+ ## Configuration Reference
498
+
499
+ ### Environment Variables
500
+
501
+ The base template supports configuration via environment variables:
502
+
503
+ | Variable | Description | Default | Example |
504
+ |----------|-------------|---------|---------|
505
+ | `SITE_TITLE` | Site title (browser tab and header) | - | `"My App Documentation"` |
506
+ | `SITE_DESCRIPTION` | Site description for SEO | - | `"Complete documentation..."` |
507
+ | `SITE_URL` | Full site URL for sitemap | - | `"https://docs.example.com"` |
508
+ | `SITE_LOGO` | Path to custom logo | - | `"./src/assets/logo.svg"` |
509
+ | `GITHUB_URL` | GitHub repository URL | - | `"https://github.com/org/repo"` |
510
+ | `NODE_ENV` | Environment mode | `production` | `development` or `production` |
511
+
512
+ **Example Usage in Dockerfile:**
513
+
514
+ ```dockerfile
515
+ ENV SITE_TITLE="My App Documentation"
516
+ ENV SITE_DESCRIPTION="Complete documentation for My App"
517
+ ENV SITE_URL="https://docs.myapp.com"
518
+ ENV GITHUB_URL="https://github.com/myorg/my-app"
519
+ ```
520
+
521
+ ### Config.json Schema
522
+
523
+ The `config.json` file provides comprehensive site configuration:
524
+
525
+ ```typescript
526
+ interface DocumentationConfig {
527
+ // Required
528
+ title: string;
529
+ description: string;
530
+ sidebar: SidebarItem[];
531
+
532
+ // Optional
533
+ logo?: {
534
+ src: string;
535
+ alt?: string;
536
+ replacesTitle?: boolean;
537
+ };
538
+ social?: {
539
+ github?: string;
540
+ twitter?: string;
541
+ discord?: string;
542
+ linkedin?: string;
543
+ };
544
+ editLink?: {
545
+ baseUrl: string;
546
+ };
547
+ head?: Array<{
548
+ tag: string;
549
+ attrs: Record<string, string | boolean | undefined>;
550
+ content?: string;
551
+ }>;
552
+ customCss?: string[];
553
+ components?: Record<string, string>;
554
+ locales?: Record<string, LocaleConfig>;
555
+ }
556
+
557
+ interface SidebarItem {
558
+ label: string;
559
+ link?: string;
560
+ items?: SidebarItem[];
561
+ autogenerate?: {
562
+ directory: string;
563
+ collapsed?: boolean;
564
+ };
565
+ collapsed?: boolean;
566
+ badge?: string | { text: string; variant: 'note' | 'danger' | 'success' | 'caution' };
567
+ }
568
+ ```
569
+
570
+ ### Sidebar Configuration Examples
571
+
572
+ <Tabs>
573
+ <TabItem label="Manual Structure">
574
+ ```json
575
+ {
576
+ "sidebar": [
577
+ {
578
+ "label": "Getting Started",
579
+ "items": [
580
+ { "label": "Introduction", "link": "/" },
581
+ { "label": "Installation", "link": "/getting-started/installation" },
582
+ { "label": "Quick Start", "link": "/getting-started/quick-start" }
583
+ ]
584
+ },
585
+ {
586
+ "label": "Guides",
587
+ "items": [
588
+ { "label": "Authentication", "link": "/guides/authentication" },
589
+ { "label": "Authorization", "link": "/guides/authorization" },
590
+ { "label": "Configuration", "link": "/guides/configuration" }
591
+ ]
592
+ }
593
+ ]
594
+ }
595
+ ```
596
+ </TabItem>
597
+
598
+ <TabItem label="Auto-generated">
599
+ ```json
600
+ {
601
+ "sidebar": [
602
+ {
603
+ "label": "Getting Started",
604
+ "link": "/"
605
+ },
606
+ {
607
+ "label": "Guides",
608
+ "autogenerate": {
609
+ "directory": "guides",
610
+ "collapsed": false
611
+ }
612
+ },
613
+ {
614
+ "label": "API Reference",
615
+ "autogenerate": {
616
+ "directory": "reference",
617
+ "collapsed": true
618
+ }
619
+ }
620
+ ]
621
+ }
622
+ ```
623
+
624
+ **Auto-generation:**
625
+ - Automatically generates sidebar items from files in the directory
626
+ - Respects file/folder structure
627
+ - Uses frontmatter `title` for labels
628
+ - Supports nesting based on folder hierarchy
629
+ </TabItem>
630
+
631
+ <TabItem label="With Badges">
632
+ ```json
633
+ {
634
+ "sidebar": [
635
+ {
636
+ "label": "Guides",
637
+ "items": [
638
+ {
639
+ "label": "Getting Started",
640
+ "link": "/guides/getting-started"
641
+ },
642
+ {
643
+ "label": "Advanced Features",
644
+ "link": "/guides/advanced",
645
+ "badge": "New"
646
+ },
647
+ {
648
+ "label": "Experimental API",
649
+ "link": "/guides/experimental",
650
+ "badge": {
651
+ "text": "Experimental",
652
+ "variant": "caution"
653
+ }
654
+ },
655
+ {
656
+ "label": "Deprecated Methods",
657
+ "link": "/guides/deprecated",
658
+ "badge": {
659
+ "text": "Deprecated",
660
+ "variant": "danger"
661
+ }
662
+ }
663
+ ]
664
+ }
665
+ ]
666
+ }
667
+ ```
668
+
669
+ **Badge Variants:**
670
+ - `note` (blue) - General information
671
+ - `success` (green) - New features
672
+ - `caution` (yellow) - Experimental/beta
673
+ - `danger` (red) - Deprecated/removed
674
+ </TabItem>
675
+
676
+ <TabItem label="Collapsible Sections">
677
+ ```json
678
+ {
679
+ "sidebar": [
680
+ {
681
+ "label": "Getting Started",
682
+ "collapsed": false,
683
+ "items": [
684
+ { "label": "Introduction", "link": "/" },
685
+ { "label": "Installation", "link": "/installation" }
686
+ ]
687
+ },
688
+ {
689
+ "label": "Advanced Topics",
690
+ "collapsed": true,
691
+ "items": [
692
+ { "label": "Performance", "link": "/advanced/performance" },
693
+ { "label": "Security", "link": "/advanced/security" }
694
+ ]
695
+ }
696
+ ]
697
+ }
698
+ ```
699
+
700
+ **Collapsed Sections:**
701
+ - `collapsed: false` - Section expanded by default
702
+ - `collapsed: true` - Section collapsed by default
703
+ - Users can expand/collapse sections interactively
704
+ </TabItem>
705
+ </Tabs>
706
+
707
+ ---
708
+
709
+ ## Advanced Customization
710
+
711
+ ### Custom Components
712
+
713
+ Add custom Astro or React components to enhance your documentation:
714
+
715
+ ```dockerfile
716
+ # In your Dockerfile
717
+ COPY ./components/ /app/src/components/
718
+ ```
719
+
720
+ **Example Custom Component:**
721
+
722
+ ```astro
723
+ ---
724
+ // src/components/ApiEndpoint.astro
725
+ interface Props {
726
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
727
+ path: string;
728
+ description: string;
729
+ }
730
+
731
+ const { method, path, description } = Astro.props;
732
+ ---
733
+
734
+ <div class="api-endpoint">
735
+ <div class="method method-{method.toLowerCase()}">{method}</div>
736
+ <code class="path">{path}</code>
737
+ <p class="description">{description}</p>
738
+ </div>
739
+
740
+ <style>
741
+ .api-endpoint {
742
+ display: flex;
743
+ align-items: center;
744
+ gap: 1rem;
745
+ padding: 1rem;
746
+ border: 1px solid var(--sl-color-gray-5);
747
+ border-radius: 0.5rem;
748
+ margin: 1rem 0;
749
+ }
750
+
751
+ .method {
752
+ padding: 0.25rem 0.5rem;
753
+ border-radius: 0.25rem;
754
+ font-weight: bold;
755
+ font-size: 0.875rem;
756
+ }
757
+
758
+ .method-get { background: #4CAF50; color: white; }
759
+ .method-post { background: #2196F3; color: white; }
760
+ .method-put { background: #FF9800; color: white; }
761
+ .method-delete { background: #F44336; color: white; }
762
+ </style>
763
+ ```
764
+
765
+ **Use in MDX:**
766
+
767
+ ```mdx
768
+ import ApiEndpoint from '~/components/ApiEndpoint.astro';
769
+
770
+ <ApiEndpoint
771
+ method="GET"
772
+ path="/api/users/:id"
773
+ description="Retrieve a user by ID"
774
+ />
775
+ ```
776
+
777
+ ### Custom CSS Styling
778
+
779
+ Customize the appearance with custom CSS:
780
+
781
+ ```dockerfile
782
+ # In your Dockerfile
783
+ COPY ./styles/ /app/src/styles/
784
+ ```
785
+
786
+ **Example Custom CSS:**
787
+
788
+ ```css
789
+ /* src/styles/custom.css */
790
+
791
+ /* Custom color scheme */
792
+ :root {
793
+ --sl-color-accent: #00a8ff;
794
+ --sl-color-accent-high: #0095e6;
795
+ --sl-color-text-accent: #00a8ff;
796
+ }
797
+
798
+ /* Custom font */
799
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
800
+
801
+ :root {
802
+ --sl-font: 'Inter', sans-serif;
803
+ }
804
+
805
+ /* Custom code block styling */
806
+ pre {
807
+ border-radius: 8px;
808
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
809
+ }
810
+
811
+ /* Custom card styling */
812
+ .sl-card {
813
+ border: 2px solid var(--sl-color-accent);
814
+ transition: transform 0.2s;
815
+ }
816
+
817
+ .sl-card:hover {
818
+ transform: translateY(-4px);
819
+ }
820
+ ```
821
+
822
+ **Reference in config.json:**
823
+
824
+ ```json
825
+ {
826
+ "customCss": [
827
+ "./src/styles/custom.css"
828
+ ]
829
+ }
830
+ ```
831
+
832
+ ### Advanced Astro Configuration
833
+
834
+ For complete control, override the Astro configuration:
835
+
836
+ ```dockerfile
837
+ # In your Dockerfile
838
+ COPY ./astro.config.mjs /app/astro.config.mjs
839
+ COPY ./package.json /app/package.json
840
+ RUN npm install
841
+ ```
842
+
843
+ **Example astro.config.mjs:**
844
+
845
+ ```javascript
846
+ import { defineConfig } from 'astro/config';
847
+ import starlight from '@astrojs/starlight';
848
+ import remarkMermaid from 'remark-mermaid';
849
+ import rehypeAutolinkHeadings from 'rehype-autolink-headings';
850
+
851
+ export default defineConfig({
852
+ integrations: [
853
+ starlight({
854
+ title: 'My App Documentation',
855
+ social: {
856
+ github: 'https://github.com/myorg/my-app',
857
+ },
858
+ sidebar: [
859
+ { label: 'Home', link: '/' },
860
+ { label: 'Guides', autogenerate: { directory: 'guides' } },
861
+ ],
862
+ customCss: ['./src/styles/custom.css'],
863
+ components: {
864
+ Head: './src/components/Head.astro',
865
+ Hero: './src/components/Hero.astro',
866
+ },
867
+ }),
868
+ ],
869
+ markdown: {
870
+ remarkPlugins: [remarkMermaid],
871
+ rehypePlugins: [rehypeAutolinkHeadings],
872
+ },
873
+ });
874
+ ```
875
+
876
+ <Aside type="caution">
877
+ Advanced configuration requires understanding Astro and Starlight. Start with environment variables and config.json before attempting custom Astro configuration.
878
+ </Aside>
879
+
880
+ ---
881
+
882
+ ## Platform Documentation Example
883
+
884
+ The Blue Alba Platform's own documentation is built using the same `pae-documentation-template`, demonstrating the feature in production.
885
+
886
+ ### Configuration
887
+
888
+ **Catalog Module:**
889
+ ```json
890
+ {
891
+ "name": "platform-documentation",
892
+ "type": "documentation",
893
+ "displayName": "Platform Documentation",
894
+ "description": "Complete Blue Alba Platform documentation",
895
+ "route": "/_/docs",
896
+ "application": "platform",
897
+ "operations": ["documentation::access"]
898
+ }
899
+ ```
900
+
901
+ **Access Control:**
902
+ - Operation: `documentation::access`
903
+ - Automatically assigned to administrators
904
+ - Can be granted to additional users via Admin UI
905
+
906
+ **Content Structure:**
907
+ ```
908
+ docs/
909
+ ├── index.mdx # Home page
910
+ ├── getting-started/
911
+ │ ├── installation.mdx
912
+ │ └── quick-start.mdx
913
+ ├── guides/
914
+ │ ├── identity-providers.mdx
915
+ │ ├── creating-services.mdx
916
+ │ ├── creating-ui-modules.mdx
917
+ │ └── adding-documentation-sites.mdx
918
+ ├── architecture/
919
+ │ ├── overview.mdx
920
+ │ ├── gateway.mdx
921
+ │ └── microservices.mdx
922
+ └── reference/
923
+ ├── api/
924
+ └── configuration/
925
+ ```
926
+
927
+ **Continuous Updates:**
928
+ The platform documentation is continuously updated as new features are released, serving as both:
929
+ - **Reference documentation** for platform users
930
+ - **Working example** of the documentation system's capabilities
931
+
932
+ ---
933
+
934
+ ## Best Practices
935
+
936
+ ### Content Organization
937
+
938
+ <CardGrid stagger>
939
+ <Card title="Logical Structure" icon="document">
940
+ Organize content into clear sections: Getting Started, Guides, API Reference, Architecture.
941
+ </Card>
942
+
943
+ <Card title="Progressive Disclosure" icon="forward">
944
+ Start with simple concepts, gradually introduce complexity. Use collapsible sections for advanced topics.
945
+ </Card>
946
+
947
+ <Card title="Consistent Naming" icon="setting">
948
+ Use consistent file naming: lowercase, hyphen-separated (e.g., `getting-started.mdx`, not `GettingStarted.mdx`).
949
+ </Card>
950
+
951
+ <Card title="Single Responsibility" icon="document">
952
+ One topic per page. Break large topics into multiple pages with clear navigation.
953
+ </Card>
954
+ </CardGrid>
955
+
956
+ ### Writing Style
957
+
958
+ **Clear and Concise:**
959
+ - Use simple language, avoid jargon
960
+ - Short paragraphs (3-4 sentences)
961
+ - Active voice over passive
962
+ - Present tense for current features
963
+
964
+ **Code Examples:**
965
+ - Always provide working code examples
966
+ - Include comments explaining key concepts
967
+ - Show complete examples, not just snippets
968
+ - Use syntax highlighting with language tags
969
+
970
+ **Visual Aids:**
971
+ - Use Mermaid diagrams for flows and architecture
972
+ - Include screenshots for UI-heavy topics
973
+ - Use tables for structured information
974
+ - Add callouts (Aside component) for important notes
975
+
976
+ ### Maintenance
977
+
978
+ **Keep Documentation Fresh:**
979
+ ```bash
980
+ # Update documentation alongside code changes
981
+ git checkout -b feature/new-api-endpoint
982
+ # ... make code changes ...
983
+ # ... update documentation ...
984
+ git add .
985
+ git commit -m "feat: add new API endpoint with documentation"
986
+ ```
987
+
988
+ **Version Documentation:**
989
+ - Use badges to mark new, experimental, or deprecated features
990
+ - Consider version-specific documentation for major changes
991
+ - Include changelog or release notes section
992
+
993
+ **Review Process:**
994
+ - Treat documentation like code (code review, testing)
995
+ - Check all links and code examples
996
+ - Verify consistency with actual implementation
997
+ - Test builds locally before deploying
998
+
999
+ ### Performance
1000
+
1001
+ **Optimize Images:**
1002
+ ```bash
1003
+ # Compress images before adding to documentation
1004
+ imagemagick convert logo.png -quality 85 logo-optimized.png
1005
+
1006
+ # Use appropriate formats
1007
+ # - SVG for logos and diagrams
1008
+ # - WebP for photos
1009
+ # - PNG for screenshots with text
1010
+ ```
1011
+
1012
+ **Lazy Load Heavy Content:**
1013
+ - Use code splitting for large examples
1014
+ - Lazy load images below the fold
1015
+ - Consider pagination for very long pages
1016
+
1017
+ ---
1018
+
1019
+ ## Troubleshooting
1020
+
1021
+ ### Common Issues and Solutions
1022
+
1023
+ <Tabs>
1024
+ <TabItem label="Build Failures">
1025
+ **Problem: Docker build fails with "Content not found"**
1026
+
1027
+ ```bash
1028
+ ERROR: Content directory not found: /app/src/content/docs/
1029
+ ```
1030
+
1031
+ **Solution:**
1032
+ Ensure your `COPY` commands in Dockerfile are correct:
1033
+
1034
+ ```dockerfile
1035
+ # Correct - relative to build context
1036
+ COPY ./docs/ /app/src/content/docs/
1037
+
1038
+ # Incorrect - absolute path won't work
1039
+ COPY /docs/ /app/src/content/docs/
1040
+ ```
1041
+
1042
+ ---
1043
+
1044
+ **Problem: Astro build fails during Docker build**
1045
+
1046
+ ```bash
1047
+ ERROR: Cannot find module '@astrojs/starlight'
1048
+ ```
1049
+
1050
+ **Solution:**
1051
+ Don't override `package.json` unless you know what you're doing. The base image has all dependencies. If you must override:
1052
+
1053
+ ```dockerfile
1054
+ COPY ./package.json /app/package.json
1055
+ RUN npm install # Ensure this runs after copying package.json
1056
+ ```
1057
+ </TabItem>
1058
+
1059
+ <TabItem label="Content Issues">
1060
+ **Problem: Sidebar not showing**
1061
+
1062
+ **Causes and Solutions:**
1063
+
1064
+ 1. **Invalid JSON in config.json:**
1065
+ ```bash
1066
+ # Validate JSON
1067
+ cat config.json | jq .
1068
+ ```
1069
+
1070
+ 2. **Missing files referenced in sidebar:**
1071
+ ```json
1072
+ // If you reference /guides/getting-started
1073
+ // The file must exist at docs/guides/getting-started.mdx
1074
+ ```
1075
+
1076
+ 3. **Incorrect autogenerate directory:**
1077
+ ```json
1078
+ {
1079
+ "sidebar": [
1080
+ {
1081
+ "label": "Guides",
1082
+ "autogenerate": {
1083
+ "directory": "guides" // Must match actual directory name
1084
+ }
1085
+ }
1086
+ ]
1087
+ }
1088
+ ```
1089
+
1090
+ ---
1091
+
1092
+ **Problem: Images not displaying**
1093
+
1094
+ **Solution:**
1095
+ Ensure images are copied and referenced correctly:
1096
+
1097
+ ```dockerfile
1098
+ # Copy assets
1099
+ COPY ./assets/ /app/src/assets
1100
+ ```
1101
+
1102
+ ```mdx
1103
+ <!-- In your MDX file -->
1104
+ ![My Image](/src/assets/my-image.png)
1105
+
1106
+ <!-- Or using import -->
1107
+ import myImage from '~/assets/my-image.png';
1108
+
1109
+ <img src={myImage.src} alt="My Image" />
1110
+ ```
1111
+ </TabItem>
1112
+
1113
+ <TabItem label="Navigation Issues">
1114
+ **Problem: Documentation link not appearing in platform**
1115
+
1116
+ **Checklist:**
1117
+ 1. **Module registered in catalog?**
1118
+ - Check Admin UI → Catalog → Modules
1119
+ - Verify type is set to `documentation`
1120
+
1121
+ 2. **Module associated with correct application?**
1122
+ - Verify `application` field matches your app
1123
+
1124
+ 3. **User has required operation?**
1125
+ - Check user's operations in Admin UI
1126
+ - Verify operation matches module's operations
1127
+
1128
+ 4. **Module is active?**
1129
+ - Check `active` field is `true` in catalog
1130
+
1131
+ **Debugging:**
1132
+ ```bash
1133
+ # Check catalog API
1134
+ curl -H "Authorization: Bearer $TOKEN" \
1135
+ https://your-platform.com/api/catalog/modules | jq '.[] | select(.type=="documentation")'
1136
+
1137
+ # Check user operations
1138
+ curl -H "Authorization: Bearer $TOKEN" \
1139
+ https://your-platform.com/api/users/me | jq '.operations'
1140
+ ```
1141
+
1142
+ ---
1143
+
1144
+ **Problem: Documentation link redirects to wrong URL**
1145
+
1146
+ **Solution:**
1147
+ Verify the `route` field in catalog module:
1148
+
1149
+ ```json
1150
+ {
1151
+ "route": "/docs/my-app" // Must match your deployment path
1152
+ }
1153
+ ```
1154
+
1155
+ And ensure your service is accessible at that path through the gateway.
1156
+ </TabItem>
1157
+
1158
+ <TabItem label="Access Control">
1159
+ **Problem: Users can't access documentation (403 Forbidden)**
1160
+
1161
+ **Causes and Solutions:**
1162
+
1163
+ 1. **Missing operation:**
1164
+ ```bash
1165
+ # Grant operation to user
1166
+ # Via Admin UI: Users → [User] → Operations → Add Operation
1167
+
1168
+ # Via API:
1169
+ POST /api/users/{userId}/operations
1170
+ { "operation": "my-app::documentation::access" }
1171
+ ```
1172
+
1173
+ 2. **Operation mismatch:**
1174
+ ```json
1175
+ // Ensure module operation matches what users have
1176
+ {
1177
+ "operations": ["my-app::documentation::access"] // Must match exactly
1178
+ }
1179
+ ```
1180
+
1181
+ 3. **Module not active:**
1182
+ ```json
1183
+ {
1184
+ "active": true // Must be true
1185
+ }
1186
+ ```
1187
+
1188
+ ---
1189
+
1190
+ **Problem: Everyone can access documentation (should be restricted)**
1191
+
1192
+ **Solution:**
1193
+ Add operations to the module:
1194
+
1195
+ ```json
1196
+ {
1197
+ "operations": ["my-app::documentation::access"]
1198
+ }
1199
+ ```
1200
+
1201
+ Without operations, documentation is public to all application users.
1202
+ </TabItem>
1203
+
1204
+ <TabItem label="Performance">
1205
+ **Problem: Documentation site loads slowly**
1206
+
1207
+ **Solutions:**
1208
+
1209
+ 1. **Optimize images:**
1210
+ ```bash
1211
+ # Compress images
1212
+ npm install -g sharp-cli
1213
+ sharp -i input.jpg -o output.jpg -q 80
1214
+ ```
1215
+
1216
+ 2. **Enable caching:**
1217
+ ```nginx
1218
+ # If using custom nginx config
1219
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
1220
+ expires 1y;
1221
+ add_header Cache-Control "public, immutable";
1222
+ }
1223
+ ```
1224
+
1225
+ 3. **Reduce page size:**
1226
+ - Split large pages into smaller ones
1227
+ - Use code splitting
1228
+ - Lazy load images
1229
+
1230
+ 4. **Check network:**
1231
+ ```bash
1232
+ # Test documentation response time
1233
+ curl -w "@curl-format.txt" -o /dev/null -s https://your-platform.com/docs/my-app
1234
+ ```
1235
+
1236
+ </TabItem>
1237
+ </Tabs>
1238
+
1239
+ ### Health Check
1240
+
1241
+ The documentation container includes a health check endpoint:
1242
+
1243
+ ```bash
1244
+ # Check if documentation service is healthy
1245
+ curl http://localhost:8080/health
1246
+
1247
+ # Expected response:
1248
+ {
1249
+ "status": "healthy",
1250
+ "timestamp": "2024-01-09T10:30:00Z"
1251
+ }
1252
+ ```
1253
+
1254
+ ### Debug Mode
1255
+
1256
+ Enable debug logging for troubleshooting:
1257
+
1258
+ ```dockerfile
1259
+ ENV NODE_ENV=development
1260
+ ENV DEBUG=*
1261
+ ```
1262
+
1263
+ Or at runtime:
1264
+
1265
+ ```bash
1266
+ docker run -e NODE_ENV=development -e DEBUG=* -p 8080:80 my-app-documentation
1267
+ ```
1268
+
1269
+ ---
1270
+
1271
+ ## Deployment Considerations
1272
+
1273
+ ### Container Resources
1274
+
1275
+ Set appropriate resource limits:
1276
+
1277
+ ```yaml
1278
+ # docker-compose.yml
1279
+ services:
1280
+ my-app-documentation:
1281
+ image: my-app-documentation:latest
1282
+ deploy:
1283
+ resources:
1284
+ limits:
1285
+ cpus: '0.5'
1286
+ memory: 256M
1287
+ reservations:
1288
+ cpus: '0.25'
1289
+ memory: 128M
1290
+ ```
1291
+
1292
+ ### High Availability
1293
+
1294
+ For production deployments:
1295
+
1296
+ ```yaml
1297
+ services:
1298
+ my-app-documentation:
1299
+ image: my-app-documentation:latest
1300
+ deploy:
1301
+ replicas: 2
1302
+ update_config:
1303
+ parallelism: 1
1304
+ delay: 10s
1305
+ restart_policy:
1306
+ condition: on-failure
1307
+ delay: 5s
1308
+ max_attempts: 3
1309
+ ```
1310
+
1311
+ ### Monitoring
1312
+
1313
+ Monitor documentation health:
1314
+
1315
+ ```yaml
1316
+ services:
1317
+ my-app-documentation:
1318
+ healthcheck:
1319
+ test: ["CMD", "curl", "-f", "http://localhost:80/health"]
1320
+ interval: 30s
1321
+ timeout: 10s
1322
+ retries: 3
1323
+ start_period: 40s
1324
+ ```
1325
+
1326
+ ---
1327
+
1328
+ ## Related Documentation
1329
+
1330
+ - **[Creating Services](./creating-services)** - Learn to create backend services
1331
+ - **[Creating UI Modules](./creating-ui-modules)** - Build React micro-frontends
1332
+ - **[Identity Providers](./identity-providers)** - Configure authentication
1333
+ - **[Using Mermaid Diagrams](./mermaid-diagrams)** - Create interactive diagrams
1334
+
1335
+ ---
1336
+
1337
+ ## Support and Resources
1338
+
1339
+ **Starlight Documentation:**
1340
+ - [Starlight Official Docs](https://starlight.astro.build/)
1341
+ - [Astro Documentation](https://docs.astro.build/)
1342
+
1343
+ **Platform Resources:**
1344
+ - Platform Documentation (this site) for reference examples
1345
+ - Admin UI for catalog management
1346
+ - Gateway API for programmatic access
1347
+
1348
+ **Getting Help:**
1349
+ 1. Check this guide and platform documentation
1350
+ 2. Review example implementations (platform docs, other services)
1351
+ 3. Inspect container logs for detailed error messages
1352
+ 4. Test locally before deploying to production
1353
+
1354
+ ---
1355
+
1356
+ ## Summary
1357
+
1358
+ You've learned how to create and deploy documentation sites on the Blue Alba Platform:
1359
+
1360
+ ✅ **Understanding** - Documentation architecture and integration
1361
+ ✅ **Creating** - Dockerfile, content, and configuration
1362
+ ✅ **Deploying** - Building, registering, and deploying
1363
+ ✅ **Integrating** - Automatic navigation and access control
1364
+ ✅ **Customizing** - Advanced configuration and styling
1365
+ ✅ **Troubleshooting** - Common issues and solutions
1366
+
1367
+ Start by creating a simple documentation site with a few pages, then expand with more content, custom components, and advanced features as needed.