Overview
Med Agenda uses environment variables for configuration, following the 12-factor app methodology. This allows the same application build to be deployed across different environments.Configuration Sources
Environment variables can be provided through:- System environment variables:
export VAR=value .envfile: For local development (Docker Compose)application.properties: Default values and variable references- Docker:
-eflag orenv_filein docker-compose.yml - Cloud platforms: Platform-specific environment variable settings
Required Variables
Database Configuration
PostgreSQL JDBC connection stringFormat: Production Example (Neon.tech):
jdbc:postgresql://host:port/database?parametersExample:Database usernameExample:
Database passwordExample:
Payment Integration
Abacate Pay API key for payment processingExample:
Optional Variables
Server Configuration
Port number for the application serverExample:
If running in Docker, ensure the container exposes this port.
Database Pool Settings
Maximum number of connections in the HikariCP connection poolRecommended values:
- Development:
5-10 - Production:
20-50 - High traffic:
50-100
JPA/Hibernate Settings
Hibernate DDL auto mode for schema managementOptions:
update: Auto-update schema (development)validate: Validate schema only (production)create: Drop and recreate schema (testing only)none: No schema management
Enable SQL query loggingExample:
Set to
true for debugging, but disable in production for performance.JVM Options (Docker only)
Custom JVM options for memory, garbage collection, etc.Example:Common options:
-Xms: Initial heap size-Xmx: Maximum heap size-XX:+UseG1GC: Use G1 garbage collector-XX:+HeapDumpOnOutOfMemoryError: Create heap dump on OOM
Email Service Configuration
Med Agenda uses Resend for sending email notifications.Recommended Email Variables
While not currently supported, these should be added for production:- API Key: Hardcoded as
re_6gEiCUYB_D8rKKD2XZPJRhUXQCh6gQwpX - From Email:
[email protected]
Consider refactoring
EmailService.java to read these from environment variables for better security.Configuration Files
application.properties
The default configuration file with variable references:.env File Example
Create a.env file for local development:
Setting Environment Variables
Linux/macOS
Windows
Docker
Security Best Practices
1. Never Commit Secrets
Add.env to .gitignore:
.gitignore
2. Use Different Keys per Environment
| Environment | Key Type |
|---|---|
| Development | Test/sandbox keys |
| Staging | Test keys |
| Production | Live production keys |
3. Rotate Secrets Regularly
- Change database passwords periodically
- Rotate API keys every 90 days
- Update credentials after team member changes
4. Use Secrets Management
For production deployments, use dedicated secrets management:- AWS Secrets Manager
- HashiCorp Vault
- Docker Secrets
- Kubernetes Secrets
5. Restrict File Permissions
6. Validate Configuration
Create a startup check to ensure required variables are set:Verification
Verify your configuration is loaded correctly:Check Environment Variables
Application Startup Logs
Check logs for configuration values:Troubleshooting
Variable not being read
Variable not being read
Ensure variable is exported before running:For Docker, ensure it’s in
.env file or passed with -e flag.Database connection fails
Database connection fails
Verify connection string format:
Port already in use
Port already in use
Change the server port:Or kill process using the port:
Special characters in password
Special characters in password
URL-encode special characters in connection string or use separate username/password variables:
Environment Variable Reference
Complete List
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
SPRING_DATASOURCE_URL | string | jdbc:postgresql://localhost:5432/postgres | Yes | Database connection URL |
SPRING_DATASOURCE_USERNAME | string | postgres | Yes | Database username |
SPRING_DATASOURCE_PASSWORD | string | postgres | Yes | Database password |
ABACATE-KEY | string | - | Yes | Abacate Pay API key |
SERVER_PORT | integer | 8080 | No | Application server port |
DB_POOL_MAX | integer | 10 | No | Max connection pool size |
JPA_DDL_AUTO | string | update | No | Hibernate DDL mode |
JPA_SHOW_SQL | boolean | false | No | Enable SQL logging |
JAVA_OPTS | string | "" | No | Custom JVM options |
Next Steps
Installation Guide
Complete installation setup
Docker Deployment
Deploy with Docker
Database Setup
Configure PostgreSQL