@terreno/mcp 0.31.0 → 56.0.0-beta.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 (209) hide show
  1. package/dist/bootstrap.d.ts.map +1 -1
  2. package/dist/bootstrap.js +15 -16
  3. package/dist/bootstrap.js.map +1 -1
  4. package/dist/docs/templates/bootstrap/backend/types/models/userTypes.template.md +4 -5
  5. package/dist/docs/templates/bootstrap/frontend/app/_layout.template.tsx +1 -1
  6. package/dist/docs/templates/tools/model.template.md +2 -4
  7. package/dist/docs/versioned/next/README.md +1 -0
  8. package/dist/docs/versioned/next/explanation/README.md +1 -7
  9. package/dist/docs/versioned/next/how-to/README.md +2 -8
  10. package/dist/docs/versioned/next/how-to/deploy-to-gcp.md +228 -20
  11. package/dist/docs/versioned/next/how-to/migrate-rtk-to-syncdb.md +445 -0
  12. package/dist/docs/versioned/next/implementationPlans/PLAN_INDEX.md +4 -57
  13. package/dist/docs/versioned/next/implementationPlans/README.md +30 -56
  14. package/dist/docs/versioned/next/implementationPlans/agentic-sdlc-plugin.md +1 -2
  15. package/dist/docs/versioned/next/implementationPlans/ai-dev-loop-boost.md +0 -1
  16. package/dist/docs/versioned/next/implementationPlans/build-terreno-app-validation.md +0 -1
  17. package/dist/docs/versioned/next/implementationPlans/deploy-to-gcp.md +0 -1
  18. package/dist/docs/versioned/next/implementationPlans/deploy-to-vercel.md +0 -1
  19. package/dist/docs/versioned/next/implementationPlans/deployment-foundation.md +0 -1
  20. package/dist/docs/versioned/next/implementationPlans/docs-reference-coverage.md +0 -1
  21. package/dist/docs/versioned/next/implementationPlans/docs-tutorials-ai-first.md +0 -1
  22. package/dist/docs/versioned/next/implementationPlans/examples-demo-coverage.md +0 -1
  23. package/dist/docs/versioned/next/implementationPlans/oss-governance-baseline.md +0 -1
  24. package/dist/docs/versioned/next/implementationPlans/positioning-django-rails-universal.md +0 -1
  25. package/dist/docs/versioned/next/implementationPlans/public-roadmap-github.md +0 -1
  26. package/dist/docs/versioned/next/implementationPlans/rtk-to-syncdb-migration-docs.md +52 -47
  27. package/dist/docs/versioned/next/implementationPlans/syncdb-api-inventory.md +303 -0
  28. package/dist/docs/versioned/next/implementationPlans/syncdb-codegen.md +252 -0
  29. package/dist/docs/versioned/next/implementationPlans/syncdb-local-first.md +468 -420
  30. package/dist/docs/versioned/next/implementationPlans/syncdb-phase-c-design.md +425 -0
  31. package/dist/docs/versioned/next/implementationPlans/terreno-syncdb-2.md +800 -0
  32. package/dist/docs/versioned/next/implementationPlans/upgrade-guides-and-skill.md +0 -1
  33. package/dist/docs/versioned/next/implementationPlans/web-ssr-and-admin-spa.md +0 -1
  34. package/dist/docs/versioned/next/reference/README.md +1 -4
  35. package/dist/docs/versioned/next/reference/environment-variables.md +382 -220
  36. package/dist/docs/versioned/next/reference/syncdb.md +456 -0
  37. package/dist/docs/versioned/next/superpowers/plans/2026-07-28-admin-mobile-navigation.md +97 -0
  38. package/dist/docs/versioned/next/superpowers/specs/2026-07-28-admin-mobile-navigation-design.md +36 -0
  39. package/dist/docs/versioned/next/tasks/agentic-sdlc-plugin.md +5 -5
  40. package/dist/docs/versioned/next/tasks/deploy-to-gcp.md +11 -11
  41. package/dist/docs/versioned/next/tasks/deployment-foundation.md +12 -12
  42. package/dist/docs/versioned/next/tasks/docs-reference-coverage.md +4 -4
  43. package/dist/docs/versioned/next/tasks/oss-governance-baseline.md +18 -18
  44. package/dist/docs/versioned/next/tasks/positioning-django-rails-universal.md +4 -4
  45. package/dist/docs/versioned/next/tasks/public-roadmap-github.md +15 -15
  46. package/dist/docs/versioned/next/tasks/rtk-to-syncdb-migration-docs.md +10 -10
  47. package/dist/docs/versioned/next/tasks/syncdb-codegen.md +65 -0
  48. package/dist/docs/versioned/next/tasks/syncdb-local-first.md +434 -117
  49. package/package.json +4 -5
  50. package/src/docs/templates/bootstrap/backend/types/models/userTypes.template.md +4 -5
  51. package/src/docs/templates/bootstrap/frontend/app/_layout.template.tsx +1 -1
  52. package/src/docs/templates/tools/model.template.md +2 -4
  53. package/src/docs/versioned/next/README.md +1 -0
  54. package/src/docs/versioned/next/explanation/README.md +1 -7
  55. package/src/docs/versioned/next/how-to/README.md +2 -8
  56. package/src/docs/versioned/next/how-to/deploy-to-gcp.md +228 -20
  57. package/src/docs/versioned/next/how-to/migrate-rtk-to-syncdb.md +445 -0
  58. package/src/docs/versioned/next/implementationPlans/PLAN_INDEX.md +4 -57
  59. package/src/docs/versioned/next/implementationPlans/README.md +30 -56
  60. package/src/docs/versioned/next/implementationPlans/agentic-sdlc-plugin.md +1 -2
  61. package/src/docs/versioned/next/implementationPlans/ai-dev-loop-boost.md +0 -1
  62. package/src/docs/versioned/next/implementationPlans/build-terreno-app-validation.md +0 -1
  63. package/src/docs/versioned/next/implementationPlans/deploy-to-gcp.md +0 -1
  64. package/src/docs/versioned/next/implementationPlans/deploy-to-vercel.md +0 -1
  65. package/src/docs/versioned/next/implementationPlans/deployment-foundation.md +0 -1
  66. package/src/docs/versioned/next/implementationPlans/docs-reference-coverage.md +0 -1
  67. package/src/docs/versioned/next/implementationPlans/docs-tutorials-ai-first.md +0 -1
  68. package/src/docs/versioned/next/implementationPlans/examples-demo-coverage.md +0 -1
  69. package/src/docs/versioned/next/implementationPlans/oss-governance-baseline.md +0 -1
  70. package/src/docs/versioned/next/implementationPlans/positioning-django-rails-universal.md +0 -1
  71. package/src/docs/versioned/next/implementationPlans/public-roadmap-github.md +0 -1
  72. package/src/docs/versioned/next/implementationPlans/rtk-to-syncdb-migration-docs.md +52 -47
  73. package/src/docs/versioned/next/implementationPlans/syncdb-api-inventory.md +303 -0
  74. package/src/docs/versioned/next/implementationPlans/syncdb-codegen.md +252 -0
  75. package/src/docs/versioned/next/implementationPlans/syncdb-local-first.md +468 -420
  76. package/src/docs/versioned/next/implementationPlans/syncdb-phase-c-design.md +425 -0
  77. package/src/docs/versioned/next/implementationPlans/terreno-syncdb-2.md +800 -0
  78. package/src/docs/versioned/next/implementationPlans/upgrade-guides-and-skill.md +0 -1
  79. package/src/docs/versioned/next/implementationPlans/web-ssr-and-admin-spa.md +0 -1
  80. package/src/docs/versioned/next/reference/README.md +1 -4
  81. package/src/docs/versioned/next/reference/environment-variables.md +382 -220
  82. package/src/docs/versioned/next/reference/syncdb.md +456 -0
  83. package/src/docs/versioned/next/superpowers/plans/2026-07-28-admin-mobile-navigation.md +97 -0
  84. package/src/docs/versioned/next/superpowers/specs/2026-07-28-admin-mobile-navigation-design.md +36 -0
  85. package/src/docs/versioned/next/tasks/agentic-sdlc-plugin.md +5 -5
  86. package/src/docs/versioned/next/tasks/deploy-to-gcp.md +11 -11
  87. package/src/docs/versioned/next/tasks/deployment-foundation.md +12 -12
  88. package/src/docs/versioned/next/tasks/docs-reference-coverage.md +4 -4
  89. package/src/docs/versioned/next/tasks/oss-governance-baseline.md +18 -18
  90. package/src/docs/versioned/next/tasks/positioning-django-rails-universal.md +4 -4
  91. package/src/docs/versioned/next/tasks/public-roadmap-github.md +15 -15
  92. package/src/docs/versioned/next/tasks/rtk-to-syncdb-migration-docs.md +10 -10
  93. package/src/docs/versioned/next/tasks/syncdb-codegen.md +65 -0
  94. package/src/docs/versioned/next/tasks/syncdb-local-first.md +434 -117
  95. package/LICENSE +0 -21
  96. package/dist/__tests__/bootstrap.test.d.ts +0 -2
  97. package/dist/__tests__/bootstrap.test.d.ts.map +0 -1
  98. package/dist/__tests__/bootstrap.test.js +0 -299
  99. package/dist/__tests__/bootstrap.test.js.map +0 -1
  100. package/dist/__tests__/databaseQuery.test.d.ts +0 -2
  101. package/dist/__tests__/databaseQuery.test.d.ts.map +0 -1
  102. package/dist/__tests__/databaseQuery.test.js +0 -83
  103. package/dist/__tests__/databaseQuery.test.js.map +0 -1
  104. package/dist/__tests__/docsRoot.test.d.ts +0 -2
  105. package/dist/__tests__/docsRoot.test.d.ts.map +0 -1
  106. package/dist/__tests__/docsRoot.test.js +0 -59
  107. package/dist/__tests__/docsRoot.test.js.map +0 -1
  108. package/dist/__tests__/inferPackages.test.d.ts +0 -2
  109. package/dist/__tests__/inferPackages.test.d.ts.map +0 -1
  110. package/dist/__tests__/inferPackages.test.js +0 -35
  111. package/dist/__tests__/inferPackages.test.js.map +0 -1
  112. package/dist/__tests__/preload.d.ts +0 -2
  113. package/dist/__tests__/preload.d.ts.map +0 -1
  114. package/dist/__tests__/preload.js +0 -12
  115. package/dist/__tests__/preload.js.map +0 -1
  116. package/dist/__tests__/prompts.test.d.ts +0 -2
  117. package/dist/__tests__/prompts.test.d.ts.map +0 -1
  118. package/dist/__tests__/prompts.test.js +0 -295
  119. package/dist/__tests__/prompts.test.js.map +0 -1
  120. package/dist/__tests__/resources.test.d.ts +0 -2
  121. package/dist/__tests__/resources.test.d.ts.map +0 -1
  122. package/dist/__tests__/resources.test.js +0 -352
  123. package/dist/__tests__/resources.test.js.map +0 -1
  124. package/dist/__tests__/search.test.d.ts +0 -2
  125. package/dist/__tests__/search.test.d.ts.map +0 -1
  126. package/dist/__tests__/search.test.js +0 -163
  127. package/dist/__tests__/search.test.js.map +0 -1
  128. package/dist/__tests__/tools.test.d.ts +0 -2
  129. package/dist/__tests__/tools.test.d.ts.map +0 -1
  130. package/dist/__tests__/tools.test.js +0 -540
  131. package/dist/__tests__/tools.test.js.map +0 -1
  132. package/dist/__tests__/upgradeGuide.test.d.ts +0 -2
  133. package/dist/__tests__/upgradeGuide.test.d.ts.map +0 -1
  134. package/dist/__tests__/upgradeGuide.test.js +0 -22
  135. package/dist/__tests__/upgradeGuide.test.js.map +0 -1
  136. package/dist/docs/upgrades/0.31.0.md +0 -60
  137. package/dist/docs/versioned/next/explanation/deployment-architecture-gcp.md +0 -65
  138. package/dist/docs/versioned/next/explanation/deployment-baseline.md +0 -78
  139. package/dist/docs/versioned/next/explanation/positioning.md +0 -164
  140. package/dist/docs/versioned/next/explanation/repository-settings.md +0 -44
  141. package/dist/docs/versioned/next/explanation/roadmap-process.md +0 -330
  142. package/dist/docs/versioned/next/explanation/roadmap-seed-issues.md +0 -866
  143. package/dist/docs/versioned/next/how-to/build-for-web.md +0 -69
  144. package/dist/docs/versioned/next/how-to/deploy-backend-to-cloud-run.md +0 -115
  145. package/dist/docs/versioned/next/how-to/deploy-web-to-gcs-cdn.md +0 -183
  146. package/dist/docs/versioned/next/implementationPlans/b2b-platform-program.md +0 -114
  147. package/dist/docs/versioned/next/implementationPlans/billing-stripe.md +0 -158
  148. package/dist/docs/versioned/next/implementationPlans/comms-abstraction.md +0 -240
  149. package/dist/docs/versioned/next/implementationPlans/comms-adapter-expo-push.md +0 -107
  150. package/dist/docs/versioned/next/implementationPlans/comms-adapter-sendgrid.md +0 -107
  151. package/dist/docs/versioned/next/implementationPlans/comms-adapter-twilio-sms.md +0 -102
  152. package/dist/docs/versioned/next/implementationPlans/comms-adapter-twilio-verify.md +0 -93
  153. package/dist/docs/versioned/next/implementationPlans/infra-mcp-research.md +0 -188
  154. package/dist/docs/versioned/next/implementationPlans/infra-mcp.md +0 -269
  155. package/dist/docs/versioned/next/implementationPlans/native-module-baseline.md +0 -105
  156. package/dist/docs/versioned/next/implementationPlans/orgs-and-teams.md +0 -158
  157. package/dist/docs/versioned/next/implementationPlans/password-reset-and-email-verification.md +0 -147
  158. package/dist/docs/versioned/next/reference/admin-spa.md +0 -130
  159. package/dist/docs/versioned/next/reference/ai.md +0 -519
  160. package/dist/docs/versioned/next/reference/test.md +0 -108
  161. package/dist/docs/versioned/next/roadmap.md +0 -9
  162. package/dist/docs/versioned/next/tasks/README.md +0 -42
  163. package/dist/docs/versioned/next/tasks/billing-stripe.md +0 -75
  164. package/dist/docs/versioned/next/tasks/comms-abstraction.md +0 -77
  165. package/dist/docs/versioned/next/tasks/comms-adapter-expo-push.md +0 -29
  166. package/dist/docs/versioned/next/tasks/comms-adapter-sendgrid.md +0 -29
  167. package/dist/docs/versioned/next/tasks/comms-adapter-twilio-sms.md +0 -29
  168. package/dist/docs/versioned/next/tasks/comms-adapter-twilio-verify.md +0 -19
  169. package/dist/docs/versioned/next/tasks/infra-mcp.md +0 -43
  170. package/dist/docs/versioned/next/tasks/native-module-baseline.md +0 -42
  171. package/dist/docs/versioned/next/tasks/orgs-and-teams.md +0 -70
  172. package/dist/docs/versioned/next/tasks/password-reset-and-email-verification.md +0 -60
  173. package/src/docs/upgrades/0.31.0.md +0 -60
  174. package/src/docs/versioned/next/explanation/deployment-architecture-gcp.md +0 -65
  175. package/src/docs/versioned/next/explanation/deployment-baseline.md +0 -78
  176. package/src/docs/versioned/next/explanation/positioning.md +0 -164
  177. package/src/docs/versioned/next/explanation/repository-settings.md +0 -44
  178. package/src/docs/versioned/next/explanation/roadmap-process.md +0 -330
  179. package/src/docs/versioned/next/explanation/roadmap-seed-issues.md +0 -866
  180. package/src/docs/versioned/next/how-to/build-for-web.md +0 -69
  181. package/src/docs/versioned/next/how-to/deploy-backend-to-cloud-run.md +0 -115
  182. package/src/docs/versioned/next/how-to/deploy-web-to-gcs-cdn.md +0 -183
  183. package/src/docs/versioned/next/implementationPlans/b2b-platform-program.md +0 -114
  184. package/src/docs/versioned/next/implementationPlans/billing-stripe.md +0 -158
  185. package/src/docs/versioned/next/implementationPlans/comms-abstraction.md +0 -240
  186. package/src/docs/versioned/next/implementationPlans/comms-adapter-expo-push.md +0 -107
  187. package/src/docs/versioned/next/implementationPlans/comms-adapter-sendgrid.md +0 -107
  188. package/src/docs/versioned/next/implementationPlans/comms-adapter-twilio-sms.md +0 -102
  189. package/src/docs/versioned/next/implementationPlans/comms-adapter-twilio-verify.md +0 -93
  190. package/src/docs/versioned/next/implementationPlans/infra-mcp-research.md +0 -188
  191. package/src/docs/versioned/next/implementationPlans/infra-mcp.md +0 -269
  192. package/src/docs/versioned/next/implementationPlans/native-module-baseline.md +0 -105
  193. package/src/docs/versioned/next/implementationPlans/orgs-and-teams.md +0 -158
  194. package/src/docs/versioned/next/implementationPlans/password-reset-and-email-verification.md +0 -147
  195. package/src/docs/versioned/next/reference/admin-spa.md +0 -130
  196. package/src/docs/versioned/next/reference/ai.md +0 -519
  197. package/src/docs/versioned/next/reference/test.md +0 -108
  198. package/src/docs/versioned/next/roadmap.md +0 -9
  199. package/src/docs/versioned/next/tasks/README.md +0 -42
  200. package/src/docs/versioned/next/tasks/billing-stripe.md +0 -75
  201. package/src/docs/versioned/next/tasks/comms-abstraction.md +0 -77
  202. package/src/docs/versioned/next/tasks/comms-adapter-expo-push.md +0 -29
  203. package/src/docs/versioned/next/tasks/comms-adapter-sendgrid.md +0 -29
  204. package/src/docs/versioned/next/tasks/comms-adapter-twilio-sms.md +0 -29
  205. package/src/docs/versioned/next/tasks/comms-adapter-twilio-verify.md +0 -19
  206. package/src/docs/versioned/next/tasks/infra-mcp.md +0 -43
  207. package/src/docs/versioned/next/tasks/native-module-baseline.md +0 -42
  208. package/src/docs/versioned/next/tasks/orgs-and-teams.md +0 -70
  209. package/src/docs/versioned/next/tasks/password-reset-and-email-verification.md +0 -60
@@ -2,223 +2,385 @@
2
2
 
3
3
  Comprehensive guide to environment variables used across Terreno packages and example applications.
4
4
 
5
- > **Build-time client variables:** `EXPO_PUBLIC_*` variables are inlined into the JavaScript bundle at **build** time. They are not secrets and cannot be changed without rebuilding the web or native export. Set `EXPO_PUBLIC_API_URL` before `bun run export`, not on the hosting platform after deploy.
6
-
7
- ## Table columns
8
-
9
- | Column | Meaning |
10
- |--------|---------|
11
- | **Read by** | Package or app that reads the variable |
12
- | **Required** | Must be set for production use |
13
- | **Secret** | Treat as credential — never commit or expose in client bundles |
14
- | **Scope** | `server` = backend runtime; `client` = build-time (inlined); `tooling` = CI/scripts/tests only |
15
-
16
- ## Database
17
-
18
- | Variable | Read by | Required | Default | Secret | Scope |
19
- |----------|---------|----------|---------|--------|-------|
20
- | `MONGO_URI` | `@terreno/api`, example-backend | ✅ prod | `mongodb://localhost:27017` | Yes | server |
21
- | `MONGODB_URI` | tests, scripts | ❌ | — | Yes | tooling |
22
- | `TEST_MONGO_URI` | example-backend tests | ❌ | `mongodb://localhost:27017/test` | Yes | tooling |
23
- | `TERRENO_TEST_MONGODB_URI` | `@terreno/test` | ❌ | auto | Yes | tooling |
24
- | `TERRENO_TEST_USE_MEMORY_MONGO` | `@terreno/test` | ❌ | — | No | tooling |
25
- | `TERRENO_TEST_USE_REPLSET` | `@terreno/test` | ❌ | — | No | tooling |
26
- | `TERRENO_TEST_USE_FIXTURE_CACHE` | `@terreno/test` | ❌ | — | No | tooling |
27
- | `TERRENO_TEST_CACHE_DIR` | `@terreno/test` | ❌ | — | No | tooling |
28
- | `BUN_TEST_DISABLE_DB` | test harness | ❌ | — | No | tooling |
29
- | `DEBUG_MONGO_PRELOAD` | tests | ❌ | — | No | tooling |
30
- | `DEBUG_TEST_TRANSACTION` | tests | ❌ | — | No | tooling |
31
-
32
- ## Auth — JWT
33
-
34
- | Variable | Read by | Required | Default | Secret | Scope |
35
- |----------|---------|----------|---------|--------|-------|
36
- | `AUTH_PROVIDER` | `@terreno/api` | ❌ | `jwt` | No | server |
37
- | `TOKEN_SECRET` | `@terreno/api` | ✅ if JWT | — | Yes | server |
38
- | `TOKEN_ISSUER` | `@terreno/api` | ✅ if JWT | — | No | server |
39
- | `REFRESH_TOKEN_SECRET` | `@terreno/api` | ✅ if JWT | — | Yes | server |
40
- | `SESSION_SECRET` | `@terreno/api` | ✅ if JWT | — | Yes | server |
41
- | `TOKEN_EXPIRES_IN` | `@terreno/api` | ❌ | `15m` | No | server |
42
- | `REFRESH_TOKEN_EXPIRES_IN` | `@terreno/api` | ❌ | `30d` | No | server |
43
- | `SIGNUP_DISABLED` | `@terreno/api` | ❌ | `false` | No | server |
44
-
45
- ## Auth — Better Auth
46
-
47
- | Variable | Read by | Required | Default | Secret | Scope |
48
- |----------|---------|----------|---------|--------|-------|
49
- | `BETTER_AUTH_SECRET` | `@terreno/api` | ✅ if Better Auth | — | Yes | server |
50
- | `BETTER_AUTH_URL` | `@terreno/api` | ✅ if Better Auth | — | No | server |
51
- | `GOOGLE_CLIENT_ID` | `@terreno/api` | ❌ | — | No | server |
52
- | `GOOGLE_CLIENT_SECRET` | `@terreno/api` | ❌ | — | Yes | server |
53
- | `APPLE_CLIENT_ID` | `@terreno/api` | ❌ | — | No | server |
54
- | `APPLE_CLIENT_SECRET` | `@terreno/api` | ❌ | — | Yes | server |
55
- | `GITHUB_CLIENT_ID` | `@terreno/api` | ❌ | — | No | server |
56
- | `GITHUB_CLIENT_SECRET` | `@terreno/api` | ❌ | — | Yes | server |
57
- | `GITHUB_CALLBACK_URL` | `@terreno/api` | ❌ | — | No | server |
58
-
59
- ## Server configuration
60
-
61
- | Variable | Read by | Required | Default | Secret | Scope |
62
- |----------|---------|----------|---------|--------|-------|
63
- | `PORT` | `@terreno/api` (`terrenoApp.ts`) | ❌ | `9000` | No | server |
64
- | `NODE_ENV` | various | ❌ | `development` | No | server |
65
- | `HOST` | servers | ❌ | all interfaces | No | server |
66
- | `ENABLE_SWAGGER` | `@terreno/api` | ❌ | `false` | No | server |
67
- | `APP_ENV` | example-backend | ❌ | `development` | No | server |
68
- | `BACKEND_URL` | scripts, deploy | ❌ | — | No | server |
69
- | `FRONTEND_URL` | example-backend CORS | ❌ | auto | No | server |
70
- | `API_URL` | microservice split | ❌ | — | No | server |
71
- | `DISABLE_LOG_ALL_REQUESTS` | `@terreno/api` logging | ❌ | — | No | server |
72
-
73
- ## Client / build-time
74
-
75
- | Variable | Read by | Required | Default | Secret | Scope |
76
- |----------|---------|----------|---------|--------|-------|
77
- | `EXPO_PUBLIC_API_URL` | `@terreno/rtk` | ✅ prod web | dev auto-detect | No | **client** |
78
- | `EXPO_PUBLIC_DEV_API_PORT` | `@terreno/rtk` | ❌ | `4000` | No | **client** |
79
- | `EXPO_PUBLIC_BUILD_NUMBER` | example-frontend | ❌ | — | No | **client** |
80
- | `OPENAPI_URL` | example-frontend `sdk` script | ❌ | `http://localhost:4000/openapi.json` | No | tooling |
81
-
82
- ### `app.json` `extra` (not `process.env`)
83
-
84
- Configured in `expo.extra` and read via `expo-constants`:
85
-
86
- | Key | Read by | Notes |
87
- |-----|---------|-------|
88
- | `BASE_URL` | `@terreno/rtk` | Production fallback when `EXPO_PUBLIC_API_URL` unset; use `__SAME_ORIGIN__` for same-origin admin SPA |
89
- | `DEV_API_PORT` | `@terreno/rtk` | Override dev API port (mirrors `EXPO_PUBLIC_DEV_API_PORT`) |
90
- | `AUTH_DEBUG` | `@terreno/rtk` | `"true"` enables auth debug logs |
91
- | `WEBSOCKETS_DEBUG` | `@terreno/rtk` | `"true"` enables socket debug logs |
92
- | `APP_ENV` | `@terreno/rtk` | Logged at startup |
93
-
94
- Resolution order for API base URL (`rtk/src/constants.ts`):
95
-
96
- 1. `EXPO_PUBLIC_API_URL` (production and dev)
97
- 2. `extra.BASE_URL` (production only, when env unset)
98
- 3. Dev fallbacks: `hostUri`, experience URL, `localhost`
99
-
100
- ## AI
101
-
102
- | Variable | Read by | Required | Default | Secret | Scope |
103
- |----------|---------|----------|---------|--------|-------|
104
- | `GEMINI_API_KEY` | `@terreno/ai` | ❌ | — | Yes | server |
105
- | `OPENAI_API_KEY` | `@terreno/ai` | ❌ | — | Yes | server |
106
- | `GOOGLE_VERTEX_PROJECT` | `@terreno/ai` | ❌ | — | No | server |
107
- | `GOOGLE_VERTEX_LOCATION` | `@terreno/ai` | ❌ | — | No | server |
108
- | `GOOGLE_VERTEX_ALLOWED_MODELS` | `@terreno/ai` | ❌ | all | No | server |
109
- | `CLAUDE_KEY` | tooling | ❌ | — | Yes | tooling |
110
- | `LANGFUSE_SECRET_KEY` | `@terreno/ai` | ❌ | — | Yes | server |
111
- | `LANGFUSE_PUBLIC_KEY` | `@terreno/ai` | ❌ | — | No | server |
112
- | `LANGFUSE_BASE_URL` | `@terreno/ai` | ❌ | — | No | server |
113
- | `LANGFUSE_ORGANIZATION` | `@terreno/ai` | ❌ | — | No | server |
114
- | `LANGFUSE_PROJECT` | `@terreno/ai` | ❌ | — | No | server |
115
- | `LANGFUSE_PROJECT_ID` | `@terreno/ai` | ❌ | — | No | server |
116
-
117
- ## Storage (GCS)
118
-
119
- | Variable | Read by | Required | Default | Secret | Scope |
120
- |----------|---------|----------|---------|--------|-------|
121
- | `GCS_BUCKET` | example-backend, admin | ❌ | — | No | server |
122
- | `GCS_PROJECT_ID` | GCS clients | ❌ | — | No | server |
123
- | `GCS_SERVICE_ACCOUNT_KEY` | GCS clients | ❌ | — | Yes | server |
124
-
125
- ## Feature flags
126
-
127
- | Variable | Read by | Required | Default | Secret | Scope |
128
- |----------|---------|----------|---------|--------|-------|
129
- | `FEATURE_FLAGS_DEBUG` | `@terreno/feature-flags` | ❌ | — | No | server |
130
-
131
- ## Observability
132
-
133
- | Variable | Read by | Required | Default | Secret | Scope |
134
- |----------|---------|----------|---------|--------|-------|
135
- | `SENTRY_DSN` | `@terreno/api`, frontends | ❌ | — | No | server / client |
136
- | `SENTRY_ENVIRONMENT` | Sentry SDK | ❌ | — | No | server |
137
- | `SENTRY_TRACES_SAMPLE_RATE` | Sentry SDK | ❌ | — | No | server |
138
- | `USE_SENTRY_LOGGING` | `@terreno/api` | ❌ | `false` | No | server |
139
- | `SLOW_REQUEST_THRESHOLD_MS` | `@terreno/api` | ❌ | `5000` | No | server |
140
- | `SLOW_DB_QUERY_THRESHOLD_MS` | `@terreno/api` | ❌ | `100` | No | server |
141
- | `TERRENO_LOG_FILE` | logger | ❌ | — | No | server |
142
- | `TRACE_SAMPLING_RATE` | example-backend OTEL | ❌ | `0.1` | No | server |
143
- | `MEMORY_SAMPLE_INTERVAL_MS` | example-backend | ❌ | `60000` | No | server |
144
- | `JOB_TRACE_LOGS` | workers | ❌ | — | No | server |
145
-
146
- ## Caching
147
-
148
- | Variable | Read by | Required | Default | Secret | Scope |
149
- |----------|---------|----------|---------|--------|-------|
150
- | `VALKEY_URL` | `@terreno/api` | ❌ | — | Yes | server |
151
- | `REDIS_URL` | various | ❌ | — | Yes | server |
152
-
153
- ## Webhooks & notifications
154
-
155
- | Variable | Read by | Required | Default | Secret | Scope |
156
- |----------|---------|----------|---------|--------|-------|
157
- | `SLACK_WEBHOOKS` | `@terreno/api` | ❌ | — | Yes | server |
158
- | `SLACK_WEBHOOK_URL` | scripts | ❌ | — | Yes | server |
159
- | `GOOGLE_CHAT_WEBHOOKS` | `@terreno/api` | ❌ | — | Yes | server |
160
- | `GOOGLE_CHAT_WEBHOOK_URL` | scripts | ❌ | — | Yes | server |
161
- | `ZOOM_CHAT_WEBHOOKS` | `@terreno/api` | ❌ | — | Yes | server |
162
- | `ZOOM_WEBHOOK_URL` | scripts | ❌ | — | Yes | server |
163
- | `WEBHOOK_SECRET` | webhooks | ❌ | — | Yes | server |
164
-
165
- ## Admin SPA
166
-
167
- | Variable | Read by | Required | Default | Secret | Scope |
168
- |----------|---------|----------|---------|--------|-------|
169
- | `ADMIN_SPA_ENABLED` | example-backend | ❌ | — | No | server |
170
- | `ADMIN_SPA_DIST_DIR` | example-backend Dockerfile | ❌ | — | No | server |
171
- | `ADMIN_SPA_DEV_PROXY` | admin-spa plugin | ❌ | — | No | server |
172
- | `ADMIN_SPA_BACKEND_URL` | admin-spa tests | ❌ | — | No | tooling |
173
- | `ADMIN_SPA_E2E_EMAIL` | e2e | ❌ | — | No | tooling |
174
- | `ADMIN_SPA_E2E_PASSWORD` | e2e | ❌ | — | Yes | tooling |
175
-
176
- ## MCP server
177
-
178
- | Variable | Read by | Required | Default | Secret | Scope |
179
- |----------|---------|----------|---------|--------|-------|
180
- | `MCP_SERVER_URL` | MCP clients | ❌ | — | No | tooling |
181
- | `TERRENO_MCP_DOCS_DIR` | `@terreno/mcp` | ❌ | — | No | tooling |
182
- | `TERRENO_MCP_EVAL` | MCP eval | ❌ | — | No | tooling |
183
- | `TERRENO_PROJECT_ROOT` | MCP local | ❌ | — | No | tooling |
184
-
185
- ## Example backend (app-specific)
186
-
187
- | Variable | Read by | Required | Default | Secret | Scope |
188
- |----------|---------|----------|---------|--------|-------|
189
- | `FLOURISH_SERVICE` | OpenTelemetry | ❌ | `flourish-backend` | No | server |
190
- | `PR_NUMBER` | PR preview deploy | ❌ | — | No | server |
191
- | `PR_SERVICE_URL` | PR preview deploy | ❌ | — | No | server |
192
- | `DEFAULT_PAGE_SIZE` | Configuration model | ❌ | `20` | No | server |
193
- | `CRON_SECRET_KEY` | tests | ❌ | — | Yes | tooling |
194
- | `WIDGET_CLIENT_SECRET` | widgets | ❌ | — | Yes | server |
195
- | `API_KEY` | integrations | ❌ | — | Yes | server |
196
-
197
- ## Testing & CI (tooling only)
198
-
199
- | Variable | Read by | Scope |
200
- |----------|---------|-------|
201
- | `CI` | CI scripts | tooling |
202
- | `JEST_WORKER_ID` | test runners | tooling |
203
- | `SHOW_ALL_TEST_LOGS` | tests | tooling |
204
- | `KEEP_COVERAGE` | tests | tooling |
205
- | `DRY_RUN` | scripts | tooling |
206
- | `APPIUM_CI`, `APPIUM_DEV_SERVER_URL`, `APPIUM_QUICK_LOOP`, `APPIUM_REQUIRE_NON_DEV_CLIENT`, `APPIUM_SPEC_FILE_RETRIES`, `APPIUM_SPECS` | Appium e2e | tooling |
207
- | `ANDROID_APP_PATH`, `ANDROID_DEVICE_NAME` | mobile e2e | tooling |
208
- | `IOS_APP_PATH`, `IOS_DEVICE_NAME`, `IOS_DEVICE_UDID`, `IOS_PLATFORM_VERSION` | mobile e2e | tooling |
209
- | `EXPO_OS` | Expo tooling | tooling |
210
- | `DEMO_URL`, `DOCS_URL` | link checkers | tooling |
211
- | `DEBUG_BILLING` | debug | tooling |
212
- | `TZ` | tests | tooling |
213
- | `X` | debug flag | tooling |
214
-
215
- ## Example `.env` files
216
-
217
- - [`example-backend/.env.example`](https://github.com/FlourishHealth/terreno/blob/master/example-backend/.env.example)
218
- - [`example-frontend/.env.example`](https://github.com/FlourishHealth/terreno/blob/master/example-frontend/.env.example)
219
-
220
- ## Related documentation
221
-
222
- - [Deployment baseline](../explanation/deployment-baseline.md)
223
- - [Build for web](../how-to/build-for-web.md)
224
- - [Configure Better Auth](../how-to/configure-better-auth.md)
5
+ ## Table of Contents
6
+
7
+ - [@terreno/api (Backend)](#terrenoapi-backend)
8
+ - [@terreno/rtk (Frontend State)](#terrenortk-frontend-state)
9
+ - [@terreno/ui (Components)](#terrenoui-components)
10
+ - [Example Backend](#example-backend)
11
+ - [Example Frontend](#example-frontend)
12
+
13
+ ---
14
+
15
+ ## @terreno/api (Backend)
16
+
17
+ Environment variables used by the `@terreno/api` package.
18
+
19
+ ### Authentication
20
+
21
+ | Variable | Required | Default | Description |
22
+ |----------|----------|---------|-------------|
23
+ | `AUTH_PROVIDER` | ❌ | `jwt` | Authentication provider: `"jwt"` or `"better-auth"` |
24
+ | `TOKEN_SECRET` | ✅ (if JWT) | - | Secret key for signing JWT access tokens |
25
+ | `TOKEN_ISSUER` | ✅ (if JWT) | - | JWT issuer claim (e.g., `your-app.com`) |
26
+ | `REFRESH_TOKEN_SECRET` | ✅ (if JWT) | - | Secret key for signing refresh tokens |
27
+ | `SESSION_SECRET` | ✅ (if JWT) | - | Express session secret |
28
+ | `TOKEN_EXPIRES_IN` | ❌ | `15m` | Access token expiration (e.g., `1h`, `30m`) |
29
+ | `REFRESH_TOKEN_EXPIRES_IN` | ❌ | `30d` | Refresh token expiration (e.g., `7d`, `90d`) |
30
+ | `SIGNUP_DISABLED` | ❌ | `false` | Disable user registration (invite-only mode) |
31
+
32
+ ### Better Auth (Optional)
33
+
34
+ | Variable | Required | Default | Description |
35
+ |----------|----------|---------|-------------|
36
+ | `BETTER_AUTH_SECRET` | ✅ (if Better Auth) | - | Secret key for Better Auth session encryption |
37
+ | `BETTER_AUTH_URL` | ✅ (if Better Auth) | - | Base URL for Better Auth server (e.g., `https://api.example.com`) |
38
+ | `GOOGLE_CLIENT_ID` | ❌ | - | Google OAuth client ID |
39
+ | `GOOGLE_CLIENT_SECRET` | ❌ | - | Google OAuth client secret |
40
+ | `APPLE_CLIENT_ID` | ❌ | - | Apple Sign In service ID |
41
+ | `APPLE_CLIENT_SECRET` | ❌ | - | Apple Sign In private key |
42
+
43
+ ### GitHub OAuth (Optional)
44
+
45
+ | Variable | Required | Default | Description |
46
+ |----------|----------|---------|-------------|
47
+ | `GITHUB_CLIENT_ID` | ❌ | - | GitHub OAuth application client ID |
48
+ | `GITHUB_CLIENT_SECRET` | ❌ | - | GitHub OAuth application client secret |
49
+ | `GITHUB_CALLBACK_URL` | ❌ | - | OAuth callback URL (e.g., `https://api.example.com/auth/github/callback`) |
50
+
51
+ ### Server Configuration
52
+
53
+ | Variable | Required | Default | Description |
54
+ |----------|----------|---------|-------------|
55
+ | `PORT` | ❌ | `3000` | HTTP server port |
56
+ | `NODE_ENV` | ❌ | `development` | Node environment (`development`, `production`, `test`) |
57
+ | `MONGO_URI` | ❌ | `mongodb://localhost:27017` | MongoDB connection string |
58
+ | `ENABLE_SWAGGER` | ❌ | `false` | Enable Swagger UI at `/swagger` endpoint |
59
+
60
+ ### Logging & Monitoring
61
+
62
+ | Variable | Required | Default | Description |
63
+ |----------|----------|---------|-------------|
64
+ | `SENTRY_DSN` | ❌ | - | Sentry DSN for error tracking |
65
+ | `USE_SENTRY_LOGGING` | ❌ | `false` | Send logs to Sentry |
66
+ | `LOG_REQUESTS` | ❌ | `false` | Log all HTTP requests |
67
+ | `LOG_SLOW_REQUESTS` | ❌ | `false` | Log requests exceeding threshold |
68
+ | `SLOW_REQUEST_THRESHOLD_MS` | ❌ | `5000` | Milliseconds to consider a request "slow" |
69
+ | `SLOW_DB_QUERY_THRESHOLD_MS` | ❌ | `100` | Milliseconds to consider a DB query "slow" |
70
+
71
+ ### Webhooks & Notifications (Optional)
72
+
73
+ | Variable | Required | Default | Description |
74
+ |----------|----------|---------|-------------|
75
+ | `SLACK_WEBHOOKS` | ❌ | - | JSON object mapping names to Slack webhook URLs<br/>Example: `{"default": "https://hooks.slack.com/..."}` |
76
+ | `GOOGLE_CHAT_WEBHOOKS` | ❌ | - | JSON object mapping names to Google Chat webhook URLs<br/>Example: `{"default": "https://chat.googleapis.com/..."}` |
77
+ | `ZOOM_WEBHOOK` | ❌ | - | Zoom webhook URL for notifications |
78
+
79
+ ### Google Cloud Platform (Optional)
80
+
81
+ | Variable | Required | Default | Description |
82
+ |----------|----------|---------|-------------|
83
+ | `GCP_PROJECT` | ❌ | - | Google Cloud project ID |
84
+ | `GCP_LOCATION` | ❌ | - | GCP region (e.g., `us-central1`) |
85
+ | `GCP_SERVICE_ACCOUNT_EMAIL` | ❌ | - | Service account email for authentication |
86
+ | `GCP_TASKS_NOTIFICATIONS_QUEUE` | ❌ | - | Cloud Tasks queue name for notifications |
87
+ | `GCP_TASK_PROCESSOR_QUEUE` | ❌ | - | Cloud Tasks queue name for background tasks |
88
+
89
+ ### Caching & Performance
90
+
91
+ | Variable | Required | Default | Description |
92
+ |----------|----------|---------|-------------|
93
+ | `VALKEY_URL` | ❌ | - | Redis/Valkey connection URL (e.g., `redis://localhost:6379`) |
94
+
95
+ ### Other APIs
96
+
97
+ | Variable | Required | Default | Description |
98
+ |----------|----------|---------|-------------|
99
+ | `GEMINI_API_KEY` | ❌ | - | Google Gemini API key for AI features |
100
+
101
+ ### Example .env File
102
+
103
+ ``````bash
104
+ # Authentication Provider
105
+ AUTH_PROVIDER=jwt # or "better-auth"
106
+
107
+ # Required for JWT authentication
108
+ TOKEN_SECRET=your-secret-key-change-this-in-production
109
+ TOKEN_ISSUER=your-app.com
110
+ REFRESH_TOKEN_SECRET=your-refresh-secret-change-this-too
111
+ SESSION_SECRET=your-session-secret-change-this-also
112
+
113
+ # Required for Better Auth (if AUTH_PROVIDER=better-auth)
114
+ # BETTER_AUTH_SECRET=your-better-auth-secret-min-32-chars
115
+ # BETTER_AUTH_URL=http://localhost:4000
116
+
117
+ # Optional - Social OAuth (Better Auth)
118
+ # GOOGLE_CLIENT_ID=your-google-client-id
119
+ # GOOGLE_CLIENT_SECRET=your-google-client-secret
120
+ # GITHUB_CLIENT_ID=your-github-client-id
121
+ # GITHUB_CLIENT_SECRET=your-github-client-secret
122
+
123
+ # Database
124
+ MONGO_URI=mongodb://localhost:27017/your-app
125
+
126
+ # Optional - Common in development
127
+ PORT=3000
128
+ NODE_ENV=development
129
+ ENABLE_SWAGGER=true
130
+ LOG_REQUESTS=true
131
+
132
+ # Optional - Production monitoring
133
+ SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
134
+ USE_SENTRY_LOGGING=true
135
+ ``````
136
+
137
+ ---
138
+
139
+ ## @terreno/rtk (Frontend State)
140
+
141
+ Environment variables used by the `@terreno/rtk` package and frontend applications.
142
+
143
+ ### Base URL Configuration
144
+
145
+ The base URL is resolved in priority order:
146
+
147
+ 1. `Constants.expoConfig?.extra?.BASE_URL` (production/staging builds)
148
+ 2. `process.env.EXPO_PUBLIC_API_URL` (development web)
149
+ 3. `Constants.expoConfig?.hostUri` + the dev API port (dev simulator/device)
150
+ 4. `http://localhost:<dev API port>` (fallback)
151
+
152
+ The dev API port defaults to `4000` and is overridable per app via `EXPO_PUBLIC_DEV_API_PORT`
153
+ or `expoConfig.extra.DEV_API_PORT` (for example `3000` or `9000`).
154
+
155
+ | Variable | Required | Default | Description |
156
+ |----------|----------|---------|-------------|
157
+ | `EXPO_PUBLIC_API_URL` | ❌ | Auto-detected | Backend API base URL<br/>Web: `http://localhost:4000`<br/>Simulator: Auto-detected via `hostUri`<br/>Device: Use your computer's local IP |
158
+ | `EXPO_PUBLIC_DEV_API_PORT` | ❌ | 4000 | Local dev API port for host/localhost resolution (also settable via `extra.DEV_API_PORT`) |
159
+
160
+ ### Debug Flags
161
+
162
+ | Variable | Required | Default | Description |
163
+ |----------|----------|---------|-------------|
164
+ | `AUTH_DEBUG` | ❌ | `false` | Enable authentication debug logging |
165
+ | `WEBSOCKETS_DEBUG` | ❌ | `false` | Enable WebSocket debug logging |
166
+
167
+ ### Example app.json Configuration
168
+
169
+ ``````json
170
+ {
171
+ "expo": {
172
+ "extra": {
173
+ "BASE_URL": "https://api.example.com",
174
+ "AUTH_DEBUG": "false",
175
+ "WEBSOCKETS_DEBUG": "false"
176
+ }
177
+ }
178
+ }
179
+ ``````
180
+
181
+ ### Example .env for Web Development
182
+
183
+ ``````bash
184
+ # Backend API URL
185
+ EXPO_PUBLIC_API_URL=http://localhost:4000
186
+ ``````
187
+
188
+ ---
189
+
190
+ ## @terreno/ui (Components)
191
+
192
+ The `@terreno/ui` package **does not require environment variables**. All configuration is done at runtime via the `TerrenoProvider` component.
193
+
194
+ ### Runtime Configuration
195
+
196
+ ``````typescript
197
+ import {TerrenoProvider} from "@terreno/ui";
198
+
199
+ <TerrenoProvider
200
+ initialTheme={{
201
+ primitives: {
202
+ primary500: "#0066CC",
203
+ accent500: "#FF6B35",
204
+ }
205
+ }}
206
+ >
207
+ <App />
208
+ </TerrenoProvider>
209
+ ``````
210
+
211
+ ---
212
+
213
+ ## Example Backend
214
+
215
+ Environment variables specific to the example backend application (not part of @terreno/api).
216
+
217
+ ### Application Configuration
218
+
219
+ | Variable | Required | Default | Description |
220
+ |----------|----------|---------|-------------|
221
+ | `APP_ENV` | ❌ | `development` | Application environment (`development`, `staging`, `production`) |
222
+ | `BACKEND_SERVICE` | ❌ | `all` | Service type to run: `api`, `websockets`, `tasks`, or `all` |
223
+ | `API_URL` | ❌ | - | API service URL (for microservice architecture) |
224
+ | `TASKS_URL` | ❌ | - | Tasks service URL (for microservice architecture) |
225
+ | `FLOURISH_SERVICE` | ❌ | `flourish-backend` | Service name for OpenTelemetry tracing |
226
+
227
+ ### WebSockets
228
+
229
+ | Variable | Required | Default | Description |
230
+ |----------|----------|---------|-------------|
231
+ | `WEBSOCKET_PORT` | ❌ | Same as `PORT` | WebSocket server port (if separate from HTTP) |
232
+ | `FRONTEND_URL` | ❌ | Auto-detected | Frontend URL for CORS (e.g., `http://localhost:8082`) |
233
+
234
+ ### Pull Request Environments
235
+
236
+ | Variable | Required | Default | Description |
237
+ |----------|----------|---------|-------------|
238
+ | `PR_NUMBER` | ❌ | - | Pull request number (set by CI/CD) |
239
+ | `PR_SERVICE_URL` | ❌ | - | Cloud Run service URL base for PR environments |
240
+
241
+ ### Performance Monitoring
242
+
243
+ | Variable | Required | Default | Description |
244
+ |----------|----------|---------|-------------|
245
+ | `MEMORY_SAMPLE_INTERVAL_MS` | ❌ | `60000` | Interval for memory usage sampling |
246
+ | `TRACE_SAMPLING_RATE` | ❌ | `0.1` | OpenTelemetry trace sampling rate (0.0-1.0) |
247
+
248
+ ### Testing
249
+
250
+ | Variable | Required | Default | Description |
251
+ |----------|----------|---------|-------------|
252
+ | `TEST_MONGO_URI` | ❌ | `mongodb://localhost:27017/test` | MongoDB URI for tests |
253
+ | `CRON_SECRET_KEY` | ❌ | - | Secret key for testing cron endpoints |
254
+
255
+ ### Configuration Model System
256
+
257
+ The example backend uses a **Configuration model** with a priority system:
258
+
259
+ **Priority (highest to lowest)**:
260
+ 1. Runtime override via `Configuration.set()`
261
+ 2. Database cache (persisted values)
262
+ 3. Environment variable
263
+ 4. Default value
264
+
265
+ ``````typescript
266
+ // Get configuration value
267
+ const pageSize = await Configuration.get("DEFAULT_PAGE_SIZE"); // Returns 20
268
+
269
+ // Set configuration value (persists to database)
270
+ await Configuration.set("DEFAULT_PAGE_SIZE", 50);
271
+
272
+ // Register new configuration
273
+ Configuration.register("FEATURE_FLAG", {
274
+ defaultValue: false,
275
+ envVar: "FEATURE_FLAG",
276
+ description: "Enable new feature",
277
+ type: "boolean",
278
+ });
279
+ ``````
280
+
281
+ See [Configuration System](../explanation/configuration-system.md) for details.
282
+
283
+ ---
284
+
285
+ ## Example Frontend
286
+
287
+ Environment variables specific to the example frontend application.
288
+
289
+ ### SDK Generation
290
+
291
+ | Variable | Required | Default | Description |
292
+ |----------|----------|---------|-------------|
293
+ | `OPENAPI_URL` | ❌ | `http://localhost:4000/openapi.json` | Backend OpenAPI spec URL for SDK generation |
294
+
295
+ Used by `bun run sdk` to fetch the OpenAPI specification and generate RTK Query hooks.
296
+
297
+ ### Development
298
+
299
+ | Variable | Required | Default | Description |
300
+ |----------|----------|---------|-------------|
301
+ | `EXPO_PUBLIC_API_URL` | ❌ | Auto-detected | Backend API URL (see [@terreno/rtk](#terrenortk-frontend-state)) |
302
+
303
+ ### Example .env File
304
+
305
+ ``````bash
306
+ # Backend API (optional - auto-detected if not set)
307
+ EXPO_PUBLIC_API_URL=http://localhost:4000
308
+
309
+ # SDK generation (optional)
310
+ OPENAPI_URL=http://localhost:4000/openapi.json
311
+ ``````
312
+
313
+ ---
314
+
315
+ ## Best Practices
316
+
317
+ ### Security
318
+
319
+ 1. **Never commit `.env` files** - Add to `.gitignore`
320
+ 2. **Use strong secrets** - Generate with `openssl rand -base64 32`
321
+ 3. **Rotate secrets regularly** - Especially `TOKEN_SECRET` and `REFRESH_TOKEN_SECRET`
322
+ 4. **Different secrets per environment** - Don't reuse production secrets in development
323
+
324
+ ### Development
325
+
326
+ 1. **Use `.env.example`** - Check into version control with placeholder values
327
+ 2. **Document all variables** - Include description and default values
328
+ 3. **Validate required variables** - Fail fast if missing critical config
329
+ 4. **Auto-detect when possible** - Like `@terreno/rtk` does for `BASE_URL`
330
+
331
+ ### Production
332
+
333
+ 1. **Use environment variables** - Not hardcoded values or `.env` files
334
+ 2. **Set via platform** - Railway, Heroku, Cloud Run, etc.
335
+ 3. **Enable monitoring** - Set `SENTRY_DSN` and `USE_SENTRY_LOGGING`
336
+ 4. **Reduce logging** - Set `LOG_REQUESTS=false` to reduce noise
337
+
338
+ ---
339
+
340
+ ## Troubleshooting
341
+
342
+ ### "TOKEN_SECRET is not set"
343
+
344
+ **Problem**: Required authentication variables missing.
345
+
346
+ **Solution**:
347
+ ```bash
348
+ cp .env.example .env
349
+ # Edit .env and set all required variables
350
+ ```
351
+
352
+ ### "Cannot connect to MongoDB"
353
+
354
+ **Problem**: `MONGO_URI` incorrect or MongoDB not running.
355
+
356
+ **Solutions**:
357
+ - Ensure MongoDB is running: `docker run -d -p 27017:27017 mongo`
358
+ - Check `MONGO_URI` in `.env`
359
+ - Test connection: `mongosh mongodb://localhost:27017`
360
+
361
+ ### "Network request failed" (Frontend)
362
+
363
+ **Problem**: Frontend can't reach backend.
364
+
365
+ **Solutions**:
366
+ - Ensure backend is running
367
+ - Check `EXPO_PUBLIC_API_URL` matches backend port
368
+ - For physical devices: Use your computer's local IP, not `localhost`
369
+ - Verify CORS settings allow frontend origin
370
+
371
+ ### "Invalid token"
372
+
373
+ **Problem**: Token secrets mismatch between frontend/backend.
374
+
375
+ **Solution**: Ensure `TOKEN_SECRET` and `REFRESH_TOKEN_SECRET` are identical across deployments if using shared authentication.
376
+
377
+ ---
378
+
379
+ ## Related Documentation
380
+
381
+ - [Getting Started Tutorial](../tutorials/getting-started.md)
382
+ - [@terreno/api Reference](./api.md)
383
+ - [@terreno/rtk Reference](./rtk.md)
384
+ - [Configuration System](../explanation/configuration-system.md)
385
+ - [Example Backend README](../../example-backend/README.md)
386
+ - [Example Frontend README](../../example-frontend/README.md)