My final project for CS50x is almost finished. This article is going to highlight the specific languages, frameworks, and tools used to build my project.
I have an article explaining the idea for this application if you wanted an overview before reading ahead.
Otherwise, here’s the quick version: A web-based Twitter sentiment guessing game.
It would have been fun to learn and use a new language/frontend framework for this project, but I decided not to.
I built the app with tools I had experience using. My goal for this project was to build a working web application. I didn’t want to get lost down the rabbit hole of learning a new language or framework.
The Languages, Frameworks, and Tools
I’ve used both jQuery and Bootstrap a few times in the past, so the learning curve was pretty low.
Chart.js was a new tool for me. I used this to convert guess and history data into doughnut charts. I originally wanted to use D3.js, but it had a much steeper learning curve.
Getting Chart.js working was much easier than I expected.
I’m considering recreating the entire user interface using Vue.js as a separate personal project.
The backend does most of the hard work. I used Python/Flask because the framework had almost everything I needed out of the box (or by easily adding a compatible library). Plus, I was familiar with both technologies.
I considered swapping out Flask for Django but didn’t see the benefits (not for such a small application).
Twython is a Twitter API wrapper. It lets you access the live Twitter stream and pull Tweets from the most recent posters. This is how the app generates random users.
TextBlob is a natural language processing library. It has a built-in sentiment analysis tool, which scores text strings with a positive or negative floating point number depending on the polarity of each word (or combination of words).
I used Passlib to generate password hashes. The conventional wisdom online seems to strongly recommend against writing your own hash functions.
Gunicorn is a Unix server. It allows multiple instances of the application to run concurrently. In development, I used Flask’s built-in server.
This was my first time creating, connecting to, and interacting with a database. Without pre-build code examples, anyway.
I made this one of my main requirements for the project. I wanted to get some hands-on experience working with a database.
I used SQLite3 with my local development environment and PostgreSQL for production. I already knew how to setup a simple SQLite3 database. I didn’t want to invest the extra time setting up a local Postgres server.
Setting up Postgres on Heroku was much easier than I was expecting.
I used Psycopg2 to connect Python and the Postgres database.
I didn’t use an ORM (Object-relational mapping) tool like SQLAlchemy. Most tutorials recommend using an ORM so you don’t have to write SQL queries directly in your code. With the ability to use variables in Psycopg2 SQL queries, I couldn’t see the upside.
It’s possible I’m missing the point of ORMs. I understand their value in much larger applications, but can’t see the payoff for small/medium applications over writing SQL queries.
Hosting is on Heroku’s free tier. I wanted the app to stay up indefinitely, which would be expensive if I was paying for hosting (even $3 per month).
I had some issues installing the Heroku Toolbelt locally (which you need to push code to the server). Once that was working, it was a pretty pleasant experience. I’ll definitely be using this service again.
All the source code is on my public GitHub profile. Pushing code to a repo feels like magic.
This is the second article in a series following the development of my final project for CS50x.
Check out the first article on idea selection.