Environment Variables
Environment Variables
The HCG AI application requires several environment variables to manage database connections, authentication security, and external API integrations. Create a .env file in the project root and populate it with the variables listed below.
Core Configuration
| Variable | Description | Default |
| :--- | :--- | :--- |
| DATABASE_URL | PostgreSQL connection string. Supports local instances and cloud providers like Neon. | None (Required) |
| PORT | The port on which the Express server will run. | 5000 |
| NODE_ENV | Sets the application environment. Set to production to enable secure cookies. | development |
Security & Authentication
| Variable | Description |
| :--- | :--- |
| SESSION_SECRET | A long, random string used to sign the session ID cookie. This is critical for preventing session hijacking. |
AI Service (OpenAI)
The chatbot feature requires a valid OpenAI API key. Without this, the AI Chat tab will not return responses.
| Variable | Description |
| :--- | :--- |
| OPENAI_API_KEY | Your secret API key from the OpenAI Platform. |
Mail Server (SMTP)
The application uses SMTP to send password reset emails. By default, the system is configured to use Hostinger (smtp.hostinger.com).
| Variable | Description |
| :--- | :--- |
| SMTP_PASS | The password for the system email account (hello@in.hcgai.com). |
Note: If you wish to use a different email provider, you must update the transporter configuration in
simple-app-server.js(lines 151–169) in addition to providing the password here.
Example .env File
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
# Format: postgresql://[user]:[password]@[host]:[port]/[database]
DATABASE_URL=postgresql://postgres:password@localhost:5432/hcgai_db
# Security
# Replace with a unique random string for production
SESSION_SECRET=your_complex_session_secret_here
# Third-Party Services
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxx
SMTP_PASS=your_smtp_app_password
Validation & Troubleshooting
- Database: If the application fails to start, verify that the
DATABASE_URLis correct by runningpsql $DATABASE_URL. - Sessions: In production, if users are unable to stay logged in, ensure
NODE_ENVis set toproductionand you are using HTTPS, as cookies are configured to besecurein that environment. - Missing Keys: If
OPENAI_API_KEYorSMTP_PASSare missing, the core tracking features will still function, but the AI Chat and Password Reset features will throw errors in the server logs.