@digilogiclabs/create-saas-app 1.20.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -388
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/commands/create.d.ts +10 -0
- package/dist/cli/commands/create.d.ts.map +1 -1
- package/dist/cli/commands/create.js +10 -0
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/prompts/project-setup.d.ts.map +1 -1
- package/dist/cli/prompts/project-setup.js +28 -0
- package/dist/cli/prompts/project-setup.js.map +1 -1
- package/dist/generators/template-generator.d.ts +13 -1
- package/dist/generators/template-generator.d.ts.map +1 -1
- package/dist/generators/template-generator.js +128 -52
- package/dist/generators/template-generator.js.map +1 -1
- package/dist/templates/web/base/template/package.json +5 -4
- package/dist/templates/web/base/template/src/lib/platform.ts +146 -0
- package/dist/templates/web/ui-auth/template/package.json +4 -3
- package/dist/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
- package/dist/templates/web/ui-auth-payments/template/.env.example +51 -15
- package/dist/templates/web/ui-auth-payments/template/package.json +5 -4
- package/dist/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
- package/dist/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
- package/dist/templates/web/ui-auth-payments-ai/template/package.json +6 -5
- package/dist/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
- package/package.json +6 -6
- package/src/templates/web/base/template/package.json +5 -4
- package/src/templates/web/base/template/src/lib/platform.ts +146 -0
- package/src/templates/web/ui-auth/template/package.json +4 -3
- package/src/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
- package/src/templates/web/ui-auth-payments/template/.env.example +51 -15
- package/src/templates/web/ui-auth-payments/template/package.json +5 -4
- package/src/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
- package/src/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
- package/src/templates/web/ui-auth-payments-ai/template/package.json +6 -5
- package/src/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
- package/bin/index.js +0 -36
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Core Integration
|
|
3
|
+
*
|
|
4
|
+
* This file sets up the @digilogiclabs/platform-core integration for
|
|
5
|
+
* unified infrastructure services across your application.
|
|
6
|
+
*
|
|
7
|
+
* Platform-core provides:
|
|
8
|
+
* - Database abstraction (Supabase, PostgreSQL)
|
|
9
|
+
* - Cache abstraction (Redis, Upstash, Memory)
|
|
10
|
+
* - Storage abstraction (S3, MinIO, R2)
|
|
11
|
+
* - Email abstraction (Resend, SMTP)
|
|
12
|
+
* - Queue abstraction (BullMQ)
|
|
13
|
+
* - Logging and Metrics
|
|
14
|
+
* - Resilience patterns (retry, circuit breaker, timeout)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createPlatform, createPlatformAsync, type IPlatform } from '@digilogiclabs/platform-core';
|
|
18
|
+
import { setPlatform as setAuthPlatform } from '@digilogiclabs/saas-factory-auth';
|
|
19
|
+
import { setPlatform as setPaymentsPlatform } from '@digilogiclabs/saas-factory-payments';
|
|
20
|
+
|
|
21
|
+
// Singleton platform instance
|
|
22
|
+
let platformInstance: IPlatform | null = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the platform instance (creates a new one if needed)
|
|
26
|
+
*
|
|
27
|
+
* For testing or development without external services,
|
|
28
|
+
* this uses in-memory adapters.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const platform = getPlatform();
|
|
33
|
+
* await platform.cache.set('key', 'value', 3600);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function getPlatform(): IPlatform {
|
|
37
|
+
if (!platformInstance) {
|
|
38
|
+
platformInstance = createPlatform();
|
|
39
|
+
initializePackageIntegrations(platformInstance);
|
|
40
|
+
}
|
|
41
|
+
return platformInstance;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Initialize platform with production adapters (async)
|
|
46
|
+
*
|
|
47
|
+
* Call this once at application startup to configure
|
|
48
|
+
* production services based on environment variables.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // In app/layout.tsx or a server initialization file
|
|
53
|
+
* await initializePlatform();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export async function initializePlatform(): Promise<IPlatform> {
|
|
57
|
+
if (platformInstance) {
|
|
58
|
+
return platformInstance;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Use createPlatformAsync for production adapters
|
|
62
|
+
// Falls back to memory adapters if env vars are not set
|
|
63
|
+
platformInstance = await createPlatformAsync();
|
|
64
|
+
initializePackageIntegrations(platformInstance);
|
|
65
|
+
|
|
66
|
+
return platformInstance;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initialize package integrations with platform services
|
|
71
|
+
*/
|
|
72
|
+
function initializePackageIntegrations(platform: IPlatform): void {
|
|
73
|
+
// Connect saas-factory-auth to platform-core
|
|
74
|
+
// Enables: logging, metrics, and email for auth events
|
|
75
|
+
setAuthPlatform({
|
|
76
|
+
email: platform.email,
|
|
77
|
+
logger: platform.logger,
|
|
78
|
+
metrics: platform.metrics,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Connect saas-factory-payments to platform-core
|
|
82
|
+
// Enables: logging, metrics, and caching for payment events
|
|
83
|
+
setPaymentsPlatform({
|
|
84
|
+
logger: platform.logger,
|
|
85
|
+
metrics: platform.metrics,
|
|
86
|
+
cache: platform.cache,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reset platform instance (useful for testing)
|
|
92
|
+
*/
|
|
93
|
+
export function resetPlatform(): void {
|
|
94
|
+
platformInstance = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Example: Using platform services
|
|
99
|
+
*
|
|
100
|
+
* Database:
|
|
101
|
+
* ```ts
|
|
102
|
+
* const users = await platform.db
|
|
103
|
+
* .from('users')
|
|
104
|
+
* .where('active', '=', true)
|
|
105
|
+
* .execute();
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* Cache:
|
|
109
|
+
* ```ts
|
|
110
|
+
* await platform.cache.set('user:123', userData, 3600);
|
|
111
|
+
* const cached = await platform.cache.get<User>('user:123');
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* Storage:
|
|
115
|
+
* ```ts
|
|
116
|
+
* await platform.storage.upload('avatars/user-123.png', buffer, {
|
|
117
|
+
* contentType: 'image/png',
|
|
118
|
+
* public: true,
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* Email:
|
|
123
|
+
* ```ts
|
|
124
|
+
* await platform.email.send({
|
|
125
|
+
* to: { email: 'user@example.com', name: 'John' },
|
|
126
|
+
* subject: 'Welcome!',
|
|
127
|
+
* html: '<h1>Welcome to {{titleCaseName}}</h1>',
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Queue:
|
|
132
|
+
* ```ts
|
|
133
|
+
* await platform.queue.add('sendWelcomeEmail', { userId: '123' });
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* Logging:
|
|
137
|
+
* ```ts
|
|
138
|
+
* platform.logger.info('User signed up', { userId: '123' });
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* Metrics:
|
|
142
|
+
* ```ts
|
|
143
|
+
* platform.metrics.increment('user.signup');
|
|
144
|
+
* platform.metrics.timing('api.response_time', 150);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{packageName}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
|
-
"description": "{{description}} (with
|
|
4
|
+
"description": "{{description}} (with Platform Core + UI + Auth)",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "next dev",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"next": "^15.0.0",
|
|
18
18
|
"react": "^19.0.0",
|
|
19
19
|
"react-dom": "^19.0.0",
|
|
20
|
-
"@digilogiclabs/
|
|
21
|
-
"@digilogiclabs/saas-factory-
|
|
20
|
+
"@digilogiclabs/platform-core": "^0.1.0",
|
|
21
|
+
"@digilogiclabs/saas-factory-ui": "^0.27.3",
|
|
22
|
+
"@digilogiclabs/saas-factory-auth": "^1.0.6",
|
|
22
23
|
"tailwindcss": "^3.3.0",
|
|
23
24
|
"autoprefixer": "^10.4.16",
|
|
24
25
|
"postcss": "^8.4.31",
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Core Integration
|
|
3
|
+
*
|
|
4
|
+
* This file sets up the @digilogiclabs/platform-core integration for
|
|
5
|
+
* unified infrastructure services across your application.
|
|
6
|
+
*
|
|
7
|
+
* Platform-core provides:
|
|
8
|
+
* - Database abstraction (Supabase, PostgreSQL)
|
|
9
|
+
* - Cache abstraction (Redis, Upstash, Memory)
|
|
10
|
+
* - Storage abstraction (S3, MinIO, R2)
|
|
11
|
+
* - Email abstraction (Resend, SMTP)
|
|
12
|
+
* - Queue abstraction (BullMQ)
|
|
13
|
+
* - Logging and Metrics
|
|
14
|
+
* - Resilience patterns (retry, circuit breaker, timeout)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createPlatform, createPlatformAsync, type IPlatform } from '@digilogiclabs/platform-core';
|
|
18
|
+
import { setPlatform as setAuthPlatform } from '@digilogiclabs/saas-factory-auth';
|
|
19
|
+
|
|
20
|
+
// Singleton platform instance
|
|
21
|
+
let platformInstance: IPlatform | null = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the platform instance (creates a new one if needed)
|
|
25
|
+
*
|
|
26
|
+
* For testing or development without external services,
|
|
27
|
+
* this uses in-memory adapters.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const platform = getPlatform();
|
|
32
|
+
* await platform.cache.set('key', 'value', 3600);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function getPlatform(): IPlatform {
|
|
36
|
+
if (!platformInstance) {
|
|
37
|
+
platformInstance = createPlatform();
|
|
38
|
+
initializePackageIntegrations(platformInstance);
|
|
39
|
+
}
|
|
40
|
+
return platformInstance;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Initialize platform with production adapters (async)
|
|
45
|
+
*
|
|
46
|
+
* Call this once at application startup to configure
|
|
47
|
+
* production services based on environment variables.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* // In app/layout.tsx or a server initialization file
|
|
52
|
+
* await initializePlatform();
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export async function initializePlatform(): Promise<IPlatform> {
|
|
56
|
+
if (platformInstance) {
|
|
57
|
+
return platformInstance;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Use createPlatformAsync for production adapters
|
|
61
|
+
// Falls back to memory adapters if env vars are not set
|
|
62
|
+
platformInstance = await createPlatformAsync();
|
|
63
|
+
initializePackageIntegrations(platformInstance);
|
|
64
|
+
|
|
65
|
+
return platformInstance;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Initialize package integrations with platform services
|
|
70
|
+
*/
|
|
71
|
+
function initializePackageIntegrations(platform: IPlatform): void {
|
|
72
|
+
// Connect saas-factory-auth to platform-core
|
|
73
|
+
// Enables: logging, metrics, and email for auth events
|
|
74
|
+
setAuthPlatform({
|
|
75
|
+
email: platform.email,
|
|
76
|
+
logger: platform.logger,
|
|
77
|
+
metrics: platform.metrics,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Reset platform instance (useful for testing)
|
|
83
|
+
*/
|
|
84
|
+
export function resetPlatform(): void {
|
|
85
|
+
platformInstance = null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Example: Using platform services
|
|
90
|
+
*
|
|
91
|
+
* Database:
|
|
92
|
+
* ```ts
|
|
93
|
+
* const users = await platform.db
|
|
94
|
+
* .from('users')
|
|
95
|
+
* .where('active', '=', true)
|
|
96
|
+
* .execute();
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* Cache:
|
|
100
|
+
* ```ts
|
|
101
|
+
* await platform.cache.set('user:123', userData, 3600);
|
|
102
|
+
* const cached = await platform.cache.get<User>('user:123');
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* Storage:
|
|
106
|
+
* ```ts
|
|
107
|
+
* await platform.storage.upload('avatars/user-123.png', buffer, {
|
|
108
|
+
* contentType: 'image/png',
|
|
109
|
+
* public: true,
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* Email:
|
|
114
|
+
* ```ts
|
|
115
|
+
* await platform.email.send({
|
|
116
|
+
* to: { email: 'user@example.com', name: 'John' },
|
|
117
|
+
* subject: 'Welcome!',
|
|
118
|
+
* html: '<h1>Welcome to {{titleCaseName}}</h1>',
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* Queue:
|
|
123
|
+
* ```ts
|
|
124
|
+
* await platform.queue.add('sendWelcomeEmail', { userId: '123' });
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* Logging:
|
|
128
|
+
* ```ts
|
|
129
|
+
* platform.logger.info('User signed up', { userId: '123' });
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* Metrics:
|
|
133
|
+
* ```ts
|
|
134
|
+
* platform.metrics.increment('user.signup');
|
|
135
|
+
* platform.metrics.timing('api.response_time', 150);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
@@ -1,15 +1,51 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# ═══════════════════════════════════════════════════════════════
|
|
2
|
+
# Auth Configuration
|
|
3
|
+
# ═══════════════════════════════════════════════════════════════
|
|
4
|
+
NEXT_PUBLIC_AUTH_PROVIDER=supabase|firebase
|
|
5
|
+
|
|
6
|
+
# Supabase
|
|
7
|
+
NEXT_PUBLIC_SUPABASE_URL=
|
|
8
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
|
9
|
+
SUPABASE_SERVICE_ROLE_KEY=
|
|
10
|
+
|
|
11
|
+
# Firebase
|
|
12
|
+
NEXT_PUBLIC_FIREBASE_API_KEY=
|
|
13
|
+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
|
|
14
|
+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
|
|
15
|
+
|
|
16
|
+
# ═══════════════════════════════════════════════════════════════
|
|
17
|
+
# Payments (Stripe)
|
|
18
|
+
# ═══════════════════════════════════════════════════════════════
|
|
19
|
+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
|
|
20
|
+
STRIPE_SECRET_KEY=
|
|
21
|
+
STRIPE_WEBHOOK_SECRET=
|
|
22
|
+
|
|
23
|
+
# ═══════════════════════════════════════════════════════════════
|
|
24
|
+
# Platform Core - Infrastructure Services (Optional)
|
|
25
|
+
# Configure these for production. Memory adapters used if not set.
|
|
26
|
+
# ═══════════════════════════════════════════════════════════════
|
|
27
|
+
|
|
28
|
+
# Cache (Upstash Redis)
|
|
29
|
+
UPSTASH_REDIS_REST_URL=
|
|
30
|
+
UPSTASH_REDIS_REST_TOKEN=
|
|
31
|
+
|
|
32
|
+
# Storage (S3-compatible: AWS S3, MinIO, Cloudflare R2)
|
|
33
|
+
S3_ENDPOINT=
|
|
34
|
+
S3_REGION=
|
|
35
|
+
S3_ACCESS_KEY_ID=
|
|
36
|
+
S3_SECRET_ACCESS_KEY=
|
|
37
|
+
S3_BUCKET=
|
|
38
|
+
|
|
39
|
+
# Email (Resend)
|
|
40
|
+
RESEND_API_KEY=
|
|
41
|
+
EMAIL_FROM=noreply@example.com
|
|
42
|
+
|
|
43
|
+
# Queue (BullMQ - requires Redis)
|
|
44
|
+
REDIS_URL=redis://localhost:6379
|
|
45
|
+
|
|
46
|
+
# ═══════════════════════════════════════════════════════════════
|
|
47
|
+
# Application
|
|
48
|
+
# ═══════════════════════════════════════════════════════════════
|
|
49
|
+
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
50
|
+
NEXT_PUBLIC_APP_NAME={{titleCaseName}}
|
|
51
|
+
NODE_ENV=development
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{packageName}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
|
-
"description": "{{description}} (with
|
|
4
|
+
"description": "{{description}} (with Platform Core + UI + Auth + Payments)",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "next dev",
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"next": "^15.0.0",
|
|
18
18
|
"react": "^19.0.0",
|
|
19
19
|
"react-dom": "^19.0.0",
|
|
20
|
-
"@digilogiclabs/
|
|
21
|
-
"@digilogiclabs/saas-factory-
|
|
22
|
-
"@digilogiclabs/saas-factory-
|
|
20
|
+
"@digilogiclabs/platform-core": "^0.1.0",
|
|
21
|
+
"@digilogiclabs/saas-factory-ui": "^0.27.3",
|
|
22
|
+
"@digilogiclabs/saas-factory-auth": "^1.0.6",
|
|
23
|
+
"@digilogiclabs/saas-factory-payments": "^1.2.8",
|
|
23
24
|
"stripe": "^14.0.0",
|
|
24
25
|
"@stripe/react-stripe-js": "^2.0.0",
|
|
25
26
|
"@stripe/stripe-js": "^2.0.0",
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Core Integration
|
|
3
|
+
*
|
|
4
|
+
* This file sets up the @digilogiclabs/platform-core integration for
|
|
5
|
+
* unified infrastructure services across your application.
|
|
6
|
+
*
|
|
7
|
+
* Platform-core provides:
|
|
8
|
+
* - Database abstraction (Supabase, PostgreSQL)
|
|
9
|
+
* - Cache abstraction (Redis, Upstash, Memory)
|
|
10
|
+
* - Storage abstraction (S3, MinIO, R2)
|
|
11
|
+
* - Email abstraction (Resend, SMTP)
|
|
12
|
+
* - Queue abstraction (BullMQ)
|
|
13
|
+
* - Logging and Metrics
|
|
14
|
+
* - Resilience patterns (retry, circuit breaker, timeout)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createPlatform, createPlatformAsync, type IPlatform } from '@digilogiclabs/platform-core';
|
|
18
|
+
import { setPlatform as setAuthPlatform } from '@digilogiclabs/saas-factory-auth';
|
|
19
|
+
import { setPlatform as setPaymentsPlatform } from '@digilogiclabs/saas-factory-payments';
|
|
20
|
+
|
|
21
|
+
// Singleton platform instance
|
|
22
|
+
let platformInstance: IPlatform | null = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the platform instance (creates a new one if needed)
|
|
26
|
+
*
|
|
27
|
+
* For testing or development without external services,
|
|
28
|
+
* this uses in-memory adapters.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const platform = getPlatform();
|
|
33
|
+
* await platform.cache.set('key', 'value', 3600);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function getPlatform(): IPlatform {
|
|
37
|
+
if (!platformInstance) {
|
|
38
|
+
platformInstance = createPlatform();
|
|
39
|
+
initializePackageIntegrations(platformInstance);
|
|
40
|
+
}
|
|
41
|
+
return platformInstance;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Initialize platform with production adapters (async)
|
|
46
|
+
*
|
|
47
|
+
* Call this once at application startup to configure
|
|
48
|
+
* production services based on environment variables.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // In app/layout.tsx or a server initialization file
|
|
53
|
+
* await initializePlatform();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export async function initializePlatform(): Promise<IPlatform> {
|
|
57
|
+
if (platformInstance) {
|
|
58
|
+
return platformInstance;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Use createPlatformAsync for production adapters
|
|
62
|
+
// Falls back to memory adapters if env vars are not set
|
|
63
|
+
platformInstance = await createPlatformAsync();
|
|
64
|
+
initializePackageIntegrations(platformInstance);
|
|
65
|
+
|
|
66
|
+
return platformInstance;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initialize package integrations with platform services
|
|
71
|
+
*/
|
|
72
|
+
function initializePackageIntegrations(platform: IPlatform): void {
|
|
73
|
+
// Connect saas-factory-auth to platform-core
|
|
74
|
+
// Enables: logging, metrics, and email for auth events
|
|
75
|
+
setAuthPlatform({
|
|
76
|
+
email: platform.email,
|
|
77
|
+
logger: platform.logger,
|
|
78
|
+
metrics: platform.metrics,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Connect saas-factory-payments to platform-core
|
|
82
|
+
// Enables: logging, metrics, and caching for payment events
|
|
83
|
+
setPaymentsPlatform({
|
|
84
|
+
logger: platform.logger,
|
|
85
|
+
metrics: platform.metrics,
|
|
86
|
+
cache: platform.cache,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reset platform instance (useful for testing)
|
|
92
|
+
*/
|
|
93
|
+
export function resetPlatform(): void {
|
|
94
|
+
platformInstance = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Example: Using platform services
|
|
99
|
+
*
|
|
100
|
+
* Database:
|
|
101
|
+
* ```ts
|
|
102
|
+
* const users = await platform.db
|
|
103
|
+
* .from('users')
|
|
104
|
+
* .where('active', '=', true)
|
|
105
|
+
* .execute();
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* Cache:
|
|
109
|
+
* ```ts
|
|
110
|
+
* await platform.cache.set('user:123', userData, 3600);
|
|
111
|
+
* const cached = await platform.cache.get<User>('user:123');
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* Storage:
|
|
115
|
+
* ```ts
|
|
116
|
+
* await platform.storage.upload('avatars/user-123.png', buffer, {
|
|
117
|
+
* contentType: 'image/png',
|
|
118
|
+
* public: true,
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* Email:
|
|
123
|
+
* ```ts
|
|
124
|
+
* await platform.email.send({
|
|
125
|
+
* to: { email: 'user@example.com', name: 'John' },
|
|
126
|
+
* subject: 'Welcome!',
|
|
127
|
+
* html: '<h1>Welcome to {{titleCaseName}}</h1>',
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Queue:
|
|
132
|
+
* ```ts
|
|
133
|
+
* await platform.queue.add('sendWelcomeEmail', { userId: '123' });
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* Logging:
|
|
137
|
+
* ```ts
|
|
138
|
+
* platform.logger.info('User signed up', { userId: '123' });
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* Metrics:
|
|
142
|
+
* ```ts
|
|
143
|
+
* platform.metrics.increment('user.signup');
|
|
144
|
+
* platform.metrics.timing('api.response_time', 150);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
@@ -1,22 +1,60 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
# ═══════════════════════════════════════════════════════════════
|
|
2
|
+
# Auth Configuration
|
|
3
|
+
# ═══════════════════════════════════════════════════════════════
|
|
4
|
+
NEXT_PUBLIC_AUTH_PROVIDER=supabase|firebase
|
|
5
|
+
|
|
6
|
+
# Supabase
|
|
7
|
+
NEXT_PUBLIC_SUPABASE_URL=
|
|
8
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
|
9
|
+
SUPABASE_SERVICE_ROLE_KEY=
|
|
10
|
+
|
|
11
|
+
# Firebase
|
|
12
|
+
NEXT_PUBLIC_FIREBASE_API_KEY=
|
|
13
|
+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
|
|
14
|
+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
|
|
15
|
+
|
|
16
|
+
# ═══════════════════════════════════════════════════════════════
|
|
17
|
+
# Payments (Stripe)
|
|
18
|
+
# ═══════════════════════════════════════════════════════════════
|
|
19
|
+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
|
|
20
|
+
STRIPE_SECRET_KEY=
|
|
21
|
+
STRIPE_WEBHOOK_SECRET=
|
|
22
|
+
|
|
23
|
+
# ═══════════════════════════════════════════════════════════════
|
|
24
|
+
# AI Providers
|
|
25
|
+
# ═══════════════════════════════════════════════════════════════
|
|
26
|
+
OPENAI_API_KEY=
|
|
27
|
+
ANTHROPIC_API_KEY=
|
|
28
|
+
GOOGLE_AI_API_KEY=
|
|
29
|
+
ELEVENLABS_API_KEY=
|
|
30
|
+
REPLICATE_API_TOKEN=
|
|
31
|
+
|
|
32
|
+
# ═══════════════════════════════════════════════════════════════
|
|
33
|
+
# Platform Core - Infrastructure Services (Optional)
|
|
34
|
+
# Configure these for production. Memory adapters used if not set.
|
|
35
|
+
# ═══════════════════════════════════════════════════════════════
|
|
36
|
+
|
|
37
|
+
# Cache (Upstash Redis - great for AI response caching)
|
|
38
|
+
UPSTASH_REDIS_REST_URL=
|
|
39
|
+
UPSTASH_REDIS_REST_TOKEN=
|
|
40
|
+
|
|
41
|
+
# Storage (S3-compatible: AWS S3, MinIO, Cloudflare R2)
|
|
42
|
+
S3_ENDPOINT=
|
|
43
|
+
S3_REGION=
|
|
44
|
+
S3_ACCESS_KEY_ID=
|
|
45
|
+
S3_SECRET_ACCESS_KEY=
|
|
46
|
+
S3_BUCKET=
|
|
47
|
+
|
|
48
|
+
# Email (Resend)
|
|
49
|
+
RESEND_API_KEY=
|
|
50
|
+
EMAIL_FROM=noreply@example.com
|
|
51
|
+
|
|
52
|
+
# Queue (BullMQ - for AI background processing)
|
|
53
|
+
REDIS_URL=redis://localhost:6379
|
|
54
|
+
|
|
55
|
+
# ═══════════════════════════════════════════════════════════════
|
|
56
|
+
# Application
|
|
57
|
+
# ═══════════════════════════════════════════════════════════════
|
|
58
|
+
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
59
|
+
NEXT_PUBLIC_APP_NAME={{titleCaseName}}
|
|
60
|
+
NODE_ENV=development
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{packageName}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
|
-
"description": "{{description}} - Full-Stack AI Platform (with
|
|
4
|
+
"description": "{{description}} - Full-Stack AI Platform (with Platform Core + UI + Auth + Payments + AI)",
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "next dev",
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
"next": "^15.0.0",
|
|
18
18
|
"react": "^19.0.0",
|
|
19
19
|
"react-dom": "^19.0.0",
|
|
20
|
-
"@digilogiclabs/
|
|
21
|
-
"@digilogiclabs/saas-factory-
|
|
22
|
-
"@digilogiclabs/saas-factory-
|
|
23
|
-
"@digilogiclabs/saas-factory-
|
|
20
|
+
"@digilogiclabs/platform-core": "^0.1.0",
|
|
21
|
+
"@digilogiclabs/saas-factory-ui": "^0.27.3",
|
|
22
|
+
"@digilogiclabs/saas-factory-auth": "^1.0.6",
|
|
23
|
+
"@digilogiclabs/saas-factory-payments": "^1.2.8",
|
|
24
|
+
"@digilogiclabs/saas-factory-ai": "^4.0.4",
|
|
24
25
|
"stripe": "^14.0.0",
|
|
25
26
|
"@stripe/react-stripe-js": "^2.0.0",
|
|
26
27
|
"@stripe/stripe-js": "^2.0.0",
|