Environment Configuration
Environment Configuration
To run the HCG AI application, you must configure several environment variables. These variables handle database connectivity, authentication security, AI features, and automated email services.
Create a file named .env in the root directory of the project and populate it with the following configuration.
1. Required Variables
| Variable | Description | Example |
| :--- | :--- | :--- |
| DATABASE_URL | The connection string for your PostgreSQL database. Supports local PostgreSQL or managed services like Neon. | postgresql://user:pass@localhost:5432/hcgai |
| SESSION_SECRET | A secure, random string used to sign session cookies. | your-long-random-string-here |
| OPENAI_API_KEY | Your API key from OpenAI. Required to power the medical analysis chatbot. | sk-proj-xxxx... |
2. Optional Variables
| Variable | Description | Default |
| :--- | :--- | :--- |
| PORT | The port the Express server will listen on. | 5000 |
| NODE_ENV | Set to production to enable secure cookies (requires HTTPS). | development |
| SMTP_PASS | The password for the SMTP email account (used for password resets). | — |
Example .env Template
# Server Configuration
PORT=5000
NODE_ENV=development
SESSION_SECRET=a_very_secret_random_key_12345
# Database (PostgreSQL)
DATABASE_URL=postgresql://postgres:password@localhost:5432/hcgai_db
# AI Features
OPENAI_API_KEY=your_openai_api_key_here
# Email Service (SMTP)
# Note: Defaults to hello@in.hcgai.com via Hostinger
SMTP_PASS=your_smtp_password_here
Service-Specific Details
Database Setup
The application uses Drizzle ORM for schema management and PostgreSQL for storage. Ensure your DATABASE_URL is formatted correctly:
- Local:
postgresql://username:password@localhost:5432/database_name - Neon/Managed:
postgresql://user:password@subdomain.region.aws.neon.tech/neondb?sslmode=require
AI Chatbot Support
The "AI Chat" tab requires a valid OpenAI API key with access to GPT models. If this key is missing, the chatbot interface will return an error when queried.
SMTP Email Configuration
By default, the application is configured to send automated emails (such as password resets) through Hostinger (smtp.hostinger.com).
- If you use the default provider, simply provide the
SMTP_PASS. - To use a different provider (e.g., Gmail, SendGrid), you must manually update the transporter configuration in
simple-app-server.js(lines 151–169).
Production Considerations
When deploying to a production environment:
- Set
NODE_ENV=production. - Ensure your site is served over HTTPS, as the application will enable
secure: truefor session cookies, preventing them from being sent over unencrypted connections. - Use a high-entropy string for your
SESSION_SECRETto prevent session hijacking.