Skip to content

ahmadleoyudanto/ifg-code-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRUD + KAFKA

This project is a crud users system built using Quarkus, MySQL, and Kafka.


🧱 Tech Stack

  • Java 17
  • Quarkus
  • MySQL
  • Kafka
  • Flyway (for DB migrations)
  • Docker + Docker Compose
  • Swagger (for API documentation)

🚀 Getting Started

1. 📋 Prerequisites

Make sure you have the following installed:

  • Java 17+
  • Maven
  • Docker + Docker Compose

2. 🗃️ Database Setup

  • Create a user with username root and password root
  • Create a database named ifg_code_test before running the application:
CREATE DATABASE ifg_code_test;
  • Set user to be able to access database ifg_code_test
  • or if you already have user, you can configure application.properties as follows:
quarkus.datasource.username=<your_username>
quarkus.datasource.password=<your_password>

3. 🐳 Running in Docker

  • Build the Quarkus App
./mvnw package
  • Build Docker Image
docker build -f src/main/docker/Dockerfile.jvm -t quarkus/ifg-code-test-jvm .
  • Setup kafka container in docker-compose.yaml
environment:
    # after change the host, delete the container first
    # KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-container:9092
  • Start the Services
docker-compose up

4. 💻 Running in Local

  • Setup kafka container in docker-compose.yaml
environment:
    # after change the host, delete the container first
    # KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
  • go to the project root, open terminal and run this command:
./mvnw quarkus:dev

5. 🔗 API Documentation

Once the app is running, you can check the available API endpoints here: http://localhost:8080/swagger-ui/index.html

6. 🔧 How to use

  • create a user
curl --location 'http://localhost:8080/webhook/user' \
--header 'Content-Type: application/json' \
--data '{
    "name": "name",
    "type": "add"
}'
  • edit a user
curl --location 'http://localhost:8080/webhook/user' \
--header 'Content-Type: application/json' \
--data '{
    "id": 1,
    "name": "name",
    "type": "edit"
}'
  • delete a user
curl --location 'http://localhost:8080/webhook/user' \
--header 'Content-Type: application/json' \
--data '{
    "id":1,
    "type": "delete"
}'
  • retry dead letter user
curl --location --request POST 'http://localhost:8080/webhook/retry-dead-letter-user'

7. ⚠️ Constraint and Limitation

  • Authentication: This project does not implement login/token authentication to simplify testing and focus on the core CRUD logic with Kafka integration.
  • Unit Tests: Unit tests are not included due to time constraints. Writing tests for Kafka publishers and consumers requires mocking Kafka, which involves additional complexity that wasn't feasible within the available time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages