A Spring Boot application for managing customer onboarding workflows with automated email sequences using Temporal.io for workflow orchestration.
- Customer onboarding workflow management
- Database-backed email template management with full CRUD operations
- Dynamic email sequence creation and management
- Template preview and validation system
- Automated email sequences with AWS SES
- Temporal.io workflow orchestration
- PostgreSQL database with JPA/Hibernate
- Comprehensive REST APIs for onboarding, templates, and sequences
- Email event tracking and analytics
- User action tracking
- Java 21
- Maven 3.6+
- PostgreSQL 12+
- Temporal Server
- AWS SES (for email sending)
- Install PostgreSQL and create a database:
CREATE DATABASE onboard_flow;
CREATE USER postgres WITH PASSWORD 'postgres';
GRANT ALL PRIVILEGES ON DATABASE onboard_flow TO postgres;
- The application will automatically create tables using the schema in
src/main/resources/schema.sql
- Install Temporal CLI:
# macOS
brew install temporal
# Or download from https://github.com/temporalio/cli/releases
- Start Temporal server:
temporal server start-dev --namespace onboard
The Temporal Web UI will be available at http://localhost:8233
- Set up AWS SES in your AWS account
- Verify your sender email address
- Get your AWS credentials (Access Key ID and Secret Access Key)
Set the following environment variables or update application.yml
:
# AWS Configuration
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export [email protected]
export SES_FROM_NAME="Your Company"
# Database (optional, defaults provided)
export DB_URL=jdbc:postgresql://localhost:5432/onboard_flow
export DB_USERNAME=postgres
export DB_PASSWORD=postgres
- Clone the repository:
git clone <repository-url>
cd onboard-flow
- Install dependencies and run:
mvn clean install
mvn spring-boot:run
The application will start on http://localhost:8080
POST /api/onboarding/start
- Start customer onboardingGET /api/onboarding/progress/{customerId}
- Get onboarding progressPOST /api/onboarding/pause/{customerId}
- Pause onboardingPOST /api/onboarding/resume/{customerId}
- Resume onboardingPOST /api/onboarding/complete/{customerId}
- Complete onboarding
POST /api/v1/templates
- Create new email templateGET /api/v1/templates
- List all email templatesGET /api/v1/templates/{id}
- Get template by IDPUT /api/v1/templates/{id}
- Update email templateDELETE /api/v1/templates/{id}
- Delete email templatePOST /api/v1/templates/{id}/activate
- Activate templatePOST /api/v1/templates/{id}/deactivate
- Deactivate templatePOST /api/v1/templates/{id}/preview
- Preview rendered template
POST /api/v1/sequences
- Create new email sequenceGET /api/v1/sequences
- List all email sequencesGET /api/v1/sequences/{id}
- Get sequence by IDPUT /api/v1/sequences/{id}
- Update email sequenceDELETE /api/v1/sequences/{id}
- Delete email sequencePOST /api/v1/sequences/{id}/activate
- Activate sequencePOST /api/v1/sequences/{id}/deactivate
- Deactivate sequencePOST /api/v1/sequences/{id}/validate
- Validate sequence configurationGET /api/v1/sequences/{id}/steps
- Get sequence stepsPOST /api/v1/sequences/{id}/steps
- Add step to sequencePUT /api/v1/sequences/{id}/steps/{order}
- Update sequence stepDELETE /api/v1/sequences/{id}/steps/{order}
- Delete sequence step
curl -X POST http://localhost:8080/api/onboarding/start \
-H "Content-Type: application/json" \
-d '{
"customer": {
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"companyName": "Example Corp"
},
"sequenceId": "default-sequence-slug"
}'
curl -X POST http://localhost:8080/api/v1/templates \
-H "Content-Type: application/json" \
-d '{
"id": "welcome-v2",
"name": "Welcome Email v2",
"subject": "Welcome to {{companyName}}, {{firstName}}!",
"htmlBody": "<html><body><h1>Welcome {{firstName}}!</h1><p>We are excited to have you join us...</p></body></html>",
"textBody": "Welcome {{firstName}}!\n\nWe are excited to have you join..."
}'
curl -X POST http://localhost:8080/api/v1/sequences \
-H "Content-Type: application/json" \
-d '{
"name": "SaaS Trial Sequence",
"description": "14-day trial onboarding sequence",
"maxDurationDays": 21,
"steps": [
{
"stepOrder": 1,
"emailTemplateId": "trial-welcome",
"delayFromStartHours": 0,
"sendConditions": []
},
{
"stepOrder": 2,
"emailTemplateId": "trial-reminder",
"delayFromStartHours": 72,
"sendConditions": ["user_not_active"]
}
]
}'
src/main/java/com/hooswhere/onboardFlow/
├── OnboardFlowApplication.java # Main application class
├── api/ # REST API controllers
├── config/ # Configuration classes
├── entity/ # JPA entities
├── models/ # Request/Response models
├── repository/ # Data repositories
├── service/ # Business logic services
└── temporal/ # Temporal workflow definitions
The application uses the following main tables:
customers
- Customer informationemail_templates
- Email template storage with HTML/text contentemail_sequences
- Email sequence configurationsemail_steps
- Individual steps in email sequencesonboarding_progress
- Tracking onboarding statusemail_events
- Email delivery and engagement eventsuser_actions
- Customer action tracking
mvn test
mvn clean package
The JAR file will be created in the target/
directory.
Create a Dockerfile
in the project root:
FROM openjdk:21-jre-slim
COPY target/onboard-flow-1.0-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]
Build and run:
mvn clean package
docker build -t onboard-flow .
docker run -p 8080:8080 onboard-flow
- Application metrics: http://localhost:8080/actuator (if Spring Actuator is added)
- Temporal workflows: http://localhost:8233
- Database: Connect to PostgreSQL with your preferred client
- Database connection errors: Ensure PostgreSQL is running and credentials are correct
- Temporal connection errors: Make sure Temporal server is running with the correct namespace
- AWS SES errors: Verify AWS credentials and that your sender email is verified in SES
- Port conflicts: Change the server port in
application.yml
if 8080 is in use
Application logs will show detailed information about workflow execution, email sending, and any errors.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
[Your License Here]