> For the complete documentation index, see [llms.txt](https://rajadilipkolli.gitbook.io/my-spring-boot-experiments/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rajadilipkolli.gitbook.io/my-spring-boot-experiments/readme.md).

# README

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Spring Boot Integration Experiments

This repository contains a collection of sample projects and experiments showcasing various Spring Boot integrations and features. The goal is to help you explore new possibilities, demonstrate best practices, and provide ready-to-use examples.

***

### Table of Contents

* [Overview](#overview)
* [Projects](#projects)
* [Tech Stack](#tech-stack)
* [Useful Docker Commands](#useful-docker-commands)
* [Useful git Commands](#useful-git-commands)

***

### Overview

Each subdirectory in this repository demonstrates a focused aspect of Spring Boot development ranging from database integrations, caching, messaging, and multi-tenancy to advanced topics like Chaos Engineering and observability.

**Key Features**:

1. **Wide Range of Integrations**: Explore different databases (MySQL, PostgreSQL, MongoDB, Oracle), caching with Redis, and advanced topics like multi-tenancy.
2. **Observability & Monitoring**: Many samples include Prometheus, Grafana, or Kibana. They demonstrate setting up and analyzing application performance in real-time.
3. **Scalability & Resilience Patterns**: Investigate Chaos Monkey for injecting controlled failures, or look at multi-database solutions for horizontal scaling.

***

### Projects

Below is a quick lookup table summarizing each sub-project. For more details, check their individual README.md files.

| Name                                                                                                                                               | Description                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| [Spring Batch Implementation](/my-spring-boot-experiments/batch-boot-jpa-sample.md)                                                                | Demonstrates how to use Spring Batch 5 with a straightforward configuration.                                |
| [Archunit Implementation](/my-spring-boot-experiments/boot-api-archunit-sample.md)                                                                 | Shows how to enforce architectural constraints in a Spring Boot project using ArchUnit.                     |
| [Chaos Engineering Principles](/my-spring-boot-experiments/boot-chaos-monkey.md)                                                                   | Covers applying Chaos Engineering with Spring Boot, along with performance tests.                           |
| [Grafana LGTM](https://github.com/rajadilipkolli/my-spring-boot-experiments/blob/main/boot-grafana-lgtm/README.md)                                 | Demonstrates an observability stack with Loki, Grafana, Tempo, and Mimir.                                   |
| [HTTP Proxy Implementation](/my-spring-boot-experiments/httpclients/boot-http-proxy.md)                                                            | Implements HTTP proxy functionality for routing and managing HTTP requests.                                 |
| [JMH Benchmark](/my-spring-boot-experiments/jmh-benchmark.md)                                                                                      | Provides microbenchmarking capabilities using JMH for measuring code performance.                           |
| [Mongodb and Elasticsearch Reactive integration](/my-spring-boot-experiments/boot-mongodb-elasticsearch.md)                                        | Illustrates storing data in MongoDB, then retrieving it using reactive Elasticsearch.                       |
| [OpenAPI Implementation](/my-spring-boot-experiments/open-api-spring-boot.md)                                                                      | Demonstrates OpenAPI specification generation and documentation using Swagger.                              |
| [Opensearch Integration](/my-spring-boot-experiments/boot-opensearch-sample.md)                                                                    | Showcases saving data and performing swift geospatial searches in OpenSearch.                               |
| [Rabbit Mq Implementation](/my-spring-boot-experiments/boot-rabbitmq-thymeleaf.md)                                                                 | Demonstrates RabbitMQ producer acknowledgments, a Dead Letter Queue setup, and more.                        |
| [Rest API Documentation with examples](/my-spring-boot-experiments/boot-rest-docs-sample.md)                                                       | Highlights generating PDF documentation of RESTful APIs using Spring REST Docs.                             |
| [RestClient Implementation](/my-spring-boot-experiments/httpclients/boot-restclient.md)                                                            | Introduces Spring 6's RestClient as a modern alternative to WebClient/RestTemplate.                         |
| [RestTemplate Implementation](/my-spring-boot-experiments/httpclients/boot-rest-template.md)                                                       | Shows how to use Spring's RestTemplate for making HTTP requests to RESTful services.                        |
| [Implementation of Strategy Design Pattern](https://github.com/rajadilipkolli/my-spring-boot-experiments/blob/main/boot-strategy-plugin/README.md) | Uses the Strategy Pattern within a Spring application, builds a native image.                               |
| [Feature Toggles](/my-spring-boot-experiments/boot-togglz-sample.md)                                                                               | Demonstrates toggling specific features on or off at runtime in a Spring Boot application.                  |
| [Ultimate Redis Implementation](/my-spring-boot-experiments/boot-ultimate-redis.md)                                                                | Explores multiple Redis usage patterns with varying time-to-live (TTL) settings.                            |
| [WebClient MVC Implementation](/my-spring-boot-experiments/httpclients/boot-web-client-mvc.md)                                                     | Demonstrates using WebClient with Spring MVC for HTTP operations.                                           |
| [WebClient WebFlux Implementation](/my-spring-boot-experiments/httpclients/boot-web-client-webflux.md)                                             | Shows WebClient usage with WebFlux for reactive HTTP operations.                                            |
| [Graph QL implementation using QueryDSL](/my-spring-boot-experiments/graphql/boot-graphql-querydsl.md)                                             | Illustrates integrating GraphQL with QueryDSL to interact with a database.                                  |
| [Graph QL implementation using webflux](/my-spring-boot-experiments/graphql/boot-graphql-webflux.md)                                               | Showcases using GraphQL alongside the reactive WebFlux stack for asynchronous processing.                   |
| [Graph QL implementation using webmvc](/my-spring-boot-experiments/graphql/boot-graphql-webmvc.md)                                                 | Demonstrates applying GraphQL concepts with the traditional Spring MVC for synchronous processing.          |
| [Custom SequenceNumber and LazyConnectionDataSourceProxy](/my-spring-boot-experiments/jpa/boot-data-customsequence.md)                             | Highlights creating custom sequence generators and optimizing database connections.                         |
| [Hibernate Envers Implementation using spring data JPA](/my-spring-boot-experiments/jpa/boot-data-envers.md)                                       | Shows how to track entity revisions with Hibernate Envers and monitor system changes.                       |
| [Connecting to multiple data sources](/my-spring-boot-experiments/jpa/boot-data-multipledatasources.md)                                            | Demonstrates configuring multiple SQL databases in a single Spring Boot application.                        |
| [Hibernate 2nd Level Cache Using Redis](/my-spring-boot-experiments/jpa/boot-hibernate2ndlevelcache-sample.md)                                     | Explains configuring Hibernate's second-level caching via Redis and testing it.                             |
| [JNDI Sample](/my-spring-boot-experiments/jpa/boot-jndi-sample.md)                                                                                 | Demonstrates JNDI usage with embedded Tomcat and Hikari DataSource.                                         |
| [JPA with JOOQ](/my-spring-boot-experiments/jpa/boot-jpa-jooq-sample.md)                                                                           | Shows how to use both JPA and JOOQ in the same application for database operations.                         |
| [JPA Locks](/my-spring-boot-experiments/jpa/boot-jpa-locks.md)                                                                                     | Demonstrates database locking mechanisms and transaction isolation levels.                                  |
| [Read Replica Postgres with connection optimization](/my-spring-boot-experiments/jpa/boot-read-replica-postgresql.md)                              | Illustrates writing data to a primary Postgres database, then reading from a replica.                       |
| [KeySet pagination and dynamic search with Blaze](/my-spring-boot-experiments/jpa/blaze-persistence.md)                                            | Implements keyset pagination using Blaze Persistence, adding dynamic query features.                        |
| [KeySet pagination and dynamic search with spring data jpa](/my-spring-boot-experiments/jpa/boot-data-window-pagination.md)                        | Implements keyset pagination using Spring Data JPA, enabling dynamic queries.                               |
| [MultiTenancy with multipledatsources](/my-spring-boot-experiments/jpa/multitenancy/multidatasource-multitenancy.md)                               | Provides examples of running multi-tenant applications under different strategies.                          |
| [MultiTenancy DB Based](/my-spring-boot-experiments/jpa/multitenancy/multitenancy-db.md)                                                           | Demonstrates having each tenant use a separate database (while sharing the same codebase).                  |
| [MultiTenancy Partition Based](/my-spring-boot-experiments/jpa/multitenancy/partition.md)                                                          | Shows how to share a single database and table across tenants using a partitioning strategy.                |
| [MultiTenancy Schema Based](/my-spring-boot-experiments/jpa/multitenancy/schema.md)                                                                | Demonstrates isolating tenants by allocating a separate schema for each tenant.                             |
| [Reactive SQL With JOOQ](/my-spring-boot-experiments/r2dbc/boot-jooq-r2dbc-sample.md)                                                              | Explains performing reactive CRUD operations in Spring Boot using jOOQ.                                     |
| [PostgreSQL JSON and ENUM column support using reactive](/my-spring-boot-experiments/r2dbc/boot-r2dbc-json-column.md)                              | Demonstrates PostgreSQL JSON and ENUM column support in a reactive application.                             |
| [PostgreSQL Notify/Listen](/my-spring-boot-experiments/r2dbc/boot-r2dbc-notify-listen.md)                                                          | Shows how to implement PostgreSQL's NOTIFY/LISTEN feature using R2DBC.                                      |
| [Reactive Cache with Redis](/my-spring-boot-experiments/r2dbc/boot-r2dbc-reactive-cache.md)                                                        | Demonstrates caching reactive database operations in Redis to boost performance.                            |
| [Reactive Application](/my-spring-boot-experiments/r2dbc/boot-r2dbc-sample.md)                                                                     | Illustrates an end-to-end reactive CRUD workflow in Spring Boot using R2DBC.                                |
| [BackgroundJobs and Scheduling using Jobrunr](/my-spring-boot-experiments/scheduler/boot-scheduler-jobrunr.md)                                     | Sets up background job scheduling with [Jobrunr](https://www.jobrunr.io/en/).                               |
| [Scheduling using Quartz](/my-spring-boot-experiments/scheduler/boot-scheduler-quartz.md)                                                          | Showcases the [Quartz Scheduler](https://www.quartz-scheduler.org/), providing job scheduling capabilities. |
| [Scheduling using Database Distributed Locks with ShedLock](/my-spring-boot-experiments/scheduler/boot-scheduler-shedlock.md)                      | Demonstrates scheduling while ensuring only one active job running at a time using ShedLock.                |

***

### Tech Stack

This repository leverages a broad stack of technologies, including:

* **Java** / **JavaScript** / **SQL** for core logic & data.
* **Spring Framework** (Boot, Data, Security, etc.) as the key application framework.
* **Project Reactor** for reactive data flows and concurrency.
* **QueryDSL**, **Liquibase**, **Flyway**, **JOOQ** for advanced database interactions and migrations.
* **Docker**, **Docker Compose** for containerization and multi-service orchestration.
* **RabbitMQ**, **Redis**, **Elasticsearch**, **OpenSearch**, **MongoDB** for messaging, caching, and search.
* **Gradle** / **Maven** for builds and dependency management.
* **GitHub Actions**, **CircleCI**, **Jenkins** for CI/CD pipelines.

For in-depth version references, visit [techstack.md](https://github.com/rajadilipkolli/my-spring-boot-experiments/blob/main/techstack.md) or see individual project READMEs.

***

### Useful Docker Commands

Start Postgres and pgAdmin

```shell
docker compose up postgres pgadmin4
```

Clean up everything using

```shell
docker system prune -a -f --volumes
```

Claim unused volumes

```shell
docker volume prune
```

Running container

```shell
docker container ls
```

***

### Useful git Commands

How to overwrite local changes with git pull

Stash local changes:

```shell
git stash
```

Pull changes from remote:

```shell
git pull
```

How to revert the changes that are pushed to remove

```shell
git revert $hash
```
