This repository provides a Sentiment Analysis System for Twitch chat messages, leveraging modern technologies for real-time data processing, analysis, and visualization.
The project is divided into three services:
-
Chat Reader
A Go-based service that connects to Twitch IRC, reads chat messages, and produces them to a Kafka topic for further processing. -
Message Analyzer
A Python-based service that consumes messages from Kafka, performs sentiment analysis using a Hugging Face neural network model, and stores results in a PostgreSQL database. -
Website
A Go + Vue-based web service that displays the sentiment analysis results and recent messages in real-time via WebSocket updates.
- Real-Time Data Processing: Stream and analyze Twitch chat messages instantly.
- Scalable Architecture: Decoupled services using Kafka.
- Insightful Visualization: Interactive dashboard for visualizing results.
- Containerized Deployment: Docker and Docker Compose for streamlined setup.
- Metrics Integration: Prometheus and Grafana for monitoring system performance.
flowchart LR
TwitchChat -- "chat<br>messages" --> MessagesTopic
subgraph ChatReader["Chat Reader"]
direction TB
TwitchChat(Twitch Chat<br>IRC)
end
subgraph KafkaBroker["Kafka Broker"]
MessagesTopic@{ shape: das, label: "messages" }
end
MessagesTopic --> Model
Model -- "Classified<br>messages" --> ResultsTable
subgraph Analyzer["Message Analyzer"]
direction TB
Model[Sentiment<br>Analysis<br>Model]
end
subgraph PostgresDatabase["PostgreSQL"]
ResultsTable@{ shape: cyl, label: "results" }
end
ResultsTable --> Backend
subgraph Website["Website"]
direction TB
Backend["Backend"]
Frontend["Frontend"]
Backend -- Channel analysis --> Frontend
Backend -- Last messages --> Frontend
end
demo.mp4
- Language: Go
- Libraries:
- franz-go: Kafka client
- go-twitch-irc: Twitch IRC client
- Testcontainers: For integration tests
- Language: Python
- Libraries:
- confluent-kafka-python: Kafka client
- transformers: Neural network API
- psycopg2: PostgreSQL client
- Backend: Go
- gorilla/websocket: WebSocket support
- pgx: PostgreSQL driver
- Testcontainers: For integration tests
- Frontend: Vue.js
- chart.js + vue-chartjs: Data visualization
- shadcn-vue: UI components
- tailwindcss: CSS framework
Prometheus is used to collect metrics, and Grafana visualizes them via a dashboard.
kafka_messages_processed_total
: Total produced messagestwitch_messages_read_total
: Total messages read and filtered by the client
broadcast_hub_clients_total
: Total active WebSocket clientsbroadcast_hub_messages_total
: Total messages broadcasted to frontend clients
-
Clone the Repository
-
Setup Dependencies:
- Install Docker Engine
-
Run the Project:
docker compose up
-
Access the Dashboard:
- Website: http://localhost:8080
- Grafana: http://localhost:3000
- Default user and password:
admin
- Default user and password:
This project uses the lxyuan/distilbert-base-multilingual-cased-sentiments-student model for sentiment analysis. While the model provides robust multilingual sentiment analysis, it is important to note:
- Potential Bias: The model may reflect biases present in its training data, potentially impacting the accuracy and fairness of sentiment classification.
- Domain Limitations: The model's performance may vary depending on the language and context of the chat messages.
Users should interpret the results with caution and consider these limitations when analyzing the data.
This project is licensed under the MIT License.