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.
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.
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 |
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 |
The code follows Google Code Conventions. Code quality is measured by:
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%.
- Set up git command line tool (https://help.github.com/articles/set-up-git)
- Clone the source code to the local machine:
git clone https://github.com/IQKV/sample-lorem.git
cd sample-lorem
- Install Docker https://docs.docker.com/get-docker/
- Add new version of Docker Compose https://docs.docker.com/compose/install/
- Spin up a single instance of Kafka broker, ZooKeeper, and Postgresql by running the command:
docker compose -f compose.yaml up -d
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
./mvnw clean
docker compose -f compose.yaml down
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
- YY - short year - 6, 16, 106
- MM - short month - 1, 2 ... 11, 12
- MICRO - "patch" segment