Skip to content

Using kafka and ksqldb to build a server to track video playback events

License

Notifications You must be signed in to change notification settings

agmo1993/videoevents-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Video tracking server

Database and API for tracking video playback events per user using kafka and ksqldb.

Dependencies

  • Python [v3.8.9]
  • Node.js [v16.17.1]
  • Docker [=>v20.10.17]
  • Docker Compose [=>v2.10.2]
  • Sqitch [v1.3.1]
  • npm [v8.15.0]

Start the ksqldb stack

Use docker compose to start the stack,

source .env
docker-compose up

wait for at least one minute until all logs show that ksqldb-server, broker and zookeeper have started.

Run the following script to create the kafka topics, as well as the required schema in ksqldb.

./startup.sh

Install dependencies

npm install

Start the server

npm run start

Run the server as a docker container

Build the docker container

docker build -t vidtracking-server .

Start the server by running the container,

docker run --name vidtracking-server \
-v "$(pwd)"/src:/app/src \
-p 3000:3000 \
--network host \ 
-d vidtracking-server 

Test queries

Write data to kafka

curl -X POST -H "Content-Type: application/json" -d '{"userId": 123, "videoId": 456, "vidTime": 60}' http://localhost:3000/video

Read data for a user

curl -X GET http://localhost:3000/video/456/123

Integration test

To run and integration test, the kakfa broker and ksqldb server need to be running, along with the server.

Start the server

npm start

Open another terminal, and run the test

npm run test

License

This project is licensed under the Apache-2.0 license.

About

Using kafka and ksqldb to build a server to track video playback events

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published