Configuration Methods
Flexprice can be configured using:
- Environment variables (recommended)
- Configuration files
- Command-line arguments (for specific overrides)
Environment Variables
Environment variables are the recommended way to configure Flexprice. All environment variables are prefixed with FLEXPRICE_
. Here’s a comprehensive list of available variables:
Deployment Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_DEPLOYMENT_MODE | Deployment mode (local, api, consumer, temporal_worker, aws_lambda_api, aws_lambda_consumer) | local | No |
FLEXPRICE_SERVER_ADDRESS | Server address and port | :8080 | No |
Authentication Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_AUTH_PROVIDER | Authentication provider (flexprice, supabase) | flexprice | No |
FLEXPRICE_AUTH_SECRET | Secret key for authentication | - | Yes |
FLEXPRICE_AUTH_SUPABASE_BASE_URL | Supabase base URL (if using Supabase auth) | - | Only if using Supabase |
FLEXPRICE_AUTH_SUPABASE_SERVICE_KEY | Supabase service key | - | Only if using Supabase |
FLEXPRICE_AUTH_API_KEY_HEADER | Header name for API key authentication | x-api-key | No |
FLEXPRICE_AUTH_API_KEY_KEYS | JSON string of API keys configuration | - | No |
Database Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_POSTGRES_HOST | PostgreSQL host | localhost | No |
FLEXPRICE_POSTGRES_PORT | PostgreSQL port | 5432 | No |
FLEXPRICE_POSTGRES_USER | PostgreSQL username | flexprice | No |
FLEXPRICE_POSTGRES_PASSWORD | PostgreSQL password | flexprice123 | Yes |
FLEXPRICE_POSTGRES_DBNAME | PostgreSQL database name | flexprice | No |
FLEXPRICE_POSTGRES_SSLMODE | PostgreSQL SSL mode (disable, require) | disable | No |
FLEXPRICE_POSTGRES_AUTO_MIGRATE | Automatically run migrations on startup | false | No |
ClickHouse Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_CLICKHOUSE_ADDRESS | ClickHouse address (host:port) | localhost:9000 | No |
FLEXPRICE_CLICKHOUSE_TLS | Use TLS for ClickHouse connection | false | No |
FLEXPRICE_CLICKHOUSE_USERNAME | ClickHouse username | flexprice | No |
FLEXPRICE_CLICKHOUSE_PASSWORD | ClickHouse password | flexprice123 | Yes |
FLEXPRICE_CLICKHOUSE_DATABASE | ClickHouse database name | flexprice | No |
Kafka Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_KAFKA_BROKERS | Kafka brokers (comma-separated) | localhost:29092 | No |
FLEXPRICE_KAFKA_CONSUMER_GROUP | Kafka consumer group ID | flexprice-consumer-local | No |
FLEXPRICE_KAFKA_TOPIC | Kafka topic for events | events | No |
FLEXPRICE_KAFKA_USE_SASL | Use SASL authentication for Kafka | false | No |
FLEXPRICE_KAFKA_SASL_MECHANISM | SASL mechanism (PLAIN, SCRAM-SHA-256, etc.) | - | Only if SASL is enabled |
FLEXPRICE_KAFKA_SASL_USER | SASL username | - | Only if SASL is enabled |
FLEXPRICE_KAFKA_SASL_PASSWORD | SASL password | - | Only if SASL is enabled |
FLEXPRICE_KAFKA_CLIENT_ID | Kafka client ID | flexprice-client-local | No |
Temporal Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_TEMPORAL_ADDRESS | Temporal service address | localhost:7233 | No |
FLEXPRICE_TEMPORAL_TLS | Use TLS for Temporal connection | false | No |
FLEXPRICE_TEMPORAL_NAMESPACE | Temporal namespace | default | No |
FLEXPRICE_TEMPORAL_TASK_QUEUE | Temporal task queue | billing-task-queue | No |
FLEXPRICE_TEMPORAL_API_KEY | Temporal API key | - | Only if using Temporal Cloud |
FLEXPRICE_TEMPORAL_API_KEY_NAME | Temporal API key name | - | Only if using Temporal Cloud |
Logging and Monitoring
Variable | Description | Default | Required |
---|
FLEXPRICE_LOGGING_LEVEL | Logging level (debug, info, warn, error) | info | No |
FLEXPRICE_SENTRY_ENABLED | Enable Sentry error reporting | false | No |
FLEXPRICE_SENTRY_DSN | Sentry DSN | - | Only if Sentry is enabled |
FLEXPRICE_SENTRY_ENVIRONMENT | Sentry environment | development | No |
FLEXPRICE_SENTRY_SAMPLE_RATE | Sentry sampling rate (0.0-1.0) | 1.0 | No |
DynamoDB Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_DYNAMODB_IN_USE | Use DynamoDB for event storage | false | No |
FLEXPRICE_DYNAMODB_REGION | AWS region for DynamoDB | us-east-1 | Only if DynamoDB is enabled |
FLEXPRICE_DYNAMODB_EVENT_TABLE_NAME | DynamoDB table name for events | events | Only if DynamoDB is enabled |
Webhook Configuration
Variable | Description | Default | Required |
---|
FLEXPRICE_WEBHOOK_MAX_RETRIES | Maximum number of webhook retry attempts | 3 | No |
FLEXPRICE_WEBHOOK_INITIAL_INTERVAL | Initial retry interval (e.g., 1s) | 1s | No |
FLEXPRICE_WEBHOOK_MAX_INTERVAL | Maximum retry interval (e.g., 10s) | 10s | No |
FLEXPRICE_WEBHOOK_MULTIPLIER | Backoff multiplier for retries | 2.0 | No |
FLEXPRICE_WEBHOOK_MAX_ELAPSED_TIME | Maximum total retry time (e.g., 2m) | 2m | No |
Event Publishing
Variable | Description | Default | Required |
---|
FLEXPRICE_EVENT_PUBLISH_DESTINATION | Event publishing destination (kafka, dynamodb, all) | kafka | No |
Using a .env File
For local development, you can use a .env
file to set environment variables. Create a file named .env
in the root directory of your project:
When using Docker Compose, you can specify environment variables in your docker-compose.yml
file or use the .env
file directly.
Configuration File
For more complex configurations, you can use a YAML configuration file. By default, Flexprice looks for a file named config.yaml
in the internal/config
directory:
Environment variables take precedence over configuration file settings. If an environment variable is set, it will override the corresponding value in the configuration file.
Production Best Practices
When configuring Flexprice for production, follow these best practices:
Security
- Use strong, unique passwords for all database users
- Enable SSL/TLS for all external connections
- Set up a firewall to restrict access to your servers
- Use a secure API key for authentication
- Rotate secrets regularly to maintain security
- Allocate sufficient resources to each component based on your expected load
- Monitor resource usage and scale as needed
- Configure appropriate Kafka settings for your message volume
- Adjust database connection pools based on your workload
High Availability
- Set up database replication for PostgreSQL and ClickHouse
- Deploy multiple API server instances behind a load balancer
- Configure Kafka with multiple brokers in a cluster
- Implement automated backups for all data stores
Next Steps
After configuring your Flexprice instance, you should:
- Set up monitoring and alerting for your instance
- Implement a backup strategy for your data
- Plan for regular updates to keep your instance secure and up-to-date