@gokiteam/goki-dev 0.2.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.
- package/README.md +478 -0
- package/bin/goki-dev.js +452 -0
- package/bin/mcp-server.js +16 -0
- package/bin/secrets-cli.js +302 -0
- package/cli/ComposeOverrideGenerator.js +226 -0
- package/cli/ComposeParser.js +73 -0
- package/cli/ConfigGenerator.js +304 -0
- package/cli/ConfigManager.js +46 -0
- package/cli/DatabaseManager.js +94 -0
- package/cli/DevToolsChecker.js +21 -0
- package/cli/DevToolsDir.js +66 -0
- package/cli/DevToolsManager.js +451 -0
- package/cli/DockerManager.js +138 -0
- package/cli/FunctionManager.js +95 -0
- package/cli/HttpProxyRewriter.js +91 -0
- package/cli/Logger.js +10 -0
- package/cli/McpConfigManager.js +123 -0
- package/cli/NgrokManager.js +431 -0
- package/cli/ProjectCLI.js +2322 -0
- package/cli/PubSubManager.js +129 -0
- package/cli/SnapshotManager.js +88 -0
- package/cli/UiFormatter.js +292 -0
- package/cli/WebhookUrlRewriter.js +32 -0
- package/cli/secrets/BiometricAuth.js +125 -0
- package/cli/secrets/SecretInjector.js +47 -0
- package/cli/secrets/SecretsConfig.js +141 -0
- package/cli/secrets/SecretsDoctor.js +384 -0
- package/cli/secrets/SecretsManager.js +255 -0
- package/client/dist/client.d.ts +332 -0
- package/client/dist/client.js +507 -0
- package/client/dist/helpers.d.ts +62 -0
- package/client/dist/helpers.js +122 -0
- package/client/dist/index.d.ts +59 -0
- package/client/dist/index.js +78 -0
- package/client/dist/package.json +1 -0
- package/client/dist/types.d.ts +280 -0
- package/client/dist/types.js +7 -0
- package/config.development +46 -0
- package/config.test +18 -0
- package/guidelines/CodingStyleGuideline.md +148 -0
- package/guidelines/CommentingGuideline.md +10 -0
- package/guidelines/HttpApiImplementationGuideline.md +137 -0
- package/guidelines/NamingGuideline.md +182 -0
- package/package.json +138 -0
- package/patterns/api/[collectionName]/Controllers.md +62 -0
- package/patterns/api/[collectionName]/Logic.md +154 -0
- package/patterns/api/[collectionName]/Permissions.md +81 -0
- package/patterns/api/[collectionName]/Router.md +83 -0
- package/patterns/api/[collectionName]/Schemas.md +197 -0
- package/patterns/configs/Patterns.md +7 -0
- package/patterns/enums/Patterns.md +24 -0
- package/patterns/errorHandling/Patterns.md +185 -0
- package/patterns/testing/Patterns.md +232 -0
- package/src/Server.js +238 -0
- package/src/api/dashboard/Controllers.js +9 -0
- package/src/api/dashboard/Logic.js +76 -0
- package/src/api/dashboard/Router.js +11 -0
- package/src/api/dashboard/Schemas.js +47 -0
- package/src/api/data/Controllers.js +26 -0
- package/src/api/data/Logic.js +188 -0
- package/src/api/data/Router.js +16 -0
- package/src/api/docker/Controllers.js +33 -0
- package/src/api/docker/Logic.js +268 -0
- package/src/api/docker/Router.js +15 -0
- package/src/api/docker/Schemas.js +80 -0
- package/src/api/docs/Controllers.js +15 -0
- package/src/api/docs/Logic.js +85 -0
- package/src/api/docs/Router.js +12 -0
- package/src/api/export/Controllers.js +30 -0
- package/src/api/export/Logic.js +143 -0
- package/src/api/export/Router.js +18 -0
- package/src/api/export/Schemas.js +104 -0
- package/src/api/firestore/Controllers.js +152 -0
- package/src/api/firestore/Logic.js +474 -0
- package/src/api/firestore/Router.js +23 -0
- package/src/api/functions/Controllers.js +261 -0
- package/src/api/functions/Logic.js +710 -0
- package/src/api/functions/Router.js +50 -0
- package/src/api/functions/Schemas.js +193 -0
- package/src/api/gateway/Controllers.js +72 -0
- package/src/api/gateway/Logic.js +74 -0
- package/src/api/gateway/Router.js +10 -0
- package/src/api/gateway/Schemas.js +19 -0
- package/src/api/health/Controllers.js +14 -0
- package/src/api/health/Logic.js +24 -0
- package/src/api/health/Router.js +12 -0
- package/src/api/httpTraffic/Controllers.js +29 -0
- package/src/api/httpTraffic/Logic.js +33 -0
- package/src/api/httpTraffic/Router.js +9 -0
- package/src/api/httpTraffic/Schemas.js +23 -0
- package/src/api/logging/Controllers.js +80 -0
- package/src/api/logging/Logic.js +461 -0
- package/src/api/logging/Router.js +24 -0
- package/src/api/logging/Schemas.js +43 -0
- package/src/api/mqtt/Controllers.js +17 -0
- package/src/api/mqtt/Logic.js +66 -0
- package/src/api/mqtt/Router.js +12 -0
- package/src/api/postgres/Controllers.js +97 -0
- package/src/api/postgres/Logic.js +221 -0
- package/src/api/postgres/Router.js +21 -0
- package/src/api/pubsub/Controllers.js +236 -0
- package/src/api/pubsub/Logic.js +732 -0
- package/src/api/pubsub/Router.js +41 -0
- package/src/api/pubsub/Schemas.js +355 -0
- package/src/api/redis/Controllers.js +63 -0
- package/src/api/redis/Logic.js +239 -0
- package/src/api/redis/Router.js +21 -0
- package/src/api/scheduler/Controllers.js +27 -0
- package/src/api/scheduler/Logic.js +49 -0
- package/src/api/scheduler/Router.js +16 -0
- package/src/api/services/Controllers.js +26 -0
- package/src/api/services/Logic.js +205 -0
- package/src/api/services/Router.js +14 -0
- package/src/api/services/Schemas.js +66 -0
- package/src/api/snapshots/Controllers.js +37 -0
- package/src/api/snapshots/Logic.js +797 -0
- package/src/api/snapshots/Router.js +15 -0
- package/src/api/snapshots/Schemas.js +23 -0
- package/src/api/webhooks/Controllers.js +49 -0
- package/src/api/webhooks/Logic.js +137 -0
- package/src/api/webhooks/Router.js +12 -0
- package/src/api/webhooks/Schemas.js +31 -0
- package/src/configs/Application.js +147 -0
- package/src/configs/Default.js +13 -0
- package/src/consumers/BlackboxLogsConsumer.js +235 -0
- package/src/consumers/DockerLogsConsumer.js +687 -0
- package/src/db/Tables.js +66 -0
- package/src/db/schemas/firestore.js +18 -0
- package/src/db/schemas/functions.js +65 -0
- package/src/db/schemas/httpTraffic.js +43 -0
- package/src/db/schemas/logging.js +74 -0
- package/src/db/schemas/migrations.js +64 -0
- package/src/db/schemas/mqtt.js +56 -0
- package/src/db/schemas/pubsub.js +90 -0
- package/src/db/schemas/pubsubRegistry.js +22 -0
- package/src/db/schemas/webhooks.js +28 -0
- package/src/emulation/awsiot/Controllers.js +91 -0
- package/src/emulation/awsiot/Logic.js +70 -0
- package/src/emulation/awsiot/Router.js +19 -0
- package/src/emulation/awsiot/Server.js +100 -0
- package/src/emulation/firestore/Server.js +136 -0
- package/src/emulation/logging/Controllers.js +212 -0
- package/src/emulation/logging/Logic.js +416 -0
- package/src/emulation/logging/Router.js +36 -0
- package/src/emulation/logging/Schemas.js +82 -0
- package/src/emulation/logging/Server.js +108 -0
- package/src/emulation/pubsub/Controllers.js +279 -0
- package/src/emulation/pubsub/DefaultTopics.js +162 -0
- package/src/emulation/pubsub/Logic.js +427 -0
- package/src/emulation/pubsub/README.md +309 -0
- package/src/emulation/pubsub/Router.js +33 -0
- package/src/emulation/pubsub/Server.js +104 -0
- package/src/emulation/pubsub/ShadowPoller.js +276 -0
- package/src/emulation/pubsub/ShadowSubscriptionManager.js +199 -0
- package/src/enums/ContainerNames.js +106 -0
- package/src/enums/ErrorReason.js +28 -0
- package/src/enums/FunctionStatuses.js +15 -0
- package/src/enums/FunctionTriggerTypes.js +15 -0
- package/src/enums/GatewayState.js +7 -0
- package/src/enums/ServiceNames.js +68 -0
- package/src/jobs/DatabaseMaintenance.js +184 -0
- package/src/jobs/MessageHistoryCleanup.js +152 -0
- package/src/mcp/ApiClient.js +25 -0
- package/src/mcp/Server.js +52 -0
- package/src/mcp/prompts/debugging.js +104 -0
- package/src/mcp/resources/platform.js +118 -0
- package/src/mcp/tools/data.js +84 -0
- package/src/mcp/tools/docker.js +166 -0
- package/src/mcp/tools/firestore.js +162 -0
- package/src/mcp/tools/functions.js +380 -0
- package/src/mcp/tools/httpTraffic.js +69 -0
- package/src/mcp/tools/logging.js +174 -0
- package/src/mcp/tools/mqtt.js +37 -0
- package/src/mcp/tools/postgres.js +130 -0
- package/src/mcp/tools/pubsub.js +316 -0
- package/src/mcp/tools/redis.js +146 -0
- package/src/mcp/tools/services.js +169 -0
- package/src/mcp/tools/snapshots.js +88 -0
- package/src/mcp/tools/webhooks.js +115 -0
- package/src/middleware/DevProxy.js +67 -0
- package/src/middleware/ErrorCatcher.js +35 -0
- package/src/middleware/HttpProxy.js +215 -0
- package/src/middleware/Reply.js +24 -0
- package/src/middleware/TraceId.js +9 -0
- package/src/middleware/WebhookProxy.js +234 -0
- package/src/protocols/mqtt/Broker.js +92 -0
- package/src/protocols/mqtt/Handlers.js +175 -0
- package/src/protocols/mqtt/PubSubBridge.js +162 -0
- package/src/protocols/mqtt/Server.js +116 -0
- package/src/runtime/FunctionRunner.js +179 -0
- package/src/services/AppGatewayService.js +582 -0
- package/src/singletons/FirestoreBroadcaster.js +367 -0
- package/src/singletons/FunctionTriggerDispatcher.js +456 -0
- package/src/singletons/FunctionsService.js +418 -0
- package/src/singletons/HttpProxy.js +224 -0
- package/src/singletons/LogBroadcaster.js +159 -0
- package/src/singletons/Logger.js +49 -0
- package/src/singletons/MemoryJsonStore.js +175 -0
- package/src/singletons/MessageBroadcaster.js +190 -0
- package/src/singletons/PostgresBroadcaster.js +367 -0
- package/src/singletons/PostgresClient.js +180 -0
- package/src/singletons/RedisClient.js +184 -0
- package/src/singletons/SqliteStore.js +480 -0
- package/src/singletons/TickService.js +151 -0
- package/src/singletons/WebhookProxy.js +223 -0
package/README.md
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
# @gokiteam/goki-dev
|
|
2
|
+
|
|
3
|
+
**"LocalStack for Goki Services"**
|
|
4
|
+
|
|
5
|
+
A unified local development platform providing mock implementations of external services (GCP Pub/Sub, AWS IoT MQTT, Redis, PostgreSQL, Google Cloud Logging, Firestore) with a centralized Web UI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Global install (CLI available everywhere)
|
|
11
|
+
npm install -g @gokiteam/goki-dev
|
|
12
|
+
|
|
13
|
+
# Or as a project dev dependency
|
|
14
|
+
npm install --save-dev @gokiteam/goki-dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### CLI — Manage local infrastructure
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Interactive menu
|
|
23
|
+
goki-dev
|
|
24
|
+
|
|
25
|
+
# Start all services (Docker)
|
|
26
|
+
goki-dev start
|
|
27
|
+
|
|
28
|
+
# Stop services
|
|
29
|
+
goki-dev stop
|
|
30
|
+
|
|
31
|
+
# Check status
|
|
32
|
+
goki-dev status
|
|
33
|
+
|
|
34
|
+
# MCP server for Claude Code integration
|
|
35
|
+
goki-dev-mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Programmatic — DevToolsClient for tests
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import { DevToolsClient } from '@gokiteam/goki-dev'
|
|
42
|
+
|
|
43
|
+
const devTools = new DevToolsClient()
|
|
44
|
+
const traceId = devTools.generateTraceId('user-reg')
|
|
45
|
+
|
|
46
|
+
// Verify Pub/Sub messages
|
|
47
|
+
await devTools.pubsub.waitForMessage({
|
|
48
|
+
filter: { topic: 'user-events' },
|
|
49
|
+
timeout: 5000,
|
|
50
|
+
traceId
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Query PostgreSQL
|
|
54
|
+
await devTools.postgres.query({
|
|
55
|
+
database: 'auth_dev',
|
|
56
|
+
query: 'SELECT * FROM users',
|
|
57
|
+
traceId
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Check Redis
|
|
61
|
+
await devTools.redis.get({ key: 'session:user-001', traceId })
|
|
62
|
+
|
|
63
|
+
// Assert no errors in logs
|
|
64
|
+
const errors = await devTools.logging.assertNoErrors({ traceId })
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Or use the pre-configured singleton:
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
import { devTools } from '@gokiteam/goki-dev'
|
|
71
|
+
|
|
72
|
+
const traceId = devTools.generateTraceId('test')
|
|
73
|
+
const message = await devTools.pubsub.waitForMessage({ ... })
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Docker (Direct)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
docker compose up -d
|
|
80
|
+
docker compose logs -f
|
|
81
|
+
docker compose down
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Access
|
|
85
|
+
|
|
86
|
+
### Production (Docker)
|
|
87
|
+
- **Web UI:** http://localhost:9001 (nginx + React)
|
|
88
|
+
- **Backend API:** http://localhost:9000/v1/*
|
|
89
|
+
- **Pub/Sub Emulator:** http://localhost:8085
|
|
90
|
+
- **AWS IoT Core HTTPS API:** http://localhost:8086 (POST /topics/:topicName)
|
|
91
|
+
- **Firestore Emulator:** http://localhost:8081
|
|
92
|
+
- **Cloud Logging:** http://localhost:8087
|
|
93
|
+
- **PostgreSQL:** localhost:5432 (user: postgres, password: postgres)
|
|
94
|
+
- **Redis:** localhost:6379
|
|
95
|
+
- **MQTT Broker:** localhost:8883
|
|
96
|
+
|
|
97
|
+
### Development
|
|
98
|
+
- **Web UI (dev):** http://localhost:9001 (React dev server)
|
|
99
|
+
- **Backend API (dev):** http://localhost:9000/v1/*
|
|
100
|
+
|
|
101
|
+
## Architecture
|
|
102
|
+
|
|
103
|
+
The platform uses a **microservices architecture** with separate frontend and backend containers:
|
|
104
|
+
|
|
105
|
+
### Production Architecture (Docker)
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
109
|
+
│ Docker Network (goki-network) │
|
|
110
|
+
├─────────────────────────────────────────────────────────────┤
|
|
111
|
+
│ │
|
|
112
|
+
│ ┌──────────────────┐ ┌───────────────────┐ │
|
|
113
|
+
│ │ Frontend (9001) │ │ Backend (9000) │ │
|
|
114
|
+
│ │ nginx + React │◄────────│ Node.js API │ │
|
|
115
|
+
│ │ │ API │ + Emulators │ │
|
|
116
|
+
│ └──────────────────┘ calls └─────────┬─────────┘ │
|
|
117
|
+
│ │ │
|
|
118
|
+
│ │ │
|
|
119
|
+
│ ┌────────────────────────────────┼────────┐ │
|
|
120
|
+
│ │ │ │ │
|
|
121
|
+
│ ▼ ▼ ▼ │
|
|
122
|
+
│ ┌─────────────┐ ┌───────────────┐ ┌──────┐ ┌──────┐ │
|
|
123
|
+
│ │ Pub/Sub │ │ Firestore │ │Redis │ │Postgres│ │
|
|
124
|
+
│ │ (8085) │ │ (8081) │ │(6379)│ │(5432)│ │
|
|
125
|
+
│ └─────────────┘ └───────────────┘ └──────┘ └──────┘ │
|
|
126
|
+
│ │
|
|
127
|
+
└─────────────────────────────────────────────────────────────┘
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Services
|
|
131
|
+
|
|
132
|
+
**Frontend Container (`dev-tools-frontend`):**
|
|
133
|
+
- **Base:** nginx:1.25-alpine
|
|
134
|
+
- **Port:** 9001 → 80 (nginx)
|
|
135
|
+
- **Purpose:** Serve React UI with optimized caching and compression
|
|
136
|
+
- **Features:**
|
|
137
|
+
- Gzip compression
|
|
138
|
+
- 1-year cache for static assets
|
|
139
|
+
- No-cache for index.html
|
|
140
|
+
- Security headers
|
|
141
|
+
- SPA routing support
|
|
142
|
+
|
|
143
|
+
**Backend Container (`dev-tools-backend`):**
|
|
144
|
+
- **Base:** node:20-alpine + Java 21
|
|
145
|
+
- **Ports:** 9000 (API), 8085 (Pub/Sub), 8086 (AWS IoT), 8087 (Logging), 8883 (MQTT)
|
|
146
|
+
- **Purpose:** API server and emulators
|
|
147
|
+
- **Features:**
|
|
148
|
+
- RESTful API endpoints
|
|
149
|
+
- GCP Pub/Sub emulator
|
|
150
|
+
- AWS IoT Core HTTPS API emulation
|
|
151
|
+
- Google Cloud Logging emulator
|
|
152
|
+
- MQTT broker (Aedes) with Pub/Sub bridge
|
|
153
|
+
- SQLite for Pub/Sub/Logging persistence
|
|
154
|
+
|
|
155
|
+
**Dependencies:**
|
|
156
|
+
- PostgreSQL 15 (port 5432)
|
|
157
|
+
- Redis 7 (port 6379)
|
|
158
|
+
- Pub/Sub Emulator (port 8085)
|
|
159
|
+
- Firestore Emulator (port 8081)
|
|
160
|
+
|
|
161
|
+
### Development Architecture
|
|
162
|
+
|
|
163
|
+
- **Backend:** Hot-reload with nodemon
|
|
164
|
+
- **Frontend:** React dev server with fast refresh
|
|
165
|
+
- Separate containers for each service
|
|
166
|
+
- Volume mounts for live code updates
|
|
167
|
+
|
|
168
|
+
## API Endpoints
|
|
169
|
+
|
|
170
|
+
### Health
|
|
171
|
+
- `GET /v1/health/liveness` - Service is alive
|
|
172
|
+
- `GET /v1/health/readiness` - Service is ready to handle requests
|
|
173
|
+
|
|
174
|
+
### Dashboard
|
|
175
|
+
- `POST /v1/dashboard/stats` - Get platform statistics
|
|
176
|
+
|
|
177
|
+
### Services
|
|
178
|
+
- `POST /v1/services/list` - List all services
|
|
179
|
+
- `POST /v1/services/status` - Get service status
|
|
180
|
+
- `POST /v1/services/restart` - Restart a service
|
|
181
|
+
|
|
182
|
+
### Pub/Sub
|
|
183
|
+
- `POST /v1/pubsub/topics/list` - List topics
|
|
184
|
+
- `POST /v1/pubsub/topics/create` - Create topic
|
|
185
|
+
- `POST /v1/pubsub/messages/publish` - Publish message
|
|
186
|
+
- `POST /v1/pubsub/messages/pull` - Pull messages
|
|
187
|
+
- `GET /v1/pubsub/messages/stream` - Stream messages (SSE)
|
|
188
|
+
|
|
189
|
+
### PostgreSQL
|
|
190
|
+
- `POST /v1/postgres/connection/test` - Test connection
|
|
191
|
+
- `POST /v1/postgres/databases/list` - List databases
|
|
192
|
+
- `POST /v1/postgres/tables/list` - List tables
|
|
193
|
+
- `POST /v1/postgres/rows/list` - List rows
|
|
194
|
+
- `POST /v1/postgres/query/execute` - Execute query
|
|
195
|
+
|
|
196
|
+
### Redis
|
|
197
|
+
- `POST /v1/redis/connection/test` - Test connection
|
|
198
|
+
- `POST /v1/redis/info` - Get info
|
|
199
|
+
- `POST /v1/redis/keys/scan` - Scan keys
|
|
200
|
+
- `POST /v1/redis/keys/get` - Get key value
|
|
201
|
+
- `POST /v1/redis/keys/update` - Update key
|
|
202
|
+
- `POST /v1/redis/keys/delete` - Delete key
|
|
203
|
+
|
|
204
|
+
### Firestore
|
|
205
|
+
- `POST /v1/firestore/collections/list` - List collections
|
|
206
|
+
- `POST /v1/firestore/documents/list` - List documents
|
|
207
|
+
- `POST /v1/firestore/documents/get` - Get document
|
|
208
|
+
- `POST /v1/firestore/query/execute` - Execute query
|
|
209
|
+
|
|
210
|
+
### Export/Import
|
|
211
|
+
- `POST /v1/data/export` - Export all data
|
|
212
|
+
- `POST /v1/data/import` - Import data
|
|
213
|
+
- `POST /v1/data/clear` - Clear all data
|
|
214
|
+
|
|
215
|
+
## MQTT and AWS IoT Core Emulation
|
|
216
|
+
|
|
217
|
+
The platform provides full MQTT broker and AWS IoT Core HTTPS API emulation for local development and testing with backend services like device-simulator.
|
|
218
|
+
|
|
219
|
+
### Architecture (Docker)
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
223
|
+
│ Docker Network (goki-network) │
|
|
224
|
+
├─────────────────────────────────────────────────────────────┤
|
|
225
|
+
│ │
|
|
226
|
+
│ device-simulator container │
|
|
227
|
+
│ ↓ [MQTT to dev-tools-backend:8883] │
|
|
228
|
+
│ dev-tools-backend: Aedes MQTT Broker │
|
|
229
|
+
│ ↓ [Pub/Sub Bridge] │
|
|
230
|
+
│ pubsub-emulator (port 8085) │
|
|
231
|
+
│ ↓ [Topic: mqttMessageReceived] │
|
|
232
|
+
│ device-simulator (subscribes via pubsub-emulator:8085) │
|
|
233
|
+
│ │
|
|
234
|
+
│ device-simulator │
|
|
235
|
+
│ ↓ [POST to dev-tools-backend:8086/topics/...?qos=1] │
|
|
236
|
+
│ dev-tools-backend: AWS IoT Core HTTPS API │
|
|
237
|
+
│ ↓ [Publishes to Aedes broker] │
|
|
238
|
+
│ device-simulator (subscribed to response topic via MQTT) │
|
|
239
|
+
│ │
|
|
240
|
+
└─────────────────────────────────────────────────────────────┘
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Key Service Names (Docker networking):**
|
|
244
|
+
- `dev-tools-backend` - MQTT broker (8883) + AWS IoT API (8086)
|
|
245
|
+
- `pubsub-emulator` - Pub/Sub emulator (8085)
|
|
246
|
+
- `redis` - Redis (6379)
|
|
247
|
+
- `postgres` - PostgreSQL (5432)
|
|
248
|
+
|
|
249
|
+
**From Host Machine:** Use `localhost` instead of service names
|
|
250
|
+
|
|
251
|
+
### MQTT Broker (Port 8883)
|
|
252
|
+
|
|
253
|
+
- **Implementation:** Aedes MQTT broker (pure Node.js)
|
|
254
|
+
- **Protocol:** MQTT 3.1.1
|
|
255
|
+
- **Authentication:** Relaxed mode (accept all connections for dev)
|
|
256
|
+
- **Features:**
|
|
257
|
+
- QoS levels 0, 1
|
|
258
|
+
- Last Will Testament (LWT)
|
|
259
|
+
- Retained messages
|
|
260
|
+
- Persistent connections
|
|
261
|
+
|
|
262
|
+
**Connect with MQTT client:**
|
|
263
|
+
|
|
264
|
+
From Docker container (using service name):
|
|
265
|
+
```javascript
|
|
266
|
+
import mqtt from 'mqtt'
|
|
267
|
+
|
|
268
|
+
const client = mqtt.connect('mqtt://dev-tools-backend:8883', {
|
|
269
|
+
clientId: 'test-device-123'
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
client.on('connect', () => {
|
|
273
|
+
client.subscribe('rs/+/test-device-123')
|
|
274
|
+
client.publish('rq/test/test-device-123', Buffer.from('packet'), { qos: 1 })
|
|
275
|
+
})
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
From host machine (using localhost):
|
|
279
|
+
```javascript
|
|
280
|
+
import mqtt from 'mqtt'
|
|
281
|
+
|
|
282
|
+
const client = mqtt.connect('mqtt://localhost:8883', {
|
|
283
|
+
clientId: 'test-device-123'
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### AWS IoT Core HTTPS API (Port 8086)
|
|
288
|
+
|
|
289
|
+
Mimics AWS IoT Core's HTTPS publishing API for backend services.
|
|
290
|
+
|
|
291
|
+
**Endpoint:** `POST http://localhost:8086/topics/:topicName?qos=1`
|
|
292
|
+
- **Body:** Binary payload (Buffer)
|
|
293
|
+
- **Query:** `qos` (optional, defaults to 1)
|
|
294
|
+
- **Response:** Empty 200 (matching AWS IoT Core)
|
|
295
|
+
- **Auth:** SigV4 headers accepted but not validated (dev mode)
|
|
296
|
+
|
|
297
|
+
**Example usage (device-simulator):**
|
|
298
|
+
|
|
299
|
+
When device-simulator runs in Docker (on goki-network):
|
|
300
|
+
```bash
|
|
301
|
+
# device-simulator Docker environment
|
|
302
|
+
AWS_IOT_CORE_MQTT_ENDPOINT=dev-tools-backend:8086 # Use service name
|
|
303
|
+
PUBSUB_EMULATOR_HOST=pubsub-emulator:8085 # Use service name
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
When device-simulator runs on host machine:
|
|
307
|
+
```bash
|
|
308
|
+
# device-simulator local development
|
|
309
|
+
AWS_IOT_CORE_MQTT_ENDPOINT=localhost:8086 # Use localhost
|
|
310
|
+
PUBSUB_EMULATOR_HOST=localhost:8085 # Use localhost
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Publishing (no code changes needed):
|
|
314
|
+
```javascript
|
|
315
|
+
const response = await axios.post(
|
|
316
|
+
`http://${AWS_IOT_CORE_MQTT_ENDPOINT}/topics/rs/test/device-123?qos=1`,
|
|
317
|
+
binaryPacket, // Buffer
|
|
318
|
+
{ headers: { 'Content-Type': 'application/octet-stream' } }
|
|
319
|
+
)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### MQTT → Pub/Sub Bridge
|
|
323
|
+
|
|
324
|
+
Automatically routes MQTT messages to Pub/Sub (mimics AWS IoT Core behavior).
|
|
325
|
+
|
|
326
|
+
**Topic:** `mqttMessageReceived`
|
|
327
|
+
**Message Format:**
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"clientId": "test-device-123",
|
|
331
|
+
"topicName": "rq/test/test-device-123",
|
|
332
|
+
"packet": "base64-encoded-binary",
|
|
333
|
+
"receivedAtMilliseconds": 1234567890
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Lifecycle Events:**
|
|
338
|
+
- **Topic:** `simulator/connected` - Client connected
|
|
339
|
+
- **Topic:** `simulator/disconnected` - Client disconnected
|
|
340
|
+
|
|
341
|
+
### Topic Patterns (Goki Conventions)
|
|
342
|
+
|
|
343
|
+
- **Request:** `rq/{action}/{clientId}`
|
|
344
|
+
- **Response:** `rs/{action}/{clientId}`
|
|
345
|
+
- **Notification:** `nf/{action}/{clientId}`
|
|
346
|
+
- **Will:** `w/{action}/{clientId}`
|
|
347
|
+
- **Lifecycle:** `simulator/connected`, `simulator/disconnected`
|
|
348
|
+
|
|
349
|
+
## Testing
|
|
350
|
+
|
|
351
|
+
### End-to-End Tests
|
|
352
|
+
|
|
353
|
+
Comprehensive E2E test suite using Playwright:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
# Run all E2E tests
|
|
357
|
+
npm run test:e2e
|
|
358
|
+
|
|
359
|
+
# Run UI tests only
|
|
360
|
+
npm run test:e2e:ui
|
|
361
|
+
|
|
362
|
+
# Run workflow tests only
|
|
363
|
+
npm run test:e2e:workflows
|
|
364
|
+
|
|
365
|
+
# Run with browser UI
|
|
366
|
+
npm run test:e2e:headed
|
|
367
|
+
|
|
368
|
+
# Debug mode
|
|
369
|
+
npm run test:e2e:debug
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
See [E2E_TEST_GUIDE.md](./tests/E2E_TEST_GUIDE.md) for complete testing documentation.
|
|
373
|
+
|
|
374
|
+
### Integration Tests
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
# Run all integration tests
|
|
378
|
+
npm run test:integration
|
|
379
|
+
|
|
380
|
+
# Run specific test categories
|
|
381
|
+
npm run test:api
|
|
382
|
+
npm run test:emulation
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Docker Images
|
|
386
|
+
|
|
387
|
+
### Production Images
|
|
388
|
+
- **Backend:** `dev-tools-dev-tools-backend` (~1.19GB)
|
|
389
|
+
- Includes Java 21 for Firebase emulator
|
|
390
|
+
- Python3, make, g++ for native dependencies
|
|
391
|
+
- Firebase CLI
|
|
392
|
+
|
|
393
|
+
- **Frontend:** `dev-tools-dev-tools-frontend` (~464MB)
|
|
394
|
+
- Multi-stage build (React → nginx)
|
|
395
|
+
- Optimized static assets
|
|
396
|
+
|
|
397
|
+
### Development Images
|
|
398
|
+
- **Backend:** Uses `Dockerfile.dev` with hot-reload
|
|
399
|
+
- **Frontend:** Uses `ui/Dockerfile.dev` with React dev server
|
|
400
|
+
|
|
401
|
+
## Environment Variables
|
|
402
|
+
|
|
403
|
+
### Backend
|
|
404
|
+
- `NODE_ENV` - Environment (development/production)
|
|
405
|
+
- `WEB_UI_PORT` - Backend port (default: 9000)
|
|
406
|
+
- `PUBSUB_EMULATOR_HOST` - Pub/Sub emulator host
|
|
407
|
+
- `FIRESTORE_EMULATOR_HOST` - Firestore emulator host
|
|
408
|
+
- `POSTGRES_HOST` - PostgreSQL host
|
|
409
|
+
- `POSTGRES_PORT` - PostgreSQL port
|
|
410
|
+
- `POSTGRES_USER` - PostgreSQL user
|
|
411
|
+
- `POSTGRES_PASSWORD` - PostgreSQL password
|
|
412
|
+
- `REDIS_HOST` - Redis host
|
|
413
|
+
- `REDIS_PORT` - Redis port
|
|
414
|
+
- `DATA_DIR` - Data directory for SQLite
|
|
415
|
+
|
|
416
|
+
### Frontend
|
|
417
|
+
- `REACT_APP_API_URL` - Backend API URL (default: http://localhost:9000)
|
|
418
|
+
|
|
419
|
+
## Troubleshooting
|
|
420
|
+
|
|
421
|
+
### Backend won't start
|
|
422
|
+
```bash
|
|
423
|
+
# Check logs
|
|
424
|
+
docker logs goki-dev-tools-backend
|
|
425
|
+
|
|
426
|
+
# Common issue: Corrupted SQLite database
|
|
427
|
+
rm -f data/dev-tools.db*
|
|
428
|
+
docker compose restart dev-tools-backend
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Frontend won't load
|
|
432
|
+
```bash
|
|
433
|
+
# Check logs
|
|
434
|
+
docker logs goki-dev-tools-frontend
|
|
435
|
+
|
|
436
|
+
# Verify backend is running
|
|
437
|
+
curl http://localhost:9000/v1/health/readiness
|
|
438
|
+
|
|
439
|
+
# Rebuild frontend
|
|
440
|
+
docker compose build dev-tools-frontend
|
|
441
|
+
docker compose up -d dev-tools-frontend
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### PostgreSQL/Redis not connecting
|
|
445
|
+
```bash
|
|
446
|
+
# Check if services are running
|
|
447
|
+
docker compose ps
|
|
448
|
+
|
|
449
|
+
# Verify ports are accessible
|
|
450
|
+
nc -zv localhost 5432 # PostgreSQL
|
|
451
|
+
nc -zv localhost 6379 # Redis
|
|
452
|
+
|
|
453
|
+
# Restart services
|
|
454
|
+
docker compose restart postgres redis
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Project Status
|
|
458
|
+
|
|
459
|
+
✅ **Production Ready** - Complete with comprehensive E2E tests
|
|
460
|
+
|
|
461
|
+
### Features
|
|
462
|
+
- ✅ Pub/Sub message management with real-time streaming
|
|
463
|
+
- ✅ PostgreSQL database viewer with query execution
|
|
464
|
+
- ✅ Redis key-value browser with type support
|
|
465
|
+
- ✅ Firestore document viewer with queries
|
|
466
|
+
- ✅ Google Cloud Logging viewer with filters
|
|
467
|
+
- ✅ MQTT broker monitoring
|
|
468
|
+
- ✅ Service control dashboard
|
|
469
|
+
- ✅ Export/Import functionality
|
|
470
|
+
- ✅ Docker auto-start for CLI
|
|
471
|
+
- ✅ Split frontend/backend architecture
|
|
472
|
+
|
|
473
|
+
See `plans/platform-specification.md` for complete specification.
|
|
474
|
+
|
|
475
|
+
## Documentation
|
|
476
|
+
|
|
477
|
+
- [Docker Setup](./DOCKER.md)
|
|
478
|
+
- [E2E Testing Guide](./E2E-TESTING-GUIDE.md)
|