Twitter Vibes is a MEAN web app that searches and analyzes recent tweets based on a provided query. The tweets are classified as either positive, negative, or neutral depending on the results of sentiment analysis.
First run the following commands:
npm install
npm run setup
Then setup the server
- Configure the server with your Twitter consumer_key and consumer_secret. You can obtain these credentials by creating a Twitter App
- Ensure you have a Mongo DB server running.
sudo mongod
- Build the front-end.
- Start the Node.js server by running the following command:
npm start
- Wait until you see
The server is now ready to accept requests.
- Open the app in you browser at http://localhost:3000
- Prerequisite: Cloud Foundry CLI
This application has been configured to work on a Cloud Foundry PaaS that supports Mongo DB. Before pushing to the cloud ensure that you have logged in using cf login
grunt
cf push
grunt
grunt test
- Yeoman scaffolding
- Node.js backend
- Mongo DB NoSQL database
- AngularJS frontend
- Bootstrap styling
- Grunt task management
- Bower package management
- Karma testing
There is only one endpoint in this api /twitter/search/tweets
. This endpoint performs an HTTPS GET request to the Twitter Search API. Once data is received it is analyzed using sentiment analysis, stored in a Mongo DB database, and returned in response to the request.
q
: The Twitter search querycount
: The number of tweets to return per page, up to a maximum of 100sentiment
: The tweet sentiment filter (positive, negative, neutral)
When a sentiment is set, the endpoint behaves slightly different. First a request is made to the Twitter Search API to obtain recent tweets related to the query. Next sentiment analysis is performed on the tweets and they are saved to the database as usual. The data is then filtered based on the specified sentiment, this will remove all tweets that do not match the requested sentiment. To fill the holes left by the filtering, the database is queried to find the remaining most recent tweets related to the query with the requested sentiment. Finally, the combined data is returned in response to the request.
http://localhost:3000/twitter/search/tweets?q=Example
Front-End:
bower install --save <Name of Package>
Back-End:
npm install --save <Name of Package>
Dev:
npm install --save-dev <Name of Package>
This app is bundled with two modes: Dev-Mode and Prod-Mode.
Dev-Mode
http://localhost:3000/dev
Dev-Mode is mapped to the app
directory and contains editable source code. In this mode you can edit source code and preview the changes directly in the browser without building the project.
Prod-Mode
http://localhost:3000
Prod-Mode is mapped to the dist
directory. This mode is the compiled, compressed and tested version of the tool that should be used for production instances.
Switching from Dev to Prod
As a standard, all new features should be made in Dev-Mode then compiled into Prod-Mode once completed. To switch from Dev-Mode to Prod-Mode simply Build the project.