Development Environment Setup
Development Environment Setup
This section provides comprehensive instructions for setting up your local development environment to work with the faizanGeek/ClaimProcessingSystem. It covers the necessary tools, external services, and steps to get the application running for development and testing.
Prerequisites
Before you begin, ensure you have the following software installed on your system:
- Java Development Kit (JDK) 17 or higher: The application is built using Java.
- Verify with:
java -version
- Verify with:
- Maven 3.6.3 or higher: Used for building and managing project dependencies.
- Verify with:
mvn -v
- Verify with:
- Git: For cloning the source code repository.
- Verify with:
git --version
- Verify with:
- Docker and Docker Compose: Highly recommended for easily running external dependencies like Kafka, Redis, and a database in isolated containers.
- Verify with:
docker --versionanddocker-compose --version
- Verify with:
- An Integrated Development Environment (IDE):
- IntelliJ IDEA Community/Ultimate (Recommended for Spring Boot development)
- Eclipse IDE for Java Developers
- Visual Studio Code with Java Extension Pack
1. Get the Code
First, clone the ClaimProcessingSystem repository to your local machine using Git:
git clone https://github.com/faizanGeek/ClaimProcessingSystem.git
cd ClaimProcessingSystem
2. Set Up External Services with Docker Compose
The ClaimProcessingSystem integrates with several external services: a relational database (e.g., PostgreSQL), Apache Kafka for messaging, Redis for caching, and an SMTP server for email notifications. Using Docker Compose is the most convenient way to quickly set up these dependencies for local development.
Create a docker-compose.yml file in the root of your ClaimProcessingSystem project directory with the following content:
version: '3.8'
services:
# PostgreSQL Database
db:
image: postgres:13
container_name: postgres-db
environment:
POSTGRES_DB: claim_processing_db
POSTGRES_USER: devuser
POSTGRES_PASSWORD: devpassword
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U devuser -d claim_processing_db"]
interval: 5s
timeout: 5s
retries: 5
# Zookeeper (required for Kafka)
zookeeper:
image: confluentinc/cp-zookeeper:7.3.0
container_name: zookeeper
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
# Apache Kafka Broker
kafka:
image: confluentinc/cp-kafka:7.3.0
container_name: kafka
hostname: kafka
ports:
- "9092:9092" # Internal listener (Docker network)
- "9093:9093" # External listener (host machine)
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
depends_on:
- zookeeper
healthcheck:
test: ["CMD", "kafka-topics", "--bootstrap-server", "localhost:9092", "--list"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:6.2-alpine
container_name: redis-cache
ports:
- "6379:6379"
command: redis-server --appendonly yes
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
# MailHog (Local SMTP server for testing emails)
mailhog:
image: mailhog/mailhog
container_name: mailhog
ports:
- "8025:8025" # Web UI to view emails
- "1025:1025" # SMTP port for the application
logging:
driver: "none" # Disable logging to keep terminal clean
volumes:
postgres_data:
redis_data:
Once the docker-compose.yml file is created, navigate to the project root in your terminal and start the services:
docker-compose up -d
This command will download the necessary Docker images (if not already present) and start the containers in the background.
- PostgreSQL: Accessible at
localhost:5432. - Kafka: Accessible by the application at
localhost:9093. - Redis: Accessible at
localhost:6379. - MailHog: Its web interface for viewing sent emails is available at
http://localhost:8025, and the SMTP server listens onlocalhost:1025.
3. Configure the Application
The ClaimProcessingSystem uses src/main/resources/application.properties (or application.yml) for its configuration. You'll need to configure the connection details for the database, Kafka, Redis, and email services to match your Docker Compose setup.
Create or update src/main/resources/application.properties with the following settings:
# ===============================================
# Database Configuration (PostgreSQL example)
# ===============================================
spring.datasource.url=jdbc:postgresql://localhost:5432/claim_processing_db
spring.datasource.username=devuser
spring.datasource.password=devpassword
spring.datasource.driver-class-name=org.postgresql.Driver
# 'update' automatically updates the database schema based on entities.
# Use 'validate' or 'none' for production environments.
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
# ===============================================
# Kafka Configuration
# ===============================================
# Use 9093 for connecting from the host machine to the Kafka container
spring.kafka.bootstrap-servers=localhost:9093
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
# Default consumer group ID
spring.kafka.consumer.group-id=group_id
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
# Specify the default type for JSON deserialization if the consumer factory doesn't explicitly define it
spring.kafka.consumer.properties.spring.json.value.default.type=com.claim.demo.dto.ClaimStatusUpdateMessage
# ===============================================
# Redis Configuration
# ===============================================
spring.redis.host=localhost
spring.redis.port=6379
# ===============================================
# Email Configuration (MailHog example)
# ===============================================
spring.mail.host=localhost
spring.mail.port=1025
# MailHog does not require username/password or authentication
spring.mail.username=
spring.mail.password=
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false
# ===============================================
# Logging Configuration
# ===============================================
logging.level.com.claim.demo=DEBUG
logging.level.org.springframework.web=INFO
Note on Database Driver: Ensure your pom.xml includes the PostgreSQL JDBC driver dependency:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
If you prefer to use an embedded H2 database for a simpler setup without Docker for the database, you can modify the spring.datasource.* properties and add the H2 dependency.
4. Build and Run the Application
You can build and run the application using Maven from your terminal or directly from your IDE.
From the Terminal (Maven)
-
Build the project: Navigate to the
ClaimProcessingSystemroot directory in your terminal and run:mvn clean installThis command compiles the code, runs tests, and packages the application into a JAR file.
-
Run the application: After a successful build, you can run the application directly using Spring Boot's Maven plugin:
mvn spring-boot:runAlternatively, you can run the generated JAR file:
java -jar target/ClaimProcessingSystem-0.0.1-SNAPSHOT.jar # Adjust version as needed
From an IDE (IntelliJ IDEA, Eclipse, VS Code)
-
Import the project:
- IntelliJ IDEA: Select
File>Open> Navigate to theClaimProcessingSystemdirectory > Select thepom.xmlfile > ChooseOpen as Project. - Eclipse: Select
File>Import>Maven>Existing Maven Projects>Browseto theClaimProcessingSystemdirectory >Finish. - VS Code: Select
File>Open Folder> Navigate to theClaimProcessingSystemdirectory. Ensure you have the necessary Java extensions installed (e.g., Java Extension Pack).
- IntelliJ IDEA: Select
-
Run
ProcessingApplication.java: Locate the main application class atsrc/main/java/com/claim/demo/ProcessingApplication.java. Most IDEs provide a convenient run button next to themainmethod. Alternatively, right-click on the file and select "Run As Java Application" or "Run 'ProcessingApplication'".
Once the application starts successfully, you should see logs indicating that Spring Boot has initialized and started the ClaimProcessingSystem, typically on port 8080.
You are now ready to develop and test features for the ClaimProcessingSystem.