Skip to content

IQKV/sample-lorem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🚀 Words Processor

Lorem ipsum text processor based on the loripsum.net API.

Spring Boot RESTful microservices example (including Swagger UI), which allows to fetch, process dummy text, and generate statistical reports.

💡 Technology stack

Java 21, Maven, Spring Boot, confluentinc/cp-kafka:7.8.2, postgres:16.6.

Including utils: liquibase, WireMock, Kafka & Postgres testcontainers, Kafka healthcheck feature, docker-compose.dev.yml, checkstyle configuration, SpotBugs, PMD, etc.

✨ Applications

TLDR: All-in-one docker compose for demo propose:

docker compose -f docker-compose.yml up

App Name Description REST Endpoint (with default port settings)
words-processing Handle http rq, process rs text & generate report http://localhost:8085/api/v1/text
reports-history Provide pageable processing reports list http://localhost:8086/api/v1/history

⚙️ Environment variables

Applications are highly configurable, support many env vars, such as:

ENV Variable Description Default Value
SERVER_PORT Application port 8085, 8086
KAFKA_BOOTSTRAP_SERVERS Kafka Broker address localhost:9092
KAFKA_SECURITY_PROTOCOL PLAINTEXT
KAFKA_TOPIC_WORDS_PROCESSED Topic name words.processed
KAFKA_TOPIC_PARTITIONS_WORDS_PROCESSED Topic partitions 4
KAFKA_CONSUMER_THREADS Consumer threads count,
respective to partitions
4
KAFKA_CONSUMERS_GROUP Consumer group name reports-history
KAFKA_ADMIN_CREATES_TOPICS Enables Kafka Admin for topic creation true
DATASOURCE_URL jdbc:postgresql://localhost:5432/lorem_db
DATASOURCE_USERNAME postgres
DATASOURCE_PASSWORD postgres
DATASOURCE_DRIVER org.postgresql.Driver

📚 Code conventions

The code follows Google Code Conventions. Code quality is measured by:

Tests

This project contains JUnit tests, Hamcrest matchers, Mockito test doubles, Wiremock stubs, etc. You can run the test suite using

./mvnw verify -P use-testcontainers

The minimum percentage of code coverage required for the workflow to pass is 80%.

Pre-Requisites to run this example locally

git clone https://github.com/IQKV/sample-lorem.git

cd sample-lorem
docker compose -f compose.yaml up -d

Running locally

This application is a Spring Boot application built using Maven. You can build jar files and run it from the command line:

  • Create jar packages:
./mvnw package
  • Run words-processing app:
java -jar words-processing/target/*.jar

Now you can access to the Swagger UI here: http://localhost:8085/swagger-ui.html

  • Run reports-history app:
java -jar reports-history/target/*.jar

Swagger UI is here: http://localhost:8086/swagger-ui.html

After all, don't forget to clean up the working directory & stop dev services:
./mvnw clean
docker compose -f compose.yaml down

Versioning

Project uses a three-segment CalVer scheme, with a short year in the major version slot, short month in the minor version slot, and micro/patch version in the third and final slot.

 YY.MM.MICRO
  1. YY - short year - 6, 16, 106
  2. MM - short month - 1, 2 ... 11, 12
  3. MICRO - "patch" segment