create-chaaskit 0.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.
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add-infra.d.ts +6 -0
- package/dist/commands/add-infra.d.ts.map +1 -0
- package/dist/commands/add-infra.js +160 -0
- package/dist/commands/add-infra.js.map +1 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +63 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/db-sync.d.ts +13 -0
- package/dist/commands/db-sync.d.ts.map +1 -0
- package/dist/commands/db-sync.js +108 -0
- package/dist/commands/db-sync.js.map +1 -0
- package/dist/commands/dev.d.ts +7 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +61 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +214 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/.env.example +24 -0
- package/dist/templates/README.md +81 -0
- package/dist/templates/app/components/AcceptInviteClient.tsx +10 -0
- package/dist/templates/app/components/AdminDashboardClient.tsx +10 -0
- package/dist/templates/app/components/AdminTeamClient.tsx +10 -0
- package/dist/templates/app/components/AdminTeamsClient.tsx +10 -0
- package/dist/templates/app/components/AdminUsersClient.tsx +10 -0
- package/dist/templates/app/components/ApiKeysClient.tsx +10 -0
- package/dist/templates/app/components/AutomationsClient.tsx +10 -0
- package/dist/templates/app/components/ChatClient.tsx +13 -0
- package/dist/templates/app/components/ClientOnly.tsx +6 -0
- package/dist/templates/app/components/DocumentsClient.tsx +10 -0
- package/dist/templates/app/components/OAuthConsentClient.tsx +10 -0
- package/dist/templates/app/components/PricingClient.tsx +10 -0
- package/dist/templates/app/components/TeamSettingsClient.tsx +10 -0
- package/dist/templates/app/components/VerifyEmailClient.tsx +10 -0
- package/dist/templates/app/entry.client.tsx +12 -0
- package/dist/templates/app/entry.server.tsx +67 -0
- package/dist/templates/app/root.tsx +91 -0
- package/dist/templates/app/routes/_index.tsx +82 -0
- package/dist/templates/app/routes/admin._index.tsx +57 -0
- package/dist/templates/app/routes/admin.teams.$teamId.tsx +57 -0
- package/dist/templates/app/routes/admin.teams._index.tsx +57 -0
- package/dist/templates/app/routes/admin.users.tsx +57 -0
- package/dist/templates/app/routes/api-keys.tsx +57 -0
- package/dist/templates/app/routes/automations.tsx +57 -0
- package/dist/templates/app/routes/chat._index.tsx +11 -0
- package/dist/templates/app/routes/chat.admin._index.tsx +10 -0
- package/dist/templates/app/routes/chat.admin.teams.$teamId.tsx +10 -0
- package/dist/templates/app/routes/chat.admin.teams._index.tsx +10 -0
- package/dist/templates/app/routes/chat.admin.users.tsx +10 -0
- package/dist/templates/app/routes/chat.api-keys.tsx +10 -0
- package/dist/templates/app/routes/chat.automations.tsx +10 -0
- package/dist/templates/app/routes/chat.documents.tsx +10 -0
- package/dist/templates/app/routes/chat.team.$teamId.settings.tsx +10 -0
- package/dist/templates/app/routes/chat.thread.$threadId.tsx +11 -0
- package/dist/templates/app/routes/chat.tsx +39 -0
- package/dist/templates/app/routes/documents.tsx +57 -0
- package/dist/templates/app/routes/invite.$token.tsx +10 -0
- package/dist/templates/app/routes/login.tsx +334 -0
- package/dist/templates/app/routes/oauth.consent.tsx +10 -0
- package/dist/templates/app/routes/pricing.tsx +10 -0
- package/dist/templates/app/routes/privacy.tsx +197 -0
- package/dist/templates/app/routes/register.tsx +398 -0
- package/dist/templates/app/routes/shared.$shareId.tsx +226 -0
- package/dist/templates/app/routes/team.$teamId.settings.tsx +57 -0
- package/dist/templates/app/routes/terms.tsx +173 -0
- package/dist/templates/app/routes/thread.$threadId.tsx +102 -0
- package/dist/templates/app/routes/verify-email.tsx +10 -0
- package/dist/templates/app/routes.ts +47 -0
- package/dist/templates/config/app.config.ts +216 -0
- package/dist/templates/docs/admin.md +257 -0
- package/dist/templates/docs/api-keys.md +403 -0
- package/dist/templates/docs/authentication.md +247 -0
- package/dist/templates/docs/configuration.md +1212 -0
- package/dist/templates/docs/custom-pages.md +466 -0
- package/dist/templates/docs/deployment.md +362 -0
- package/dist/templates/docs/development.md +411 -0
- package/dist/templates/docs/documents.md +293 -0
- package/dist/templates/docs/extensions.md +639 -0
- package/dist/templates/docs/index.md +139 -0
- package/dist/templates/docs/installation.md +286 -0
- package/dist/templates/docs/mcp.md +952 -0
- package/dist/templates/docs/native-tools.md +688 -0
- package/dist/templates/docs/queue.md +514 -0
- package/dist/templates/docs/scheduled-prompts.md +279 -0
- package/dist/templates/docs/settings.md +415 -0
- package/dist/templates/docs/slack.md +318 -0
- package/dist/templates/docs/styling.md +288 -0
- package/dist/templates/extensions/agents/.gitkeep +0 -0
- package/dist/templates/extensions/pages/.gitkeep +0 -0
- package/dist/templates/extensions/payment-plans/.gitkeep +0 -0
- package/dist/templates/index.html +16 -0
- package/dist/templates/infra-aws/.github/workflows/deploy.yml +95 -0
- package/dist/templates/infra-aws/README.md +207 -0
- package/dist/templates/infra-aws/bin/cdk.ts +18 -0
- package/dist/templates/infra-aws/cdk.json +43 -0
- package/dist/templates/infra-aws/config/deployment.ts +156 -0
- package/dist/templates/infra-aws/lib/chaaskit-stack.ts +419 -0
- package/dist/templates/infra-aws/package.json +27 -0
- package/dist/templates/infra-aws/scripts/build-app.sh +63 -0
- package/dist/templates/infra-aws/tsconfig.json +25 -0
- package/dist/templates/package.json +46 -0
- package/dist/templates/prisma/schema/base.prisma +584 -0
- package/dist/templates/prisma/schema/custom.prisma +24 -0
- package/dist/templates/prisma/schema.prisma +271 -0
- package/dist/templates/public/favicon.svg +4 -0
- package/dist/templates/public/logo.svg +4 -0
- package/dist/templates/react-router.config.ts +11 -0
- package/dist/templates/server.js +52 -0
- package/dist/templates/src/main.tsx +8 -0
- package/dist/templates/tsconfig.json +26 -0
- package/dist/templates/vite.config.ts +26 -0
- package/package.json +46 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# Deployment
|
|
2
|
+
|
|
3
|
+
This guide covers deploying ChaasKit applications to production.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm build
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This creates:
|
|
12
|
+
- `build/server/` - Server bundle for Node.js
|
|
13
|
+
- `build/client/` - Client assets (JS, CSS)
|
|
14
|
+
|
|
15
|
+
The production server serves both API routes and the React Router v7 application.
|
|
16
|
+
|
|
17
|
+
## Start Production Server
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm start
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This runs `server.js` which starts the production server on port 3000 (or `PORT` env var).
|
|
24
|
+
|
|
25
|
+
## Production Requirements
|
|
26
|
+
|
|
27
|
+
- Node.js 18+
|
|
28
|
+
- PostgreSQL 14+
|
|
29
|
+
- Environment variables configured
|
|
30
|
+
- HTTPS for production
|
|
31
|
+
|
|
32
|
+
## Environment Variables
|
|
33
|
+
|
|
34
|
+
Production `.env`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Required
|
|
38
|
+
NODE_ENV=production
|
|
39
|
+
DATABASE_URL="postgresql://..."
|
|
40
|
+
SESSION_SECRET="production-secret-32-chars-min"
|
|
41
|
+
JWT_SECRET="production-jwt-secret-32-chars-min"
|
|
42
|
+
APP_URL="https://your-domain.com"
|
|
43
|
+
API_URL="https://your-domain.com"
|
|
44
|
+
|
|
45
|
+
# AI Provider (at least one required)
|
|
46
|
+
ANTHROPIC_API_KEY="sk-ant-..."
|
|
47
|
+
# or
|
|
48
|
+
OPENAI_API_KEY="sk-..."
|
|
49
|
+
|
|
50
|
+
# Optional - OAuth
|
|
51
|
+
GOOGLE_CLIENT_ID="..."
|
|
52
|
+
GOOGLE_CLIENT_SECRET="..."
|
|
53
|
+
GITHUB_CLIENT_ID="..."
|
|
54
|
+
GITHUB_CLIENT_SECRET="..."
|
|
55
|
+
|
|
56
|
+
# Optional - Payments
|
|
57
|
+
STRIPE_SECRET_KEY="sk_live_..."
|
|
58
|
+
STRIPE_WEBHOOK_SECRET="whsec_..."
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Docker Deployment
|
|
62
|
+
|
|
63
|
+
### Dockerfile
|
|
64
|
+
|
|
65
|
+
```dockerfile
|
|
66
|
+
FROM node:20-slim
|
|
67
|
+
|
|
68
|
+
RUN corepack enable pnpm
|
|
69
|
+
|
|
70
|
+
WORKDIR /app
|
|
71
|
+
|
|
72
|
+
# Copy package files
|
|
73
|
+
COPY package.json pnpm-lock.yaml ./
|
|
74
|
+
COPY config/ ./config/
|
|
75
|
+
COPY prisma/ ./prisma/
|
|
76
|
+
|
|
77
|
+
# Install dependencies
|
|
78
|
+
RUN pnpm install --frozen-lockfile --prod
|
|
79
|
+
|
|
80
|
+
# Copy built application
|
|
81
|
+
COPY build/ ./build/
|
|
82
|
+
COPY server.js ./
|
|
83
|
+
|
|
84
|
+
# Generate Prisma client
|
|
85
|
+
RUN npx prisma generate --schema=./prisma/schema
|
|
86
|
+
|
|
87
|
+
EXPOSE 3000
|
|
88
|
+
|
|
89
|
+
ENV NODE_ENV=production
|
|
90
|
+
|
|
91
|
+
CMD ["node", "server.js"]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Build Steps
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 1. Build the application locally
|
|
98
|
+
pnpm build
|
|
99
|
+
|
|
100
|
+
# 2. Build Docker image
|
|
101
|
+
docker build -t my-chat-app .
|
|
102
|
+
|
|
103
|
+
# 3. Run container
|
|
104
|
+
docker run -p 3000:3000 --env-file .env.production my-chat-app
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Docker Compose
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
version: '3.8'
|
|
111
|
+
|
|
112
|
+
services:
|
|
113
|
+
app:
|
|
114
|
+
build: .
|
|
115
|
+
ports:
|
|
116
|
+
- "3000:3000"
|
|
117
|
+
environment:
|
|
118
|
+
- NODE_ENV=production
|
|
119
|
+
- DATABASE_URL=postgresql://postgres:postgres@db:5432/my_app
|
|
120
|
+
env_file:
|
|
121
|
+
- .env.production
|
|
122
|
+
depends_on:
|
|
123
|
+
- db
|
|
124
|
+
|
|
125
|
+
db:
|
|
126
|
+
image: postgres:15
|
|
127
|
+
environment:
|
|
128
|
+
- POSTGRES_USER=postgres
|
|
129
|
+
- POSTGRES_PASSWORD=postgres
|
|
130
|
+
- POSTGRES_DB=my_app
|
|
131
|
+
volumes:
|
|
132
|
+
- postgres_data:/var/lib/postgresql/data
|
|
133
|
+
|
|
134
|
+
volumes:
|
|
135
|
+
postgres_data:
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Platform Deployments
|
|
139
|
+
|
|
140
|
+
### Railway
|
|
141
|
+
|
|
142
|
+
1. Connect your GitHub repository
|
|
143
|
+
2. Set environment variables in Railway dashboard
|
|
144
|
+
3. Railway auto-detects Node.js and deploys
|
|
145
|
+
|
|
146
|
+
Build settings (if needed):
|
|
147
|
+
- Build command: `pnpm install && pnpm build && pnpm db:generate`
|
|
148
|
+
- Start command: `pnpm start`
|
|
149
|
+
|
|
150
|
+
### Render
|
|
151
|
+
|
|
152
|
+
1. Create a Web Service
|
|
153
|
+
2. Connect your repository
|
|
154
|
+
3. Configure:
|
|
155
|
+
- Build command: `pnpm install && pnpm build && npx prisma generate`
|
|
156
|
+
- Start command: `node server.js`
|
|
157
|
+
4. Add environment variables
|
|
158
|
+
|
|
159
|
+
### Fly.io
|
|
160
|
+
|
|
161
|
+
Create `fly.toml`:
|
|
162
|
+
|
|
163
|
+
```toml
|
|
164
|
+
app = "my-chat-app"
|
|
165
|
+
primary_region = "iad"
|
|
166
|
+
|
|
167
|
+
[build]
|
|
168
|
+
[build.args]
|
|
169
|
+
NODE_VERSION = "20"
|
|
170
|
+
|
|
171
|
+
[env]
|
|
172
|
+
NODE_ENV = "production"
|
|
173
|
+
PORT = "3000"
|
|
174
|
+
|
|
175
|
+
[http_service]
|
|
176
|
+
internal_port = 3000
|
|
177
|
+
force_https = true
|
|
178
|
+
auto_stop_machines = true
|
|
179
|
+
auto_start_machines = true
|
|
180
|
+
min_machines_running = 0
|
|
181
|
+
|
|
182
|
+
[[vm]]
|
|
183
|
+
memory = "512mb"
|
|
184
|
+
cpu_kind = "shared"
|
|
185
|
+
cpus = 1
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Deploy:
|
|
189
|
+
```bash
|
|
190
|
+
fly launch
|
|
191
|
+
fly secrets set DATABASE_URL="..." JWT_SECRET="..." SESSION_SECRET="..."
|
|
192
|
+
fly deploy
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Heroku
|
|
196
|
+
|
|
197
|
+
Create `Procfile`:
|
|
198
|
+
```
|
|
199
|
+
web: node server.js
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Deploy:
|
|
203
|
+
```bash
|
|
204
|
+
heroku create my-chat-app
|
|
205
|
+
heroku config:set DATABASE_URL="..." JWT_SECRET="..."
|
|
206
|
+
git push heroku main
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Database Migrations
|
|
210
|
+
|
|
211
|
+
### Development (Push)
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pnpm db:push
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Production (Migrations)
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Create a migration
|
|
221
|
+
pnpm db:migrate
|
|
222
|
+
|
|
223
|
+
# Deploy migrations in production
|
|
224
|
+
DATABASE_URL="..." npx prisma migrate deploy
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Reverse Proxy (Nginx)
|
|
228
|
+
|
|
229
|
+
For running behind Nginx:
|
|
230
|
+
|
|
231
|
+
```nginx
|
|
232
|
+
server {
|
|
233
|
+
listen 443 ssl http2;
|
|
234
|
+
server_name your-domain.com;
|
|
235
|
+
|
|
236
|
+
ssl_certificate /path/to/cert.pem;
|
|
237
|
+
ssl_certificate_key /path/to/key.pem;
|
|
238
|
+
|
|
239
|
+
# Proxy all requests to Node.js
|
|
240
|
+
location / {
|
|
241
|
+
proxy_pass http://localhost:3000;
|
|
242
|
+
proxy_http_version 1.1;
|
|
243
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
244
|
+
proxy_set_header Connection 'upgrade';
|
|
245
|
+
proxy_set_header Host $host;
|
|
246
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
247
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
248
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
249
|
+
proxy_cache_bypass $http_upgrade;
|
|
250
|
+
|
|
251
|
+
# SSE support for chat streaming
|
|
252
|
+
proxy_buffering off;
|
|
253
|
+
proxy_read_timeout 86400;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# Redirect HTTP to HTTPS
|
|
258
|
+
server {
|
|
259
|
+
listen 80;
|
|
260
|
+
server_name your-domain.com;
|
|
261
|
+
return 301 https://$server_name$request_uri;
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Health Checks
|
|
266
|
+
|
|
267
|
+
The app exposes a health endpoint:
|
|
268
|
+
|
|
269
|
+
```http
|
|
270
|
+
GET /api/health
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Response:
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"status": "ok",
|
|
277
|
+
"timestamp": "2024-01-01T00:00:00.000Z"
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Use this for load balancer health checks and uptime monitoring.
|
|
282
|
+
|
|
283
|
+
## Security Checklist
|
|
284
|
+
|
|
285
|
+
- [ ] HTTPS enabled
|
|
286
|
+
- [ ] Environment variables secured (not in code)
|
|
287
|
+
- [ ] Database credentials rotated regularly
|
|
288
|
+
- [ ] Strong, unique secrets for JWT and session
|
|
289
|
+
- [ ] CORS properly configured
|
|
290
|
+
- [ ] Rate limiting enabled
|
|
291
|
+
- [ ] Document upload limits set (`documents.maxFileSizeMB`)
|
|
292
|
+
- [ ] MCP servers scoped appropriately
|
|
293
|
+
- [ ] Admin access restricted
|
|
294
|
+
|
|
295
|
+
## Monitoring
|
|
296
|
+
|
|
297
|
+
### Logging
|
|
298
|
+
|
|
299
|
+
Server logs include:
|
|
300
|
+
- Request logs with timing
|
|
301
|
+
- Error stack traces
|
|
302
|
+
- Config loading status
|
|
303
|
+
- MCP connection status
|
|
304
|
+
|
|
305
|
+
### Error Tracking
|
|
306
|
+
|
|
307
|
+
Consider integrating:
|
|
308
|
+
- Sentry for error tracking
|
|
309
|
+
- LogRocket for session replay
|
|
310
|
+
- Datadog for metrics
|
|
311
|
+
|
|
312
|
+
## Scaling
|
|
313
|
+
|
|
314
|
+
### Horizontal Scaling
|
|
315
|
+
|
|
316
|
+
The app is stateless and can be horizontally scaled:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
# Docker Compose
|
|
320
|
+
docker-compose up --scale app=3
|
|
321
|
+
|
|
322
|
+
# Kubernetes
|
|
323
|
+
kubectl scale deployment my-chat-app --replicas=3
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Database Connection Pooling
|
|
327
|
+
|
|
328
|
+
For production, use connection pooling:
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
DATABASE_URL="postgresql://...?connection_limit=10&pool_timeout=20"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Consider using PgBouncer or similar for high-traffic deployments.
|
|
335
|
+
|
|
336
|
+
### CDN
|
|
337
|
+
|
|
338
|
+
For static assets, consider a CDN:
|
|
339
|
+
- CloudFlare
|
|
340
|
+
- AWS CloudFront
|
|
341
|
+
- Vercel Edge Network
|
|
342
|
+
|
|
343
|
+
Static assets are served from `build/client/assets/` with cache headers.
|
|
344
|
+
|
|
345
|
+
## Updating in Production
|
|
346
|
+
|
|
347
|
+
When deploying updates:
|
|
348
|
+
|
|
349
|
+
1. Build the new version locally or in CI
|
|
350
|
+
2. Run database migrations if needed
|
|
351
|
+
3. Deploy the new build
|
|
352
|
+
4. Restart the server
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Example update script
|
|
356
|
+
pnpm build
|
|
357
|
+
pnpm db:migrate
|
|
358
|
+
# Deploy build/ to production
|
|
359
|
+
# Restart server
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
For zero-downtime deployments, use rolling updates with your platform's deployment strategy.
|