Skip to content

samarthasthan/twitter-sentiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Here's the revised version of your document with corrected English:


Twitter Sentiment Analysis Backend

This backend service is designed for Twitter Sentiment Analysis, providing a robust and scalable solution for processing and analyzing tweets. Built using Golang, Kafka, gRPC, and Go-Fiber, it combines the efficiency of Go with the power of Kafka messaging and the flexibility of gRPC for seamless communication.

Tech Stack

Language: GoLang

Library: GORM

Framework: gRPC, Apache Kafka

Tools: Docker

System Design

App Screenshot

Live URL

twitter-go.samarthasthan.com

API Reference

Welcome API

  GET /

Get Tweets

  GET /tweets

Returns a JSON object containing the sentiment analysis results for the 10 most recent tweets. A score of 1 indicates a positive sentiment, while a null score indicates a negative sentiment.

Example

App Screenshot

Run on VPS

  1. Clone the project
git clone https://github.com/samarthasthan/twitter-sentiments
  1. Download the dataset CSV file from Kaggle, rename it to tweets.csv, and copy it to twitter-sentiments/twitter-api.

    Kaggle Dataset Link

    Copy the tweets.csv file from your local machine to the VPS.

    scp -i "secret.pem" path/tweets.csv ubuntu@publicip:github/twitter-sentiments/twitter-api

    If you encounter a permission denied error, use the following command on the VPS:

    sudo chmod 777 (remote folder)
  2. Navigate to the project directory

cd twitter-sentiments
  1. Start Docker
docker compose up -d

App Screenshot

  1. Set up Nginx
apt update
apt install nginx
vim /etc/nginx/conf.d/samarthasthan.conf

Then copy your Nginx config to {domain}.conf

server {
    listen 80;
    listen [::]:80;

    server_name twitter-go.samarthasthan.com;

    location / {
        proxy_pass http://localhost:9058;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
  1. Install SSL certificate using Certbot
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d twitter-go.samarthasthan.com
  1. Automate SSL renewal with crontab
crontab -e

And paste the crontab job

0 6 * * 0 certbot renew -n -q --pre-hook "service nginx stop" --post-hook "service nginx start"
  1. Finally, restart Nginx
nginx -t
sudo systemctl restart nginx

Run Locally

  1. Clone the project
git clone https://github.com/samarthasthan/twitter-sentiments
  1. Download the dataset CSV file from Kaggle, rename it to tweets.csv, and copy it to twitter-sentiments/twitter-api.

    Kaggle Dataset Link

  2. Navigate to the project directory

cd twitter-sentiments
  1. Start Docker
docker compose up -d

App Screenshot

Note: Now, you can access it using localhost:9058/tweets.

Authors


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published