Environment Management & Secrets
Relevant source files
The following files were used as context for generating this wiki page:
The Hospice Roadmap project utilizes a structured approach to environment management to ensure that sensitive configurations and API credentials are handled securely across its monorepo architecture. This system facilitates the separation of development, staging, and production environments while protecting critical secrets such as database connection strings and AI service keys.
Sources: replit.md, artifacts/mobile/scripts/write-env.js
Configuration Architecture
The project manages environment variables at both the workspace root and individual package levels. The root package.json and .gitignore define the high-level security boundary, ensuring that local environment files are never committed to version control.
Secret Protection Mechanisms
The repository employs strict ignore rules to prevent the accidental exposure of secrets. The following patterns are explicitly excluded from version control:
.env.local.env.*.local*.log
Sources: attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt, .gitignore
Data Flow for Environment Variables
The mobile application specifically uses a utility script, write-env.js, to programmatically generate environment files. This ensures that the React Native/Expo application has access to the correct API endpoints and keys during the build process without hardcoding them into the source.
The diagram shows how environment variables are propagated from root configuration files through a generation script to reach the mobile application runtime.
Sources: artifacts/mobile/scripts/write-env.js, replit.md
Core Environment Variables
The project relies on several key variables to connect disparate systems, including the PostgreSQL database, the Anthropic AI integration, and the CMS provider data services.
| Variable Name | Description | Used By |
|---|---|---|
DATABASE_URL | PostgreSQL connection string for Drizzle ORM | lib/db, artifacts/api-server |
ANTHROPIC_API_KEY | Credential for Claude AI model integration | artifacts/api-server |
API_BASE_URL | The endpoint for the Express API server | artifacts/mobile |
X_CLIENT_ID | Header-based identity for session persistence | artifacts/mobile, artifacts/api-server |
Sources: replit.md, artifacts/api-server/src/routes/anthropic/index.ts, attached_assets/Pasted-Build-a-real-in-app-support-request-flow-for-the-React-_1774839229732.txt
Secret Integration Points
Database and ORM
The backend uses Drizzle ORM to interface with PostgreSQL. Connection details are pulled from environment variables and validated using Zod schemas to ensure type safety and prevent runtime failures due to missing configuration.
Sources: replit.md, lib/db/package.json
Anthropic Claude Integration
The artifacts/api-server manages the integration with Anthropic's Claude. The API key is utilized to authenticate requests that power the "Ragna" AI companion. These secrets are injected into the system prompt context during the generation of the Intelligence Package.
This sequence illustrates the use of the ANTHROPIC_API_KEY to facilitate secure communication between the internal API server and the external AI provider.
Sources: artifacts/api-server/src/routes/anthropic/index.ts, .agents/memory/anthropic-integration.md
Client Identity Management
A specific header, x_client_id, is used to manage anonymous session persistence and associate data (like support requests or symptom logs) with a specific device without requiring a full login system. The API server validates this header against a specific regex: /^client_[a-z0-9_]+$/.
Sources: artifacts/api-server/src/routes/anthropic/index.ts:12-20, attached_assets/Pasted-Build-a-real-in-app-support-request-flow-for-the-React-_1774839229732.txt
Development Workflow Scripts
To maintain dependency hygiene and environment consistency, the root workspace provides scripts for cleaning and health checks.
repo:clean:artifacts: Removes local caches and build artifacts like.expo,dist, and.local.repo:health: Executes a workspace-wide typecheck to ensure environment-dependent types (like those generated by Orval) are correct.
Sources: attached_assets/Pasted-Make-a-focused-repo-cleanup-and-dependency-hygiene-pass_1774842983742.txt
The environment management system in Hospice Roadmap prioritizes local-first storage and secure transmission to the backend. By leveraging automated scripts for .env generation and strict .gitignore policies, the project maintains a clear separation between public source code and private operational secrets.