- Golang
- Docker and Docker Compose
- Supported platforms:
- Linux-based environment
- macOS (Darwin)
- WSL under Windows
The easiest way to get started is using our Docker Compose setup:
# Clone the repository
git clone https://github.com/flexprice/flexprice
cd flexprice
# Set up the complete development environment
make dev-setupThis command will:
- Start all required infrastructure (PostgreSQL, Kafka, ClickHouse, Temporal)
- Build the FlexPrice application image
- Run database migrations and initialize Kafka
- Start all FlexPrice services (API, Consumer, Worker)
Once setup is complete, you can access:
- FlexPrice API: http://localhost:8080
- Temporal UI: http://localhost:8088
- Kafka UI: http://localhost:8084 (with profile 'dev')
- ClickHouse UI: http://localhost:8123
# Restart only the FlexPrice services
make restart-flexprice
# Stop all services
make down
# Clean everything and start fresh
make clean-start
# Build the FlexPrice image separately
make build-image
# Start only the FlexPrice services
make start-flexpriceIf you prefer to run the application directly:
# Start the required infrastructure
docker compose up -d postgres kafka clickhouse temporal temporal-ui
# Run the application locally
go run cmd/server/main.go- Host: localhost
- Port: 5432
- Database: flexprice
- Username: flexprice
- Password: flexprice123
- Host: localhost
- Port: 9000
- Database: flexprice
- Username: flexprice
- Password: flexprice123
- Bootstrap Server: localhost:29092
- UI: http://localhost:8084 (with profile 'dev')
The API documentation is available in OpenAPI 3.0 format at docs/swagger/swagger-3-0.json.
-
Open Postman
-
Click on "Import" in the top left
-
Select "Import File"
-
Choose
docs/swagger/swagger-3-0.json -
Click "Import"
-
Create a new environment for local development:
-
Name: Local
-
Variable:
baseUrl -
Initial Value:
http://localhost:8080/v1 -
Current Value:
http://localhost:8080/v1 -
Variable:
apiKey -
Initial Value:
0cc505d7b917e0b1f25ccbea029dd43f4002edfea46b7f941f281911246768fe -
Current Value:
0cc505d7b917e0b1f25ccbea029dd43f4002edfea46b7f941f281911246768fe
-
- Ensure Docker is running properly:
docker info- Check the status of all containers:
docker compose ps- View logs for a specific service:
docker compose logs [service_name]- Check database logs:
docker compose logs postgres
docker compose logs clickhouse- Verify the database is running:
docker compose ps postgres
docker compose ps clickhouse- Verify Kafka is running:
docker compose logs kafka- Check topic list:
docker compose exec kafka kafka-topics --bootstrap-server kafka:9092 --list- View Kafka UI at http://localhost:8084
If you wish to enable S3 storage for your FlexPrice API, follow these steps to configure your AWS S3 access:
- Log in to your AWS Management Console.
- Navigate to the S3 service.
- Create a new bucket named
<YOUR BUCKET NAME>(or use an existing bucket). - Ensure that the bucket is in the desired region.
- It is highly recommended to disable public access to the bucket, the API generates presigned URLs in the response which can be used to download the invoice.
To allow FlexPrice to access the S3 bucket, you need to set up a bucket policy. Use the following policy, remembering to replace the bucket name with the name of your bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::<YOUR BUCKET NAME>/*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::<YOUR BUCKET NAME>"
}
]
}Ensure that your AWS credentials are configured on the server where the FlexPrice API will run. You can set up your credentials in the ~/.aws/credentials file as follows:
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEYIf using a different profile, you can set the profile name in the ~/.aws/config file:
[<YOUR PROFILE NAME>]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEYDo remember to set the AWS_PROFILE environment variable to the profile name you just set up.
Edit the internal/config/config.yaml file and set the s3 section to the following:
s3:
enabled: false
region: <YOUR BUCKET REGION>
invoice:
bucket: <YOUR BUCKET NAME>
presign_expiry_duration: "1h" # The duration for which the presigned URL is valid (https://pkg.go.dev/time#ParseDuration)
key_prefix: ""
# The prefix for the invoice key in the bucket (defaults to empty and the invoice is stored under the tenant id folder - eg. {tenant_id}/{invoice_id}.pdf)Once you have configured the S3 bucket and set the necessary environment variables, you can start your FlexPrice API. The application will now be able to interact with the S3 bucket for storing and retrieving invoices.
If you encounter issues with S3 access, check the following:
- Ensure that the bucket policy is correctly applied to the bucket.
- Verify that your AWS credentials have the necessary permissions.
- Check the logs for any errors related to S3 operations.
By following these steps, you can successfully set up S3 as an optional storage solution for your self-hosted FlexPrice API.