https://github.com/renatompf/poc_spring_elasticsearch
This project is a Spring Boot application that demonstrates the integration of PostgreSQL and Elasticsearch for managing and searching product data.
https://github.com/renatompf/poc_spring_elasticsearch
elasticsearch java kafka openapi postgresql spring-boot
Last synced: 3 months ago
JSON representation
This project is a Spring Boot application that demonstrates the integration of PostgreSQL and Elasticsearch for managing and searching product data.
- Host: GitHub
- URL: https://github.com/renatompf/poc_spring_elasticsearch
- Owner: renatompf
- Created: 2025-12-17T14:01:00.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-17T14:43:58.000Z (7 months ago)
- Last Synced: 2025-12-21T02:29:24.261Z (6 months ago)
- Topics: elasticsearch, java, kafka, openapi, postgresql, spring-boot
- Language: Java
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Elastic POC
This project is a **Spring Boot** application that demonstrates the integration of **PostgreSQL** and **Elasticsearch** for managing and searching product data. It provides a REST API for CRUD operations and advanced search capabilities.
## Features
- **CR~~U~~D Operations**: Create, read, ~~update~~, and delete products.
- **Elasticsearch Integration**: Full-text search on product fields like name, description, and tags.
- **PostgreSQL Integration**: Persistent storage for product data.
- **Validation**: Input validation using `@Valid` annotations.
- **OpenAPI Documentation**: API documentation with Swagger UI.
- **Messaging**: Kafka-based messaging for syncing data between services.
## Technologies Used
- **Java 25**
- **Spring Boot**
- **PostgreSQL**
- **Elasticsearch**
- **Kafka**
- **MapStruct** for object mapping
- **Maven** for dependency management
## Prerequisites
- **Java 25+**
- **Docker** and **Docker Compose** (for running PostgreSQL, Elasticsearch, and Kafka)
- **Maven**
## Architecture
```mermaid
graph TD
%% Client
Client[Client / Frontend]
%% Application
subgraph SpringBootApp["Spring Boot Application"]
API[REST Controllers]
Service[Application Services]
JPARepo[JPA Repository]
ESRepo[Elasticsearch Repository]
Producer[Kafka Producer]
Consumer[Kafka Consumer]
Mapper[Entity ↔ Document Mapper]
end
%% Datastores
Postgres[(PostgreSQL)]
Elasticsearch[(Elasticsearch)]
Kafka[(Kafka Topic)]
%% Write flow
Client -->|HTTP POST/DELETE| API
API --> Service
Service --> JPARepo
JPARepo --> Postgres
%% Async sync flow
Service -->|ProductCreated / Deleted| Producer
Producer --> Kafka
Kafka --> Consumer
Consumer --> Mapper
Mapper --> ESRepo
ESRepo --> Elasticsearch
%% Read flow
Client -->|HTTP GET /search| API
API --> Service
Service -->|Search query| ESRepo
ESRepo --> Elasticsearch
```
## Getting Started
### Clone the Repository
```bash
git clone https://github.com/renatompf/poc_spring_elasticsearch.git
cd poc_spring_elasticsearch
```
### Build the Project
```bash
mvn clean install
```
### Run the Application
By running the following command, the application will start along with PostgreSQL, Elasticsearch, and Kafka using Docker Compose:
```bash
make run
```
## Documentation
You can access the API documentation at:
```
http://localhost:8080/swagger-ui.html
```
or
```
http://localhost:8080/api-docs
```
You will also find some pre-created requests in the [http folder](/http).