Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beakerandjake/kafka-hello-world
Realtime (fake) stock prices with Kafka.
https://github.com/beakerandjake/kafka-hello-world
fastify kafka kafka-consumer kafka-producer nodejs postgresql python react
Last synced: about 1 month ago
JSON representation
Realtime (fake) stock prices with Kafka.
- Host: GitHub
- URL: https://github.com/beakerandjake/kafka-hello-world
- Owner: beakerandjake
- License: gpl-3.0
- Created: 2023-12-18T22:59:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-10T20:57:55.000Z (12 months ago)
- Last Synced: 2024-01-10T23:38:15.607Z (12 months ago)
- Topics: fastify, kafka, kafka-consumer, kafka-producer, nodejs, postgresql, python, react
- Language: JavaScript
- Homepage:
- Size: 329 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Table of Contents
## About
![project-screenshot]
Created while I was learning Kafka, I needed a stream of realtime data to work with and stock prices came to mind.
The project is composed of different applications which are orchestrated by docker compose.
A single Producer continually publishes price change messages to a topic with multiple Consumers.
- One Consumer saves each price event to a database.
- Another Consumer aggregates these rows into time buckets.
- A final Consumer pushes price events to the frontend via SSE.### Built With
[![Kafka][Kafka]][Kafka-url]
[![Postgres][Postgres]][Postgres-url]
[![Nginx][Nginx]][Nginx-url]
[![Docker][Docker]][Docker-url]
[![Fastify][Fastify]][Fastify-url]
[![Vite][Vite]][Vite-url]
[![React][React]][React-url]
[![Chart.js][Chart.js]][Chart.js-url]
[![TailwindCSS][TailwindCSS]][TailwindCSS-url]## Getting Started
Installation is easy thanks to docker compose, you just need to clone this repository then run the `up` command.
### Prerequisites
Docker Compose must be installed on your machine. It can be installed through docker desktop or [docker engine][install-docker-url].
### Installation
1. Clone this repo
```sh
git clone https://github.com/beakerandjake/kafka-hello-world
```
2. Start the application
```sh
docker compose up -d
```To stop the application
```sh
docker compose down
```## Usage
Once the containers are all started navigate to `http://localhost:8080` in your browser. You should see prices continually update, if you leave it running you can see the price chart change over time.
To view the price events you can create a console consumer:
```sh
docker exec -it kafka kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic stock_price_changes
```You can also follow the consumer logs:
```sh
docker logs consumer-realtime --follow
```
```sh
docker logs consumer-aggregate --follow
```## Architecture Diagram
![project-architecture]
See a specific component's README file for more information.
[project-screenshot]: https://github.com/beakerandjake/kafka-hello-world/assets/1727349/d9f7bf11-d548-43e1-817c-0055e18a562e
[project-architecture]: https://github.com/beakerandjake/kafka-hello-world/assets/1727349/fa3b1072-904c-4b7a-b4b8-6e6995e53df3[Kafka]: https://img.shields.io/badge/Apache%20Kafka-000?style=for-the-badge&logo=apachekafka
[Kafka-url]: https://kafka.apache.org/
[Postgres]: https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white
[Postgres-url]: https://www.postgresql.org/
[Nginx]: https://img.shields.io/badge/nginx-%23009639.svg?style=for-the-badge&logo=nginx&logoColor=white
[Nginx-url]: https://nginx.org
[Docker]: https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white
[Docker-url]: https://www.docker.com/
[Fastify]: https://img.shields.io/badge/fastify-%23000000.svg?style=for-the-badge&logo=fastify&logoColor=white
[Fastify-url]: https://fastify.dev/
[Vite]: https://img.shields.io/badge/vite-%23646CFF.svg?style=for-the-badge&logo=vite&logoColor=white
[Vite-url]: https://vitejs.dev/
[React]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
[React-url]: https://react.dev/
[TailwindCSS]: https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white
[TailwindCSS-url]: https://tailwindcss.com/
[Chart.js]: https://img.shields.io/badge/chart.js-F5788D.svg?style=for-the-badge&logo=chart.js&logoColor=white
[Chart.js-url]: https://www.chartjs.org/
[install-docker-url]: https://docs.docker.com/engine/install/