@digilogiclabs/create-saas-app 1.20.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +27 -388
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli/commands/create.d.ts +10 -0
  4. package/dist/cli/commands/create.d.ts.map +1 -1
  5. package/dist/cli/commands/create.js +10 -0
  6. package/dist/cli/commands/create.js.map +1 -1
  7. package/dist/cli/prompts/project-setup.d.ts.map +1 -1
  8. package/dist/cli/prompts/project-setup.js +72 -9
  9. package/dist/cli/prompts/project-setup.js.map +1 -1
  10. package/dist/generators/template-generator.d.ts +13 -1
  11. package/dist/generators/template-generator.d.ts.map +1 -1
  12. package/dist/generators/template-generator.js +155 -52
  13. package/dist/generators/template-generator.js.map +1 -1
  14. package/dist/templates/infrastructure/kubernetes/base/template/README.md +253 -0
  15. package/dist/templates/infrastructure/kubernetes/base/template/configmap.yaml +12 -0
  16. package/dist/templates/infrastructure/kubernetes/base/template/deployment.yaml +123 -0
  17. package/dist/templates/infrastructure/kubernetes/base/template/hpa.yaml +45 -0
  18. package/dist/templates/infrastructure/kubernetes/base/template/ingress.yaml +31 -0
  19. package/dist/templates/infrastructure/kubernetes/base/template/kustomization.yaml +25 -0
  20. package/dist/templates/infrastructure/kubernetes/base/template/namespace.yaml +8 -0
  21. package/dist/templates/infrastructure/kubernetes/base/template/networkpolicy.yaml +48 -0
  22. package/dist/templates/infrastructure/kubernetes/base/template/pdb.yaml +14 -0
  23. package/dist/templates/infrastructure/kubernetes/base/template/secret.yaml +17 -0
  24. package/dist/templates/infrastructure/kubernetes/base/template/service.yaml +19 -0
  25. package/dist/templates/infrastructure/kubernetes/base/template/serviceaccount.yaml +9 -0
  26. package/dist/templates/infrastructure/kubernetes/production/template/kustomization.yaml +92 -0
  27. package/dist/templates/infrastructure/terraform/aws/template/README.md +156 -0
  28. package/dist/templates/infrastructure/terraform/aws/template/main.tf +343 -0
  29. package/dist/templates/infrastructure/terraform/aws/template/outputs.tf +66 -0
  30. package/dist/templates/infrastructure/terraform/aws/template/terraform.tfvars.example +28 -0
  31. package/dist/templates/infrastructure/terraform/aws/template/variables.tf +110 -0
  32. package/dist/templates/infrastructure/terraform/gcp/template/README.md +165 -0
  33. package/dist/templates/infrastructure/terraform/gcp/template/main.tf +397 -0
  34. package/dist/templates/infrastructure/terraform/gcp/template/outputs.tf +51 -0
  35. package/dist/templates/infrastructure/terraform/gcp/template/terraform.tfvars.example +29 -0
  36. package/dist/templates/infrastructure/terraform/gcp/template/variables.tf +115 -0
  37. package/dist/templates/web/ai-platform/template/.env.example +16 -0
  38. package/dist/templates/web/ai-platform/template/README.md +84 -0
  39. package/dist/templates/web/ai-platform/template/middleware.ts +55 -0
  40. package/dist/templates/web/ai-platform/template/next.config.js +14 -0
  41. package/dist/templates/web/ai-platform/template/package.json +55 -0
  42. package/dist/templates/web/ai-platform/template/src/app/api/chat/route.ts +54 -0
  43. package/dist/templates/web/ai-platform/template/src/app/chat/page.tsx +235 -0
  44. package/dist/templates/web/ai-platform/template/src/app/dashboard/page.tsx +142 -0
  45. package/dist/templates/web/ai-platform/template/src/app/globals.css +34 -0
  46. package/dist/templates/web/ai-platform/template/src/app/layout.tsx +27 -0
  47. package/dist/templates/web/ai-platform/template/src/app/page.tsx +203 -0
  48. package/dist/templates/web/ai-platform/template/src/components/providers/app-providers.tsx +27 -0
  49. package/dist/templates/web/ai-platform/template/src/lib/auth-server.ts +33 -0
  50. package/dist/templates/web/ai-platform/template/src/lib/supabase/client.ts +8 -0
  51. package/dist/templates/web/ai-platform/template/src/lib/supabase/server.ts +27 -0
  52. package/dist/templates/web/ai-platform/template/src/lib/utils.ts +6 -0
  53. package/dist/templates/web/ai-platform/template/tsconfig.json +27 -0
  54. package/dist/templates/web/base/template/package.json +5 -4
  55. package/dist/templates/web/base/template/src/lib/platform.ts +146 -0
  56. package/dist/templates/web/iot-dashboard/template/.env.example +12 -0
  57. package/dist/templates/web/iot-dashboard/template/README.md +101 -0
  58. package/dist/templates/web/iot-dashboard/template/middleware.ts +56 -0
  59. package/dist/templates/web/iot-dashboard/template/next.config.js +14 -0
  60. package/dist/templates/web/iot-dashboard/template/package.json +49 -0
  61. package/dist/templates/web/iot-dashboard/template/src/app/dashboard/page.tsx +229 -0
  62. package/dist/templates/web/iot-dashboard/template/src/app/globals.css +20 -0
  63. package/dist/templates/web/iot-dashboard/template/src/app/layout.tsx +27 -0
  64. package/dist/templates/web/iot-dashboard/template/src/app/page.tsx +191 -0
  65. package/dist/templates/web/iot-dashboard/template/src/components/providers/app-providers.tsx +24 -0
  66. package/dist/templates/web/iot-dashboard/template/src/lib/auth-server.ts +33 -0
  67. package/dist/templates/web/iot-dashboard/template/src/lib/supabase/client.ts +8 -0
  68. package/dist/templates/web/iot-dashboard/template/src/lib/supabase/server.ts +27 -0
  69. package/dist/templates/web/iot-dashboard/template/src/lib/utils.ts +25 -0
  70. package/dist/templates/web/iot-dashboard/template/tsconfig.json +27 -0
  71. package/dist/templates/web/marketplace/template/.env.example +12 -0
  72. package/dist/templates/web/marketplace/template/README.md +66 -0
  73. package/dist/templates/web/marketplace/template/middleware.ts +56 -0
  74. package/dist/templates/web/marketplace/template/next.config.js +14 -0
  75. package/dist/templates/web/marketplace/template/package.json +51 -0
  76. package/dist/templates/web/marketplace/template/src/app/cart/page.tsx +147 -0
  77. package/dist/templates/web/marketplace/template/src/app/dashboard/page.tsx +149 -0
  78. package/dist/templates/web/marketplace/template/src/app/globals.css +20 -0
  79. package/dist/templates/web/marketplace/template/src/app/layout.tsx +27 -0
  80. package/dist/templates/web/marketplace/template/src/app/page.tsx +167 -0
  81. package/dist/templates/web/marketplace/template/src/app/products/page.tsx +129 -0
  82. package/dist/templates/web/marketplace/template/src/components/providers/app-providers.tsx +27 -0
  83. package/dist/templates/web/marketplace/template/src/lib/auth-server.ts +33 -0
  84. package/dist/templates/web/marketplace/template/src/lib/supabase/client.ts +8 -0
  85. package/dist/templates/web/marketplace/template/src/lib/supabase/server.ts +27 -0
  86. package/dist/templates/web/marketplace/template/src/lib/utils.ts +19 -0
  87. package/dist/templates/web/marketplace/template/tsconfig.json +27 -0
  88. package/dist/templates/web/micro-saas/template/.env.example +10 -0
  89. package/dist/templates/web/micro-saas/template/README.md +63 -0
  90. package/dist/templates/web/micro-saas/template/middleware.ts +53 -0
  91. package/dist/templates/web/micro-saas/template/next.config.js +14 -0
  92. package/dist/templates/web/micro-saas/template/package.json +41 -0
  93. package/dist/templates/web/micro-saas/template/src/app/dashboard/page.tsx +117 -0
  94. package/dist/templates/web/micro-saas/template/src/app/globals.css +20 -0
  95. package/dist/templates/web/micro-saas/template/src/app/layout.tsx +27 -0
  96. package/dist/templates/web/micro-saas/template/src/app/login/page.tsx +87 -0
  97. package/dist/templates/web/micro-saas/template/src/app/page.tsx +137 -0
  98. package/dist/templates/web/micro-saas/template/src/app/signup/page.tsx +108 -0
  99. package/dist/templates/web/micro-saas/template/src/components/providers/app-providers.tsx +24 -0
  100. package/dist/templates/web/micro-saas/template/src/lib/auth-server.ts +33 -0
  101. package/dist/templates/web/micro-saas/template/src/lib/supabase/client.ts +8 -0
  102. package/dist/templates/web/micro-saas/template/src/lib/supabase/server.ts +29 -0
  103. package/dist/templates/web/micro-saas/template/src/lib/utils.ts +6 -0
  104. package/dist/templates/web/micro-saas/template/tsconfig.json +27 -0
  105. package/dist/templates/web/ui-auth/template/package.json +4 -3
  106. package/dist/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
  107. package/dist/templates/web/ui-auth-payments/template/.env.example +51 -15
  108. package/dist/templates/web/ui-auth-payments/template/package.json +5 -4
  109. package/dist/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
  110. package/dist/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
  111. package/dist/templates/web/ui-auth-payments-ai/template/package.json +6 -5
  112. package/dist/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
  113. package/package.json +6 -6
  114. package/src/templates/infrastructure/kubernetes/base/template/README.md +253 -0
  115. package/src/templates/infrastructure/kubernetes/base/template/configmap.yaml +12 -0
  116. package/src/templates/infrastructure/kubernetes/base/template/deployment.yaml +123 -0
  117. package/src/templates/infrastructure/kubernetes/base/template/hpa.yaml +45 -0
  118. package/src/templates/infrastructure/kubernetes/base/template/ingress.yaml +31 -0
  119. package/src/templates/infrastructure/kubernetes/base/template/kustomization.yaml +25 -0
  120. package/src/templates/infrastructure/kubernetes/base/template/namespace.yaml +8 -0
  121. package/src/templates/infrastructure/kubernetes/base/template/networkpolicy.yaml +48 -0
  122. package/src/templates/infrastructure/kubernetes/base/template/pdb.yaml +14 -0
  123. package/src/templates/infrastructure/kubernetes/base/template/secret.yaml +17 -0
  124. package/src/templates/infrastructure/kubernetes/base/template/service.yaml +19 -0
  125. package/src/templates/infrastructure/kubernetes/base/template/serviceaccount.yaml +9 -0
  126. package/src/templates/infrastructure/kubernetes/production/template/kustomization.yaml +92 -0
  127. package/src/templates/infrastructure/terraform/aws/template/README.md +156 -0
  128. package/src/templates/infrastructure/terraform/aws/template/main.tf +343 -0
  129. package/src/templates/infrastructure/terraform/aws/template/outputs.tf +66 -0
  130. package/src/templates/infrastructure/terraform/aws/template/terraform.tfvars.example +28 -0
  131. package/src/templates/infrastructure/terraform/aws/template/variables.tf +110 -0
  132. package/src/templates/infrastructure/terraform/gcp/template/README.md +165 -0
  133. package/src/templates/infrastructure/terraform/gcp/template/main.tf +397 -0
  134. package/src/templates/infrastructure/terraform/gcp/template/outputs.tf +51 -0
  135. package/src/templates/infrastructure/terraform/gcp/template/terraform.tfvars.example +29 -0
  136. package/src/templates/infrastructure/terraform/gcp/template/variables.tf +115 -0
  137. package/src/templates/web/ai-platform/template/.env.example +16 -0
  138. package/src/templates/web/ai-platform/template/README.md +84 -0
  139. package/src/templates/web/ai-platform/template/middleware.ts +55 -0
  140. package/src/templates/web/ai-platform/template/next.config.js +14 -0
  141. package/src/templates/web/ai-platform/template/package.json +55 -0
  142. package/src/templates/web/ai-platform/template/src/app/api/chat/route.ts +54 -0
  143. package/src/templates/web/ai-platform/template/src/app/chat/page.tsx +235 -0
  144. package/src/templates/web/ai-platform/template/src/app/dashboard/page.tsx +142 -0
  145. package/src/templates/web/ai-platform/template/src/app/globals.css +34 -0
  146. package/src/templates/web/ai-platform/template/src/app/layout.tsx +27 -0
  147. package/src/templates/web/ai-platform/template/src/app/page.tsx +203 -0
  148. package/src/templates/web/ai-platform/template/src/components/providers/app-providers.tsx +27 -0
  149. package/src/templates/web/ai-platform/template/src/lib/auth-server.ts +33 -0
  150. package/src/templates/web/ai-platform/template/src/lib/supabase/client.ts +8 -0
  151. package/src/templates/web/ai-platform/template/src/lib/supabase/server.ts +27 -0
  152. package/src/templates/web/ai-platform/template/src/lib/utils.ts +6 -0
  153. package/src/templates/web/ai-platform/template/tsconfig.json +27 -0
  154. package/src/templates/web/base/template/package.json +5 -4
  155. package/src/templates/web/base/template/src/lib/platform.ts +146 -0
  156. package/src/templates/web/iot-dashboard/template/.env.example +12 -0
  157. package/src/templates/web/iot-dashboard/template/README.md +101 -0
  158. package/src/templates/web/iot-dashboard/template/middleware.ts +56 -0
  159. package/src/templates/web/iot-dashboard/template/next.config.js +14 -0
  160. package/src/templates/web/iot-dashboard/template/package.json +49 -0
  161. package/src/templates/web/iot-dashboard/template/src/app/dashboard/page.tsx +229 -0
  162. package/src/templates/web/iot-dashboard/template/src/app/globals.css +20 -0
  163. package/src/templates/web/iot-dashboard/template/src/app/layout.tsx +27 -0
  164. package/src/templates/web/iot-dashboard/template/src/app/page.tsx +191 -0
  165. package/src/templates/web/iot-dashboard/template/src/components/providers/app-providers.tsx +24 -0
  166. package/src/templates/web/iot-dashboard/template/src/lib/auth-server.ts +33 -0
  167. package/src/templates/web/iot-dashboard/template/src/lib/supabase/client.ts +8 -0
  168. package/src/templates/web/iot-dashboard/template/src/lib/supabase/server.ts +27 -0
  169. package/src/templates/web/iot-dashboard/template/src/lib/utils.ts +25 -0
  170. package/src/templates/web/iot-dashboard/template/tsconfig.json +27 -0
  171. package/src/templates/web/marketplace/template/.env.example +12 -0
  172. package/src/templates/web/marketplace/template/README.md +66 -0
  173. package/src/templates/web/marketplace/template/middleware.ts +56 -0
  174. package/src/templates/web/marketplace/template/next.config.js +14 -0
  175. package/src/templates/web/marketplace/template/package.json +51 -0
  176. package/src/templates/web/marketplace/template/src/app/cart/page.tsx +147 -0
  177. package/src/templates/web/marketplace/template/src/app/dashboard/page.tsx +149 -0
  178. package/src/templates/web/marketplace/template/src/app/globals.css +20 -0
  179. package/src/templates/web/marketplace/template/src/app/layout.tsx +27 -0
  180. package/src/templates/web/marketplace/template/src/app/page.tsx +167 -0
  181. package/src/templates/web/marketplace/template/src/app/products/page.tsx +129 -0
  182. package/src/templates/web/marketplace/template/src/components/providers/app-providers.tsx +27 -0
  183. package/src/templates/web/marketplace/template/src/lib/auth-server.ts +33 -0
  184. package/src/templates/web/marketplace/template/src/lib/supabase/client.ts +8 -0
  185. package/src/templates/web/marketplace/template/src/lib/supabase/server.ts +27 -0
  186. package/src/templates/web/marketplace/template/src/lib/utils.ts +19 -0
  187. package/src/templates/web/marketplace/template/tsconfig.json +27 -0
  188. package/src/templates/web/micro-saas/template/.env.example +10 -0
  189. package/src/templates/web/micro-saas/template/README.md +63 -0
  190. package/src/templates/web/micro-saas/template/middleware.ts +53 -0
  191. package/src/templates/web/micro-saas/template/next.config.js +14 -0
  192. package/src/templates/web/micro-saas/template/package.json +41 -0
  193. package/src/templates/web/micro-saas/template/src/app/dashboard/page.tsx +117 -0
  194. package/src/templates/web/micro-saas/template/src/app/globals.css +20 -0
  195. package/src/templates/web/micro-saas/template/src/app/layout.tsx +27 -0
  196. package/src/templates/web/micro-saas/template/src/app/login/page.tsx +87 -0
  197. package/src/templates/web/micro-saas/template/src/app/page.tsx +137 -0
  198. package/src/templates/web/micro-saas/template/src/app/signup/page.tsx +108 -0
  199. package/src/templates/web/micro-saas/template/src/components/providers/app-providers.tsx +24 -0
  200. package/src/templates/web/micro-saas/template/src/lib/auth-server.ts +33 -0
  201. package/src/templates/web/micro-saas/template/src/lib/supabase/client.ts +8 -0
  202. package/src/templates/web/micro-saas/template/src/lib/supabase/server.ts +29 -0
  203. package/src/templates/web/micro-saas/template/src/lib/utils.ts +6 -0
  204. package/src/templates/web/micro-saas/template/tsconfig.json +27 -0
  205. package/src/templates/web/ui-auth/template/package.json +4 -3
  206. package/src/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
  207. package/src/templates/web/ui-auth-payments/template/.env.example +51 -15
  208. package/src/templates/web/ui-auth-payments/template/package.json +5 -4
  209. package/src/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
  210. package/src/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
  211. package/src/templates/web/ui-auth-payments-ai/template/package.json +6 -5
  212. package/src/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
  213. package/bin/index.js +0 -36
@@ -0,0 +1,33 @@
1
+ import { redirect } from 'next/navigation'
2
+ import { createClient } from './supabase/server'
3
+
4
+ export interface AuthUser {
5
+ id: string
6
+ email: string | null
7
+ name?: string | null
8
+ }
9
+
10
+ export async function getUser(): Promise<AuthUser | null> {
11
+ const supabase = await createClient()
12
+ const { data: { user }, error } = await supabase.auth.getUser()
13
+
14
+ if (error || !user) {
15
+ return null
16
+ }
17
+
18
+ return {
19
+ id: user.id,
20
+ email: user.email ?? null,
21
+ name: user.user_metadata?.name ?? user.user_metadata?.full_name ?? null,
22
+ }
23
+ }
24
+
25
+ export async function requireAuth(): Promise<AuthUser> {
26
+ const user = await getUser()
27
+
28
+ if (!user) {
29
+ redirect('/login')
30
+ }
31
+
32
+ return user
33
+ }
@@ -0,0 +1,8 @@
1
+ import { createBrowserClient } from '@supabase/ssr'
2
+
3
+ export function createClient() {
4
+ return createBrowserClient(
5
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
6
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
7
+ )
8
+ }
@@ -0,0 +1,27 @@
1
+ import { createServerClient } from '@supabase/ssr'
2
+ import { cookies } from 'next/headers'
3
+
4
+ export async function createClient() {
5
+ const cookieStore = await cookies()
6
+
7
+ return createServerClient(
8
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
9
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
10
+ {
11
+ cookies: {
12
+ getAll() {
13
+ return cookieStore.getAll()
14
+ },
15
+ setAll(cookiesToSet) {
16
+ try {
17
+ cookiesToSet.forEach(({ name, value, options }) =>
18
+ cookieStore.set(name, value, options)
19
+ )
20
+ } catch {
21
+ // Server Component context
22
+ }
23
+ },
24
+ },
25
+ }
26
+ )
27
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from 'clsx'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./src/*"]
23
+ }
24
+ },
25
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
+ "exclude": ["node_modules"]
27
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "{{packageName}}",
3
3
  "version": "0.1.0",
4
- "description": "{{description}}",
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/saas-factory-ui": "^0.26.1",
21
- "@digilogiclabs/saas-factory-auth": "^1.0.3",
22
- "@digilogiclabs/saas-factory-payments": "^1.2.0",
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
  "tailwindcss": "^3.3.0",
24
25
  "autoprefixer": "^10.4.16",
25
26
  "postcss": "^8.4.31",
@@ -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
+ */
@@ -0,0 +1,12 @@
1
+ # Supabase Configuration
2
+ NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
3
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
4
+ SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
5
+
6
+ # MQTT Configuration (optional)
7
+ MQTT_BROKER_URL=mqtt://localhost:1883
8
+ MQTT_USERNAME=
9
+ MQTT_PASSWORD=
10
+
11
+ # Application
12
+ NEXT_PUBLIC_APP_URL=http://localhost:3000
@@ -0,0 +1,101 @@
1
+ # {{titleCaseName}}
2
+
3
+ {{description}} - An IoT device monitoring and management dashboard.
4
+
5
+ ## Features
6
+
7
+ - **Device Management** - Monitor and control all your IoT devices
8
+ - **Real-time Telemetry** - Live data streams with updates every few seconds
9
+ - **Smart Alerts** - Configurable notifications for critical events
10
+ - **Analytics** - Historical data analysis and trends
11
+ - **Responsive Design** - Works on desktop and mobile
12
+
13
+ ## Quick Start
14
+
15
+ 1. **Install dependencies:**
16
+ ```bash
17
+ npm install
18
+ ```
19
+
20
+ 2. **Set up environment variables:**
21
+ ```bash
22
+ cp .env.example .env.local
23
+ ```
24
+ Update with your Supabase credentials.
25
+
26
+ 3. **Run the development server:**
27
+ ```bash
28
+ npm run dev
29
+ ```
30
+
31
+ 4. **Open [http://localhost:3000](http://localhost:3000)**
32
+
33
+ ## Tech Stack
34
+
35
+ - **Framework:** Next.js 15
36
+ - **Language:** TypeScript
37
+ - **Styling:** Tailwind CSS
38
+ - **Auth:** Supabase
39
+ - **Charts:** Recharts
40
+ - **UI Components:** @digilogiclabs/saas-factory-ui
41
+
42
+ ## Project Structure
43
+
44
+ ```
45
+ src/
46
+ ├── app/ # Next.js App Router pages
47
+ │ ├── dashboard/ # Main IoT dashboard
48
+ │ ├── devices/ # Device management
49
+ │ ├── analytics/ # Data analytics
50
+ │ └── alerts/ # Alert management
51
+ ├── components/ # React components
52
+ │ ├── iot/ # IoT-specific components
53
+ │ └── providers/ # Context providers
54
+ └── lib/ # Utilities and helpers
55
+ ```
56
+
57
+ ## Database Schema
58
+
59
+ Set up the following tables in Supabase:
60
+
61
+ ```sql
62
+ -- Devices table
63
+ create table devices (
64
+ id uuid primary key default gen_random_uuid(),
65
+ name text not null,
66
+ type text not null,
67
+ status text default 'offline',
68
+ last_seen timestamp with time zone,
69
+ metadata jsonb default '{}',
70
+ user_id uuid references auth.users(id),
71
+ created_at timestamp with time zone default now()
72
+ );
73
+
74
+ -- Telemetry table
75
+ create table telemetry (
76
+ id uuid primary key default gen_random_uuid(),
77
+ device_id uuid references devices(id),
78
+ data jsonb not null,
79
+ timestamp timestamp with time zone default now()
80
+ );
81
+
82
+ -- Alerts table
83
+ create table alerts (
84
+ id uuid primary key default gen_random_uuid(),
85
+ device_id uuid references devices(id),
86
+ message text not null,
87
+ severity text not null,
88
+ acknowledged boolean default false,
89
+ created_at timestamp with time zone default now()
90
+ );
91
+ ```
92
+
93
+ ## Deployment
94
+
95
+ Deploy to Vercel with one click:
96
+
97
+ [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new)
98
+
99
+ ## License
100
+
101
+ MIT - Built with DLL Platform
@@ -0,0 +1,56 @@
1
+ import { createServerClient } from '@supabase/ssr'
2
+ import { NextResponse, type NextRequest } from 'next/server'
3
+
4
+ export async function middleware(request: NextRequest) {
5
+ let supabaseResponse = NextResponse.next({
6
+ request,
7
+ })
8
+
9
+ const supabase = createServerClient(
10
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
11
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
12
+ {
13
+ cookies: {
14
+ getAll() {
15
+ return request.cookies.getAll()
16
+ },
17
+ setAll(cookiesToSet) {
18
+ cookiesToSet.forEach(({ name, value }) =>
19
+ request.cookies.set(name, value)
20
+ )
21
+ supabaseResponse = NextResponse.next({
22
+ request,
23
+ })
24
+ cookiesToSet.forEach(({ name, value, options }) =>
25
+ supabaseResponse.cookies.set(name, value, options)
26
+ )
27
+ },
28
+ },
29
+ }
30
+ )
31
+
32
+ const {
33
+ data: { user },
34
+ } = await supabase.auth.getUser()
35
+
36
+ // Redirect to login if accessing protected route without auth
37
+ if (
38
+ !user &&
39
+ (request.nextUrl.pathname.startsWith('/dashboard') ||
40
+ request.nextUrl.pathname.startsWith('/devices') ||
41
+ request.nextUrl.pathname.startsWith('/analytics') ||
42
+ request.nextUrl.pathname.startsWith('/alerts'))
43
+ ) {
44
+ const url = request.nextUrl.clone()
45
+ url.pathname = '/login'
46
+ return NextResponse.redirect(url)
47
+ }
48
+
49
+ return supabaseResponse
50
+ }
51
+
52
+ export const config = {
53
+ matcher: [
54
+ '/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
55
+ ],
56
+ }
@@ -0,0 +1,14 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ reactStrictMode: true,
4
+ images: {
5
+ remotePatterns: [
6
+ {
7
+ protocol: 'https',
8
+ hostname: '**.supabase.co',
9
+ },
10
+ ],
11
+ },
12
+ }
13
+
14
+ module.exports = nextConfig
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "{{packageName}}",
3
+ "version": "0.1.0",
4
+ "description": "{{description}} - IoT Dashboard",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "next dev",
8
+ "build": "next build",
9
+ "start": "next start",
10
+ "lint": "next lint",
11
+ "type-check": "tsc --noEmit",
12
+ "test": "vitest",
13
+ "test:run": "vitest run"
14
+ },
15
+ "dependencies": {
16
+ "next": "^15.0.0",
17
+ "react": "^19.0.0",
18
+ "react-dom": "^19.0.0",
19
+ "@digilogiclabs/platform-core": "^1.1.0",
20
+ "@digilogiclabs/app-sdk": "^1.0.0",
21
+ "@digilogiclabs/saas-factory-auth": "^1.0.7",
22
+ "@digilogiclabs/saas-factory-ui": "^1.0.1",
23
+ "tailwindcss": "^4.0.0",
24
+ "clsx": "^2.0.0",
25
+ "class-variance-authority": "^0.7.0",
26
+ "tailwind-merge": "^2.0.0",
27
+ "next-themes": "^0.4.0",
28
+ "lucide-react": "^0.460.0",
29
+ "zod": "^3.22.4",
30
+ "zustand": "^4.5.0",
31
+ "recharts": "^2.13.0",
32
+ "date-fns": "^4.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "^5.7.0",
36
+ "@types/node": "^22.0.0",
37
+ "@types/react": "^19.0.0",
38
+ "@types/react-dom": "^19.0.0",
39
+ "eslint": "^9.0.0",
40
+ "eslint-config-next": "^15.0.0",
41
+ "prettier": "^3.4.0",
42
+ "vitest": "^2.1.0",
43
+ "@testing-library/react": "^16.0.0",
44
+ "@testing-library/jest-dom": "^6.6.0"
45
+ },
46
+ "engines": {
47
+ "node": ">=20.0.0"
48
+ }
49
+ }