Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 2.26 KB

README.md

File metadata and controls

88 lines (62 loc) · 2.26 KB

Twitch Chat Analytics

A micro-service platform for streaming Twitch IRC channel messages and analysing the results. Subscription to chat, and querying analytics are available through a GraphQL endpoint.

Background

This was a coding challenge for a potential position as a backend developer.

This code represents aproximately two days worth of work, at about 2-3 hours a day.

I had not previously worked with graphql or websockets and used this code challenge as an opportunity to do both.


Running the system

Things you will need:

  • A twitch oauth2 token available from Twitch here. DONOT INCLUDE "oath:" WITH THE TOKEN!

Run

docker-compose up

The graphql playground is available at: http://localhost:8000/

Queries to try

Subscribe to a channel and stream messages

subscription streamChannel {
  streamChannel(
    nickname: "your twitch nickname",
    token: "your oath2 token from twitch",
    channel: "name of channel to subscribe"
  ){
    nickname
    body
    created_at
    channel
  }
}

Get chat analytics

Once you are streaming some messages, you can query the channel for analytics

query {
  channel(channel: "name of channel you are streaming") {
	lulz_per_minute
    messages_per_minute
    chat_sentiment
    sentiment_emoji
  }
}

Troubleshooting

I'm having trouble with database connections...

  • Delete the volume for the database and docker-compose up -d db to start the database from scratch. docker-compose up dependent services seperately

I connect, but no messages are streaming...

  • Is the channel still streaming on Twitch??
  • Is you oauth token valid? (DONOT INCLUDE oath: with your token)
  • Channel name should not include a #

Known issues

Websocket connection can be flaky. Does not end connections properly sometimes. Multiple subscriptions has not been tested or attempted 😱 (Does it work?). Can another user see your stream?!? 🙀

If your auth token expires, or is invalid it will look like you have connected but nothing will happen.

Repos used as reference