@friggframework/devtools 2.0.0--canary.546.74db90f.0 → 2.0.0--canary.545.e7becd9.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 (128) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +326 -0
  3. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +337 -0
  4. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +373 -0
  5. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +313 -0
  6. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +269 -0
  7. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +82 -0
  8. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +408 -0
  9. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +583 -0
  10. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +314 -0
  11. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +383 -0
  12. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  13. package/frigg-cli/__tests__/unit/commands/doctor.test.js +0 -2
  14. package/frigg-cli/__tests__/unit/commands/init.test.js +406 -0
  15. package/frigg-cli/__tests__/unit/commands/install.test.js +23 -19
  16. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +383 -0
  17. package/frigg-cli/__tests__/unit/commands/repair.test.js +275 -0
  18. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  19. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +411 -0
  20. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +405 -0
  21. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +496 -0
  22. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +474 -0
  23. package/frigg-cli/__tests__/unit/utils/output.test.js +196 -0
  24. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +93 -0
  25. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +93 -0
  26. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +103 -0
  27. package/frigg-cli/build-command/index.js +123 -11
  28. package/frigg-cli/container.js +172 -0
  29. package/frigg-cli/deploy-command/index.js +83 -1
  30. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +286 -0
  31. package/frigg-cli/doctor-command/index.js +37 -16
  32. package/frigg-cli/domain/entities/ApiModule.js +272 -0
  33. package/frigg-cli/domain/entities/AppDefinition.js +227 -0
  34. package/frigg-cli/domain/entities/Integration.js +198 -0
  35. package/frigg-cli/domain/exceptions/DomainException.js +24 -0
  36. package/frigg-cli/domain/ports/IApiModuleRepository.js +53 -0
  37. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +43 -0
  38. package/frigg-cli/domain/ports/IIntegrationRepository.js +61 -0
  39. package/frigg-cli/domain/services/IntegrationValidator.js +185 -0
  40. package/frigg-cli/domain/value-objects/IntegrationId.js +42 -0
  41. package/frigg-cli/domain/value-objects/IntegrationName.js +60 -0
  42. package/frigg-cli/domain/value-objects/SemanticVersion.js +70 -0
  43. package/frigg-cli/generate-iam-command.js +21 -1
  44. package/frigg-cli/index.js +21 -6
  45. package/frigg-cli/index.test.js +7 -2
  46. package/frigg-cli/infrastructure/UnitOfWork.js +46 -0
  47. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +197 -0
  48. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +224 -0
  49. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +249 -0
  50. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +92 -0
  51. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +373 -0
  52. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +116 -0
  53. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +277 -0
  54. package/frigg-cli/init-command/backend-first-handler.js +124 -42
  55. package/frigg-cli/init-command/index.js +2 -1
  56. package/frigg-cli/init-command/template-handler.js +13 -3
  57. package/frigg-cli/install-command/backend-js.js +3 -3
  58. package/frigg-cli/install-command/environment-variables.js +16 -19
  59. package/frigg-cli/install-command/environment-variables.test.js +12 -13
  60. package/frigg-cli/install-command/index.js +14 -9
  61. package/frigg-cli/install-command/integration-file.js +3 -3
  62. package/frigg-cli/install-command/validate-package.js +5 -9
  63. package/frigg-cli/jest.config.js +4 -1
  64. package/frigg-cli/package-lock.json +16226 -0
  65. package/frigg-cli/repair-command/index.js +121 -128
  66. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +376 -0
  67. package/frigg-cli/start-command/index.js +324 -2
  68. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +591 -0
  69. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +306 -0
  70. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +329 -0
  71. package/frigg-cli/templates/backend/.env.example +62 -0
  72. package/frigg-cli/templates/backend/.eslintrc.json +12 -0
  73. package/frigg-cli/templates/backend/.prettierrc +6 -0
  74. package/frigg-cli/templates/backend/docker-compose.yml +22 -0
  75. package/frigg-cli/templates/backend/index.js +96 -0
  76. package/frigg-cli/templates/backend/infrastructure.js +12 -0
  77. package/frigg-cli/templates/backend/jest.config.js +17 -0
  78. package/frigg-cli/templates/backend/package.json +50 -0
  79. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +10 -0
  80. package/frigg-cli/templates/backend/src/base/.gitkeep +7 -0
  81. package/frigg-cli/templates/backend/src/integrations/.gitkeep +10 -0
  82. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +65 -0
  83. package/frigg-cli/templates/backend/src/utils/.gitkeep +7 -0
  84. package/frigg-cli/templates/backend/test/setup.js +30 -0
  85. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  86. package/frigg-cli/templates/backend/ui-extensions/README.md +77 -0
  87. package/frigg-cli/ui-command/index.js +58 -36
  88. package/frigg-cli/utils/__tests__/provider-helper.test.js +55 -0
  89. package/frigg-cli/utils/__tests__/repo-detection.test.js +436 -0
  90. package/frigg-cli/utils/output.js +382 -0
  91. package/frigg-cli/utils/provider-helper.js +75 -0
  92. package/frigg-cli/utils/repo-detection.js +85 -37
  93. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +205 -0
  94. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +104 -0
  95. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +153 -0
  96. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +162 -0
  97. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +152 -0
  98. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +332 -0
  99. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +191 -0
  100. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +146 -0
  101. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +155 -0
  102. package/frigg-cli/validate-command/adapters/cli/validate-command.js +199 -0
  103. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +35 -0
  104. package/frigg-cli/validate-command/domain/entities/validation-result.js +74 -0
  105. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +74 -0
  106. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +68 -0
  107. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +181 -0
  108. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +128 -0
  109. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +113 -0
  110. package/infrastructure/create-frigg-infrastructure.js +93 -0
  111. package/infrastructure/docs/iam-policy-templates.md +1 -1
  112. package/infrastructure/domains/admin-scripts/admin-script-builder.js +200 -0
  113. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +499 -0
  114. package/infrastructure/domains/admin-scripts/index.js +5 -0
  115. package/infrastructure/domains/networking/vpc-builder.test.js +2 -4
  116. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  117. package/infrastructure/domains/shared/cloudformation-discovery.test.js +4 -7
  118. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  119. package/infrastructure/domains/shared/types/app-definition.js +21 -0
  120. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  121. package/infrastructure/domains/shared/utilities/base-definition-factory.js +10 -1
  122. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  123. package/infrastructure/infrastructure-composer.js +2 -0
  124. package/infrastructure/infrastructure-composer.test.js +2 -2
  125. package/infrastructure/jest.config.js +16 -0
  126. package/management-ui/README.md +245 -109
  127. package/package.json +8 -7
  128. package/frigg-cli/install-command/logger.js +0 -12
@@ -0,0 +1,5 @@
1
+ const { AdminScriptBuilder } = require('./admin-script-builder');
2
+
3
+ module.exports = {
4
+ AdminScriptBuilder
5
+ };
@@ -1500,10 +1500,9 @@ describe('VpcBuilder', () => {
1500
1500
  }
1501
1501
  };
1502
1502
 
1503
- // Discovery results matching ACTUAL Frontify production stack
1504
1503
  const discoveredResources = {
1505
1504
  fromCloudFormationStack: true,
1506
- stackName: 'create-frigg-app-production',
1505
+ stackName: 'frigg-app-production',
1507
1506
  existingLogicalIds: [
1508
1507
  'FriggLambdaRouteTable',
1509
1508
  'FriggNATRoute', // OLD naming
@@ -1566,10 +1565,9 @@ describe('VpcBuilder', () => {
1566
1565
  });
1567
1566
 
1568
1567
  it('should convert OLD logical IDs to structured discovery stackManaged array', () => {
1569
- // TDD test: Verify that VPCEndpointS3 in existingLogicalIds gets added to stackManaged
1570
1568
  const flatDiscovery = {
1571
1569
  fromCloudFormationStack: true,
1572
- stackName: 'create-frigg-app-production',
1570
+ stackName: 'frigg-app-production',
1573
1571
  existingLogicalIds: [
1574
1572
  'VPCEndpointS3', // OLD naming
1575
1573
  'VPCEndpointDynamoDB', // OLD naming
@@ -746,7 +746,7 @@ describe('VpcResourceResolver', () => {
746
746
  ],
747
747
  external: [],
748
748
  fromCloudFormation: true,
749
- stackName: 'create-frigg-app-production'
749
+ stackName: 'frigg-app-production'
750
750
  };
751
751
 
752
752
  const decisions = resolver.resolveAll(appDefinition, discovery);
@@ -589,10 +589,8 @@ describe('CloudFormationDiscovery', () => {
589
589
 
590
590
  describe('External VPC with routing infrastructure pattern', () => {
591
591
  it('should discover routing resources when VPC is external', async () => {
592
- // This tests the external VPC pattern: external VPC/subnets/KMS,
593
- // but stack creates routing infrastructure (route table, NAT route, VPC endpoints)
594
592
  const mockStack = {
595
- StackName: 'create-frigg-app-production',
593
+ StackName: 'frigg-app-production',
596
594
  Outputs: [],
597
595
  };
598
596
 
@@ -638,7 +636,7 @@ describe('CloudFormationDiscovery', () => {
638
636
  mockProvider.describeStack.mockResolvedValue(mockStack);
639
637
  mockProvider.listStackResources.mockResolvedValue(mockResources);
640
638
 
641
- const result = await cfDiscovery.discoverFromStack('create-frigg-app-production');
639
+ const result = await cfDiscovery.discoverFromStack('frigg-app-production');
642
640
 
643
641
  // Verify routing infrastructure was discovered
644
642
  expect(result.routeTableId).toBe('rtb-0b83aca77ccde20a6');
@@ -807,9 +805,8 @@ describe('CloudFormationDiscovery', () => {
807
805
 
808
806
  describe('existingLogicalIds tracking', () => {
809
807
  it('should track OLD VPC endpoint logical IDs (VPCEndpointS3 pattern) for backwards compatibility', async () => {
810
- // CRITICAL: Frontify production uses OLD naming convention
811
808
  const mockStack = {
812
- StackName: 'create-frigg-app-production',
809
+ StackName: 'frigg-app-production',
813
810
  Outputs: []
814
811
  };
815
812
 
@@ -825,7 +822,7 @@ describe('CloudFormationDiscovery', () => {
825
822
  mockProvider.describeStack.mockResolvedValue(mockStack);
826
823
  mockProvider.listStackResources.mockResolvedValue(mockResources);
827
824
 
828
- const result = await cfDiscovery.discoverFromStack('create-frigg-app-production');
825
+ const result = await cfDiscovery.discoverFromStack('frigg-app-production');
829
826
 
830
827
  // CRITICAL: existingLogicalIds MUST contain old VPC endpoint names
831
828
  expect(result.existingLogicalIds).toBeDefined();
@@ -88,8 +88,8 @@ async function gatherDiscoveredResources(appDefinition) {
88
88
 
89
89
  // Build discovery configuration
90
90
  const stage = process.env.SLS_STAGE || 'dev';
91
- const stackName = `${appDefinition.name || 'create-frigg-app'}-${stage}`;
92
- const serviceName = appDefinition.name || 'create-frigg-app';
91
+ const stackName = `${appDefinition.name || 'frigg-app'}-${stage}`;
92
+ const serviceName = appDefinition.name || 'frigg-app';
93
93
 
94
94
  // Try CloudFormation-first discovery
95
95
  const cfDiscovery = new CloudFormationDiscovery(provider, { serviceName, stage });
@@ -135,9 +135,9 @@ async function gatherDiscoveredResources(appDefinition) {
135
135
  // KMS keys CAN be shared across stages (encryption keys are safe to reuse)
136
136
  const kmsDiscovery = new KmsDiscovery(provider);
137
137
  const kmsConfig = {
138
- serviceName: appDefinition.name || 'create-frigg-app',
138
+ serviceName: appDefinition.name || 'frigg-app',
139
139
  stage,
140
- keyAlias: `alias/${appDefinition.name || 'create-frigg-app'}-${stage}-frigg-kms`,
140
+ keyAlias: `alias/${appDefinition.name || 'frigg-app'}-${stage}-frigg-kms`,
141
141
  };
142
142
  const kmsResult = await kmsDiscovery.discover(kmsConfig);
143
143
 
@@ -166,7 +166,7 @@ async function gatherDiscoveredResources(appDefinition) {
166
166
  const ssmDiscovery = new SsmDiscovery(provider);
167
167
 
168
168
  const config = {
169
- serviceName: appDefinition.name || 'create-frigg-app',
169
+ serviceName: appDefinition.name || 'frigg-app',
170
170
  stage,
171
171
  vpcId: appDefinition.vpc?.vpcId,
172
172
  databaseId: appDefinition.database?.postgres?.clusterId ||
@@ -106,6 +106,25 @@
106
106
  * @property {string} Definition.name - Integration name
107
107
  */
108
108
 
109
+ /**
110
+ * Admin script definition
111
+ * @typedef {Object} AdminScriptDefinition
112
+ * @property {Object} Definition - Static definition from script class
113
+ * @property {string} Definition.name - Script name identifier
114
+ * @property {string} Definition.version - Script version (semver)
115
+ * @property {string} [Definition.description] - Human-readable description
116
+ * @property {Object} [Definition.schedule] - Schedule configuration
117
+ * @property {boolean} [Definition.schedule.enabled] - Whether scheduling is enabled
118
+ * @property {string} [Definition.schedule.cronExpression] - Cron expression
119
+ */
120
+
121
+ /**
122
+ * Admin configuration
123
+ * @typedef {Object} AdminConfig
124
+ * @property {boolean} [includeBuiltinScripts] - Whether to include built-in scripts
125
+ * @property {boolean} [enableScheduling] - Whether to enable EventBridge scheduling
126
+ */
127
+
109
128
  /**
110
129
  * Complete application definition
111
130
  * @typedef {Object} AppDefinition
@@ -122,6 +141,8 @@
122
141
  * @property {MigrationDefinition} [migrations] - Database migration configuration
123
142
  * @property {WebsocketDefinition} [websockets] - WebSocket API configuration
124
143
  * @property {IntegrationDefinition[]} [integrations] - Integration definitions
144
+ * @property {AdminScriptDefinition[]} [adminScripts] - Admin script definitions
145
+ * @property {AdminConfig} [admin] - Admin configuration
125
146
  *
126
147
  * @property {Object} [environment] - Environment variables
127
148
  */
@@ -219,7 +219,7 @@ describe('Discovery Result Utilities', () => {
219
219
  ],
220
220
  external: [],
221
221
  fromCloudFormation: true,
222
- stackName: 'create-frigg-app-production'
222
+ stackName: 'frigg-app-production'
223
223
  };
224
224
 
225
225
  expect(discovery.fromCloudFormation).toBe(true);
@@ -165,7 +165,7 @@ function createBaseDefinition(
165
165
 
166
166
  return {
167
167
  frameworkVersion: '>=3.17.0',
168
- service: AppDefinition.name || 'create-frigg-app',
168
+ service: AppDefinition.name || 'frigg-app',
169
169
  package: {
170
170
  individually: true,
171
171
  },
@@ -311,6 +311,15 @@ function createBaseDefinition(
311
311
  { httpApi: { path: '/health/{proxy+}', method: 'GET' } },
312
312
  ],
313
313
  },
314
+ docs: {
315
+ handler: 'node_modules/@friggframework/core/handlers/routers/docs.handler',
316
+ skipEsbuild: true,
317
+ package: skipEsbuildPackageConfig,
318
+ events: [
319
+ { httpApi: { path: '/api/docs', method: 'GET' } },
320
+ { httpApi: { path: '/api/openapi.json', method: 'GET' } },
321
+ ],
322
+ },
314
323
  // Note: dbMigrate removed - MigrationBuilder now handles migration infrastructure
315
324
  // See: packages/devtools/infrastructure/domains/database/migration-builder.js
316
325
  },
@@ -30,10 +30,10 @@ describe('Base Definition Factory', () => {
30
30
  expect(result.provider.stage).toBe('${opt:stage}');
31
31
  });
32
32
 
33
- it('should default service name to create-frigg-app', () => {
33
+ it('should default service name to frigg-app', () => {
34
34
  const result = createBaseDefinition({}, {}, {});
35
35
 
36
- expect(result.service).toBe('create-frigg-app');
36
+ expect(result.service).toBe('frigg-app');
37
37
  });
38
38
 
39
39
  it('should use custom provider if specified', () => {
@@ -17,6 +17,7 @@ const { SsmBuilder } = require('./domains/parameters/ssm-builder');
17
17
  const { WebsocketBuilder } = require('./domains/integration/websocket-builder');
18
18
  const { IntegrationBuilder } = require('./domains/integration/integration-builder');
19
19
  const { SchedulerBuilder } = require('./domains/scheduler/scheduler-builder');
20
+ const { AdminScriptBuilder } = require('./domains/admin-scripts/admin-script-builder');
20
21
 
21
22
  // Utilities
22
23
  const { modifyHandlerPaths } = require('./domains/shared/utilities/handler-path-resolver');
@@ -53,6 +54,7 @@ const composeServerlessDefinition = async (AppDefinition) => {
53
54
  new WebsocketBuilder(),
54
55
  new IntegrationBuilder(),
55
56
  new SchedulerBuilder(), // Add scheduler after IntegrationBuilder (depends on it)
57
+ new AdminScriptBuilder(),
56
58
  ]);
57
59
 
58
60
  // Build all infrastructure (orchestrator handles validation, dependencies, parallel execution)
@@ -157,7 +157,7 @@ describe('composeServerlessDefinition', () => {
157
157
 
158
158
  const result = await composeServerlessDefinition(appDefinition);
159
159
 
160
- expect(result.service).toBe('create-frigg-app');
160
+ expect(result.service).toBe('frigg-app');
161
161
  });
162
162
 
163
163
  it('should use custom provider when specified', async () => {
@@ -1859,7 +1859,7 @@ describe('composeServerlessDefinition', () => {
1859
1859
 
1860
1860
  await expect(composeServerlessDefinition(appDefinition)).resolves.not.toThrow();
1861
1861
  const result = await composeServerlessDefinition(appDefinition);
1862
- expect(result.service).toBe('create-frigg-app');
1862
+ expect(result.service).toBe('frigg-app');
1863
1863
  });
1864
1864
 
1865
1865
  it('should handle null/undefined integrations', async () => {
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ displayName: 'Infrastructure',
3
+ rootDir: __dirname,
4
+ testMatch: [
5
+ '<rootDir>/**/*.test.js',
6
+ '<rootDir>/**/*.spec.js',
7
+ ],
8
+ testPathIgnorePatterns: [
9
+ '/node_modules/',
10
+ '/__tests__/fixtures/',
11
+ '/__tests__/helpers/',
12
+ ],
13
+ testEnvironment: 'node',
14
+ testTimeout: 10000,
15
+ transform: {},
16
+ };
@@ -1,17 +1,24 @@
1
1
  # Frigg Management UI
2
2
 
3
- A modern React-based management interface for Frigg development environment. Built with Vite, React, and Tailwind CSS, this application provides developers with a comprehensive dashboard to manage integrations, users, connections, and environment variables.
3
+ A modern React-based **developer tool** for managing local Frigg projects. Built with Vite, React, and Tailwind CSS following DDD/Hexagonal architecture principles.
4
+
5
+ ## Purpose
6
+
7
+ The Management UI is a **local development tool** for Frigg framework developers to:
8
+ - Manage Frigg project lifecycle (start/stop/inspect)
9
+ - Perform git operations (branch management, sync)
10
+ - Test integrations using `@friggframework/ui` in a sandboxed environment
11
+
12
+ **NOT for runtime integration management** - that's handled by `@friggframework/ui` in deployed applications.
4
13
 
5
14
  ## Features
6
15
 
7
- - **Dashboard**: Server control, metrics, and activity monitoring
8
- - **Integration Discovery**: Browse, install, and manage Frigg integrations
9
- - **Environment Management**: Configure environment variables and settings
10
- - **User Management**: Create and manage test users
11
- - **Connection Management**: Monitor and manage integration connections
12
- - **Real-time Updates**: WebSocket-based live updates
16
+ - **Project Management**: Discover, initialize, start/stop local Frigg projects
17
+ - **Git Operations**: Branch management, repository status, sync operations
18
+ - **Test Area**: Sandboxed environment using `@friggframework/ui` for integration testing
19
+ - **Real-time Updates**: WebSocket-based live updates for process status
13
20
  - **Responsive Design**: Mobile-friendly interface
14
- - **Error Boundaries**: Robust error handling
21
+ - **DDD Architecture**: Clean separation of concerns with hexagonal architecture
15
22
 
16
23
  ## Tech Stack
17
24
 
@@ -28,111 +35,153 @@ A modern React-based management interface for Frigg development environment. Bui
28
35
 
29
36
  ### Prerequisites
30
37
 
31
- - Node.js 16+ and npm
32
- - Running Frigg backend server
38
+ - Node.js 18+ and npm
39
+ - A Frigg project directory to manage
40
+
41
+ ### Quick Start
42
+
43
+ ```bash
44
+ # From any Frigg project directory
45
+ frigg ui
46
+
47
+ # Or install and run globally
48
+ npm install -g @friggframework/devtools
49
+ frigg ui
50
+ ```
33
51
 
34
- ### Installation
52
+ ### Development
35
53
 
36
54
  ```bash
37
55
  # Install dependencies
38
56
  npm install
39
57
 
40
- # Start development server (frontend only)
41
- npm run dev
42
-
43
- # Start both frontend and backend
58
+ # Start development server (frontend + backend)
44
59
  npm run dev:server
45
60
 
46
- # Build for production
47
- npm run build
61
+ # Frontend only
62
+ npm run dev
63
+
64
+ # Backend only
65
+ npm run server:dev
48
66
  ```
49
67
 
50
68
  ### Available Scripts
51
69
 
52
- - `npm run dev` - Start Vite development server
70
+ - `npm run dev` - Start Vite development server (port 5173)
53
71
  - `npm run dev:server` - Start both frontend and backend concurrently
54
72
  - `npm run build` - Build for production
55
73
  - `npm run preview` - Preview production build
56
- - `npm run server` - Start backend server only
74
+ - `npm run server` - Start backend server (port 3210)
57
75
  - `npm run server:dev` - Start backend server with nodemon
58
76
  - `npm run lint` - Run ESLint
59
77
  - `npm run lint:fix` - Fix ESLint issues
60
- - `npm run typecheck` - Run TypeScript type checking
78
+ - `npm run test` - Run Jest tests
61
79
 
62
- ## Project Structure
80
+ ## Architecture
63
81
 
64
- ```
65
- src/
66
- ├── components/ # Reusable UI components
67
- │ ├── Button.jsx # Custom button component
68
- │ ├── Card.jsx # Card container components
69
- │ ├── ErrorBoundary.jsx
70
- │ ├── IntegrationCard.jsx
71
- │ ├── Layout.jsx # Main layout component
72
- │ ├── LoadingSpinner.jsx
73
- │ ├── StatusBadge.jsx
74
- │ └── index.js # Component exports
75
- ├── hooks/ # React hooks
76
- │ ├── useFrigg.jsx # Main Frigg state management
77
- │ └── useSocket.jsx # WebSocket connection
78
- ├── pages/ # Page components
79
- │ ├── Dashboard.jsx # Main dashboard
80
- │ ├── Integrations.jsx
81
- │ ├── Environment.jsx
82
- │ ├── Users.jsx
83
- │ └── Connections.jsx
84
- ├── services/ # API services
85
- │ └── api.js # Axios configuration
86
- ├── utils/ # Utility functions
87
- │ └── cn.js # Class name utility
88
- ├── App.jsx # Root component
89
- ├── main.jsx # Application entry point
90
- └── index.css # Global styles
91
-
92
- server/
93
- ├── api/ # Backend API routes
94
- ├── middleware/ # Express middleware
95
- ├── utils/ # Server utilities
96
- ├── websocket/ # WebSocket handlers
97
- └── index.js # Server entry point
98
- ```
99
-
100
- ## Component Architecture
101
-
102
- ### Layout Components
103
- - **Layout**: Main application layout with responsive sidebar
104
- - **ErrorBoundary**: Catches and displays errors gracefully
105
-
106
- ### UI Components
107
- - **Button**: Customizable button with variants and sizes
108
- - **Card**: Container components for content sections
109
- - **StatusBadge**: Displays server status with color coding
110
- - **LoadingSpinner**: Loading indicators
111
- - **IntegrationCard**: Rich integration display component
112
-
113
- ### State Management
114
- - **useFrigg**: Central state management for Frigg data
115
- - **useSocket**: WebSocket connection and real-time updates
116
-
117
- ## API Integration
82
+ ### DDD/Hexagonal Architecture (Clean Architecture)
118
83
 
119
- The management UI communicates with the Frigg backend through:
84
+ The Management UI follows Domain-Driven Design principles with clear separation of concerns:
120
85
 
121
- 1. **REST API**: Standard CRUD operations
122
- 2. **WebSocket**: Real-time updates and notifications
123
-
124
- ### API Endpoints
86
+ ```
87
+ server/src/
88
+ ├── presentation/ # Routes & Controllers (HTTP adapters)
89
+ │ ├── routes/
90
+ │ │ ├── projectRoutes.js # Project management endpoints
91
+ │ │ ├── gitRoutes.js # Git operation endpoints
92
+ │ │ └── testAreaRoutes.js # Test area endpoints
93
+ │ └── controllers/
94
+ │ ├── ProjectController.js
95
+ │ └── GitController.js
96
+ ├── application/ # Use Cases & Services (Business logic)
97
+ │ ├── use-cases/
98
+ │ │ ├── StartProjectUseCase.js
99
+ │ │ ├── StopProjectUseCase.js
100
+ │ │ ├── InspectProjectUseCase.js
101
+ │ │ └── git/
102
+ │ │ ├── CreateBranchUseCase.js
103
+ │ │ ├── SwitchBranchUseCase.js
104
+ │ │ └── SyncBranchUseCase.js
105
+ │ └── services/
106
+ │ ├── ProjectService.js
107
+ │ └── GitService.js
108
+ ├── domain/ # Domain Entities & Services
109
+ │ ├── entities/
110
+ │ │ ├── Project.js
111
+ │ │ └── AppDefinition.js
112
+ │ └── services/
113
+ │ ├── ProcessManager.js
114
+ │ └── GitService.js
115
+ └── infrastructure/ # Repositories & Adapters
116
+ ├── repositories/
117
+ │ └── FileSystemProjectRepository.js
118
+ ├── adapters/
119
+ │ ├── FriggCliAdapter.js
120
+ │ └── GitAdapter.js
121
+ └── persistence/
122
+ └── SimpleGitAdapter.js
123
+
124
+ src/ # Frontend (React)
125
+ ├── presentation/ # UI Layer
126
+ │ ├── components/
127
+ │ │ ├── common/ # Shared UI components
128
+ │ │ ├── admin/ # Admin view components
129
+ │ │ └── zones/ # Zone-based organization
130
+ │ ├── pages/
131
+ │ └── hooks/
132
+ ├── application/ # Frontend use cases
133
+ ├── domain/ # Frontend domain models
134
+ └── infrastructure/ # API clients
135
+ ```
125
136
 
126
- - `GET /api/frigg/status` - Server status
127
- - `POST /api/frigg/start` - Start Frigg server
128
- - `POST /api/frigg/stop` - Stop Frigg server
129
- - `GET /api/integrations` - List integrations
130
- - `POST /api/integrations/install` - Install integration
131
- - `GET /api/environment` - Environment variables
132
- - `PUT /api/environment` - Update environment variables
133
- - `GET /api/users` - List test users
134
- - `POST /api/users` - Create test user
135
- - `GET /api/connections` - List connections
137
+ ## Core Functionality
138
+
139
+ ### 1. Project Management
140
+ - **Discover Projects**: Automatically find Frigg projects in your workspace
141
+ - **Initialize**: Set up new Frigg projects
142
+ - **Start/Stop**: Manage local Frigg process lifecycle
143
+ - **Inspect**: Deep project analysis (structure, config, dependencies)
144
+
145
+ ### 2. Git Operations
146
+ - **Branch Management**: Create, switch, delete branches
147
+ - **Repository Status**: Real-time git status and branch info
148
+ - **Sync Operations**: Pull, push, and synchronize branches
149
+ - **Working Directory**: Track uncommitted changes
150
+
151
+ ### 3. Test Area
152
+ - **Integration Testing**: Uses `@friggframework/ui` for testing integrations
153
+ - **User Simulation**: Switch between test users
154
+ - **Live Testing**: Test integrations in real-time with hot reload
155
+ - **Same UI**: Test with the exact UI end-users will see
156
+
157
+ ## API Endpoints
158
+
159
+ The management UI backend exposes clean REST APIs following DDD principles:
160
+
161
+ ### Project Management (`/api/projects`)
162
+ - `GET /api/projects/discover` - Discover Frigg projects in workspace
163
+ - `POST /api/projects/initialize` - Initialize new Frigg project
164
+ - `GET /api/projects/inspect` - Deep inspection of project structure
165
+ - `GET /api/projects/status` - Get project and process status
166
+ - `POST /api/projects/start` - Start Frigg project
167
+ - `POST /api/projects/stop` - Stop Frigg project
168
+
169
+ ### Git Operations (`/api/git`)
170
+ - `GET /api/git/status` - Repository and branch status
171
+ - `GET /api/git/branches` - List all branches
172
+ - `POST /api/git/branches` - Create new branch
173
+ - `PUT /api/git/branches/:name` - Switch to branch
174
+ - `DELETE /api/git/branches/:name` - Delete branch
175
+ - `POST /api/git/sync` - Sync branch with remote
176
+
177
+ ### Test Area (`/api/test-area`)
178
+ - `GET /api/test-area/status` - Check if Frigg is running for testing
179
+ - `POST /api/test-area/start` - Start Frigg for test area
180
+ - `POST /api/test-area/stop` - Stop test area Frigg instance
181
+ - `GET /api/test-area/health` - Health check for test Frigg
182
+
183
+ ### System
184
+ - `GET /api/health` - Management UI health check
136
185
 
137
186
  ## Styling
138
187
 
@@ -156,20 +205,46 @@ This project uses Tailwind CSS for styling with:
156
205
 
157
206
  ## Development
158
207
 
159
- ### Code Style
208
+ ### DDD/Hexagonal Architecture Guidelines
160
209
 
161
- - **ESLint**: Linting with React and React Hooks rules
162
- - **Prettier**: Code formatting (recommended)
163
- - **TypeScript Ready**: Prepared for TypeScript migration
210
+ **Golden Rule**: Handlers/Controllers ONLY call Use Cases, NEVER Repositories directly.
164
211
 
165
- ### Best Practices
212
+ ```
213
+ Controller → Use Case → Repository → External System
214
+ ```
215
+
216
+ #### Layer Responsibilities
217
+
218
+ 1. **Presentation Layer** (Routes & Controllers)
219
+ - HTTP-specific logic only (status codes, headers, response formatting)
220
+ - Calls use cases, never repositories
221
+ - Thin adapters with minimal logic
222
+ - Error mapping (domain errors → HTTP errors)
223
+
224
+ 2. **Application Layer** (Use Cases & Services)
225
+ - Business logic and orchestration
226
+ - Coordinates multiple repository calls
227
+ - Enforces business rules
228
+ - Receives dependencies via constructor (dependency injection)
166
229
 
167
- - Functional components with hooks
168
- - Component composition over inheritance
169
- - Separation of concerns (UI, state, logic)
170
- - Error boundaries for robustness
171
- - Loading states for better UX
172
- - Responsive design principles
230
+ 3. **Domain Layer** (Entities & Domain Services)
231
+ - Core business objects
232
+ - Domain logic and invariants
233
+ - Technology-agnostic
234
+
235
+ 4. **Infrastructure Layer** (Repositories & Adapters)
236
+ - Pure database/file operations (CRUD)
237
+ - External API calls
238
+ - No business logic
239
+ - Returns raw data
240
+
241
+ ### Code Style
242
+
243
+ - **DDD Principles**: Follow hexagonal architecture patterns
244
+ - **ESLint**: Linting with React and React Hooks rules
245
+ - **Functional Components**: React hooks and composition
246
+ - **Dependency Injection**: Constructor-based injection
247
+ - **Single Responsibility**: Each use case does one thing
173
248
 
174
249
  ## Building and Deployment
175
250
 
@@ -183,20 +258,81 @@ npm run preview
183
258
 
184
259
  The build output will be in the `dist/` directory and can be served by any static file server.
185
260
 
261
+ ## Key Architectural Decisions
262
+
263
+ ### Why No Integration Management in Management UI?
264
+
265
+ The Management UI is a **developer tool** for managing local Frigg projects. Integration and connection management belongs in `@friggframework/ui`, which is:
266
+ - Used by deployed Frigg applications (runtime)
267
+ - End-user facing
268
+ - Embedded in Test Area for testing
269
+
270
+ This separation ensures:
271
+ - ✅ Zero duplication between dev tools and runtime UI
272
+ - ✅ Clear boundaries of responsibility
273
+ - ✅ Developers test with the exact UI end-users see
274
+ - ✅ Simpler maintenance (single source of truth)
275
+
276
+ ### Test Area Pattern
277
+
278
+ The Test Area embeds `@friggframework/ui` to provide:
279
+ 1. **Integration testing** with the production UI
280
+ 2. **User simulation** for multi-tenant scenarios
281
+ 3. **Real-time testing** with hot reload
282
+ 4. **Authentication context** for testing flows
283
+
186
284
  ## Environment Variables
187
285
 
188
- The application automatically detects the environment:
286
+ ### Backend
287
+ - `PORT` - Server port (default: 3210)
288
+ - `PROJECT_PATH` - Default project path to manage
189
289
 
190
- - **Development**: API calls to `http://localhost:3001`
191
- - **Production**: API calls to the same origin
290
+ ### Frontend
291
+ - Auto-detects environment:
292
+ - **Development**: API at `http://localhost:3210`
293
+ - **Production**: Same origin
192
294
 
193
295
  ## Contributing
194
296
 
195
- 1. Follow the existing code style and patterns
196
- 2. Add error handling for new features
197
- 3. Include loading states for async operations
198
- 4. Write tests for new components (when testing is set up)
199
- 5. Update documentation for significant changes
297
+ 1. **Follow DDD Architecture**:
298
+ - Controllers call use cases, not repositories
299
+ - Business logic in use cases, not controllers
300
+ - Repositories only for data access
301
+ 2. **Add error handling** for new features
302
+ 3. **Include loading states** for async operations
303
+ 4. **Write tests** using the established patterns
304
+ 5. **Update documentation** for significant changes
305
+ 6. **Use dependency injection** for all dependencies
306
+
307
+ ## Testing
308
+
309
+ ```bash
310
+ # Run server tests
311
+ npm run test
312
+
313
+ # Run specific test file
314
+ npm run test -- path/to/test.js
315
+
316
+ # Watch mode
317
+ npm run test -- --watch
318
+ ```
319
+
320
+ ### Test Structure
321
+ - **Unit Tests**: Domain entities, value objects
322
+ - **Integration Tests**: Use case workflows
323
+ - **Controller Tests**: HTTP endpoint behavior
324
+
325
+ ## Related Packages
326
+
327
+ - **@friggframework/core**: Frigg framework core functionality
328
+ - **@friggframework/ui**: Runtime integration UI (used in Test Area)
329
+ - **@friggframework/devtools**: CLI tools for Frigg development
330
+
331
+ ## Documentation
332
+
333
+ - [DDD Architecture](./docs/ARCHITECTURE.md)
334
+ - [Cleanup Summary](./CLEANUP_SUMMARY.md)
335
+ - [Frigg Framework Docs](https://docs.friggframework.org)
200
336
 
201
337
  ## License
202
338