Giter Club home page Giter Club logo

ivangfr / springboot-kafka-websocket Goto Github PK

View Code? Open in Web Editor NEW
51.0 5.0 30.0 20.87 MB

The goal of this project is to implement two Spring Boot applications: bitcoin-api and bitcoin-client. The bitcoin-api application simulates BTC price changes, while the bitcoin-client application listens to these changes and updates a real-time UI. The bitcoin-client UI is secured using Basic Authentication.

Java 57.25% JavaScript 14.24% HTML 20.79% Shell 7.71%
spring-boot kafka websocket thymeleaf mysql java docker basic-authentication spring-cloud-stream springdoc-openapi

springboot-kafka-websocket's Introduction

springboot-kafka-websocket

The goal of this project is to implement two String Boot applications: bitcoin-api and bitcoin-client. The bitcoin-api application simulates BTC price changes, while the bitcoin-client application listens to these changes and updates a real-time UI. The bitcoin-client UI is secured using Basic Authentication.

Proof-of-Concepts & Articles

On ivangfr.github.io, I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.

Project Diagram

project diagram

Applications

  • bitcoin-api

    Spring Boot Web Java application service that simulates BTC price changes and pushes those changes to Kafka

  • bitcoin-client

    Spring Boot Web Java application that was implemented using Thymeleaf as HTML template. It reads from Kafka and updates its UI using Websocket. It has also a chat where users can talk to each other, by sending messages publicly or privately.

Prerequisites

Start Environment

  • Open a terminal and inside springboot-kafka-websocket root folder run:

    docker compose up -d
  • Wait for Docker containers to be up and running. To check it, run:

    docker compose ps

Running applications with Maven

Inside springboot-kafka-websocket root folder, run the following Maven commands in different terminals:

  • bitcoin-api

    ./mvnw clean spring-boot:run --projects bitcoin-api -Dspring-boot.run.jvmArguments="-Dserver.port=9081"
  • bitcoin-client

    ./mvnw clean spring-boot:run --projects bitcoin-client -Dspring-boot.run.jvmArguments="-Dserver.port=9082"

Running Applications as Docker containers

Build Application’s Docker Image

  • In a terminal, make sure you are in springboot-kafka-websocket root folder;

  • In order to build the application docker images, run the following script:

    ./docker-build.sh

Application’s Environment Variables

  • bitcoin-api

    Environment Variable Description

    MYSQL_HOST

    Specify host of the MySQL database to use (default localhost)

    MYSQL_PORT

    Specify port of the MySQL database to use (default 3306)

    KAFKA_HOST

    Specify host of the Kafka message broker to use (default localhost)

    KAFKA_PORT

    Specify port of the Kafka message broker to use (default 29092)

  • bitcoin-client

    Environment Variable Description

    KAFKA_HOST

    Specify host of the Kafka message broker to use (default localhost)

    KAFKA_PORT

    Specify port of the Kafka message broker to use (default 29092)

Start Application’s Docker container

  • In a terminal, make sure you are inside springboot-kafka-websocket root folder;

  • Run following script:

    ./start-apps.sh

Applications URLs

Application URL Credentials (user/pass)

bitcoin-api

http://localhost:9081/swagger-ui.html

bitcoin-client

http://localhost:9082

user1/123 or user2/123

The gif below shows two users checking real-time the BTC price changes. Besides, they are using a chat channel to communicate with each other.

two users example
  • Kafdrop

    Kafdrop can be accessed at http://localhost:9000

  • MySQL

    docker exec -it -e MYSQL_PWD=secret mysql mysql -uroot --database bitcoindb
    select * from prices;

Shutdown

  • To stop applications

    • If they were started with Maven, go to the terminals where they are running and press Ctrl+C;

    • If they were started as Docker containers, go to a terminal and, inside springboot-kafka-websocket root folder, run the script below:

      ./stop-apps.sh
  • To stop and remove docker compose containers, network and volumes, go to a terminal and, inside springboot-kafka-websocket root folder, run the following command:

    docker compose down -v

Cleanup

To remove the Docker images created by this project, go to a terminal and, inside springboot-kafka-websocket root folder, run the script below:

./remove-docker-images.sh

springboot-kafka-websocket's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.