Overview
The Soft-Bee API uses PostgreSQL as its database backend. Database configuration is managed through theDATABASE_URL environment variable and varies by environment.
The application follows PostgreSQL connection URI format for database configuration.
Database URL Format
TheDATABASE_URL follows the PostgreSQL connection string format:
Components
PostgreSQL username
PostgreSQL password
Database server hostname or IP address
PostgreSQL port number
Database name
Environment-Specific Databases
Each environment uses a separate database to prevent data conflicts:Local Environment
Database connection for local development
.env.local
- Database Name:
softbee_local - Host:
localhost - Port:
5432 - User:
postgres - Password:
postgres
Development Environment
Database connection for development server
.env.development
- Database Name:
softbee_dev - Host:
localhost - Port:
5432 - User:
postgres - Password:
postgres
Production Environment
Database connection for production (REQUIRED)
.env.production
- No default value provided
- Must be explicitly configured
- Use strong credentials
- Consider using connection pooling
- Enable SSL/TLS for remote connections
Testing Environment
Database connection for automated tests
.env.testing
- Database Name:
softbee_test - Host:
localhost - Port:
5432 - User:
postgres - Password:
postgres
The test database is isolated to prevent interference with development or production data.
Additional PostgreSQL Variables
For advanced PostgreSQL configuration, you can use these optional variables:PostgreSQL username (alternative to DATABASE_URL)
PostgreSQL password (alternative to DATABASE_URL)
PostgreSQL host (alternative to DATABASE_URL)
PostgreSQL port (alternative to DATABASE_URL)
PostgreSQL database name (alternative to DATABASE_URL)
SSL mode for PostgreSQL connections (e.g.,
require, disable, prefer).env
While these individual PostgreSQL variables are supported, using
DATABASE_URL is recommended as it’s more portable and follows standard conventions.Database Setup Examples
Local Development Setup
Docker Setup
Production Setup with SSL
For production deployments with SSL-enabled PostgreSQL:Connection Pooling
For production environments with high traffic, consider using connection pooling:Troubleshooting
Connection Refused
PostgreSQL not running
PostgreSQL not running
Ensure PostgreSQL service is running:
Wrong credentials
Wrong credentials
Verify your username and password are correct:
Database doesn't exist
Database doesn't exist
Create the database if it doesn’t exist:
Port conflict
Port conflict
Check if port 5432 is available or change the port in your configuration:
Best Practices
Use separate databases per environment to prevent data contamination
Use environment variables for production credentials, never hardcode
Enable SSL/TLS for all remote database connections
Use strong passwords for production database users
Regular backups of production databases
Monitor connection pool usage in production
Next Steps
Environment Configuration
Learn about environment-specific settings
JWT Configuration
Configure authentication tokens