- Finance: Web application via which you can manage portfolios of stocks. This tool allows you to check real stocks’ actual prices and portfolios’ values, it will also let you buy (okay, “buy”) and sell (okay, “sell”) stocks by querying IEX Stock Quote API for stocks’ prices.
- I wrote all the code in the templates directory. I wrote most of the code in application.py. Some of the code in helpers.py was provided by instructor
- I styled the application myself, with illustrations provided by Freepik. Landing page and favicon cloned after Robinhood
- Database design and Create, Read, Update in SQL
- Rewrote the entire application to use Flask SQL Alchemy, an extension of SQL Alchemy
- Developed MVP of application with SQLite locally and Deployed with MySQL
- Using Flask as a server-side micro-framework
- Python Class/Models and Schemas
- Jinja templating
- Password hashing using Werkzeug
- Caching user sessions with Redis and Flask-sessions
- Parsing data from API with python
- Parsing data from SQL queries with python
- Calculations using data from API and database
- Hosting application on AWS with an EC2 instance with an Ubuntu operating system, Gunicorn WSGI HTTP server, and Nginx front-end reverse proxy
- Using Ubuntu as an operating system
- Gunicorn configuration and error-logging
- Nginx configuration and server security/performance optimization
- Hosting MySQL database on AWS with a RDS instance
- Hosting Redis cache on AWS with an Elasticache instance
- Using AWS Cloudfront as a Content Delivery Network (CDN) and connecting Google Domains custom domain to AWS CDN
- Error logging with Sentry for hosted application in production
- Continous integration and continuous deployment with Travis CI and AWS CodeDeploy
- (Deprecated) Hosting application on AWS with an Elastic Beanstalk instance and MySQL database on AWS with a RDS instance
| Graphic Design | Front-End | Back-End | Database | Deployment | Testing |
|---|---|---|---|---|---|
| Inkscape | HTML5 | Python3 | MySQL | AWS EC2 | Pytest |
| Freepik | CSS3 | Flask | SQL Alchemy | Ubuntu | Lighthouse |
| . | Bootstrap 4 | Werkzeug | Flask SQL Alchemy | Gunicorn | . |
| . | Jinja | . | Redis | Nginx | . |
| . | . | . | . | Sentry | . |
| . | . | . | . | AWS RDS | . |
| . | . | . | . | AWS Elasticache | . |
| . | . | . | . | AWS Cloudfront | . |
| . | . | . | . | Travis CI | . |
| . | . | . | . | AWS CodeDeploy | . |
- Initially hosted application on AWS Elastic Beanstalk for a gradual introduction to AWS. Previously only used Heroku to host full-stack web applications, so I chose a similar IaaS offered by AWS. After numerous Elastic Beanstalk policy changes and disconnections, decided to go to the next level down in AWS, which is hosting this application on an EC2 instance. This offered a lot of experience and opportunities for learning about web servers.
- Ubuntu as OS since it's the most popular operating system for web servers. Gunicorn as the WSGI since it's fast. Nginx as the reverse proxy since it was made with this optimization in mind.
- Initially stored user sessions in a tmp folder with
mkdtemp, however Nginx had trouble accessing it in production. Therefore refactored application to store user sessions in a Redis database and hosted the Redis database on AWS Elasticache.
- Login, sign-up
- Security to prevent certain transactions using error codes 400-404
- Create, Read, and Update for stocks
- Ensure that
python3andpython3-pipare installed on your system - In your terminal, navigate to the root project directory and run the following commands
- Activate the virtual environment
$ pipenv shell - Install the dependencies
$ pipenv install -r requirements.txt - You'll need to register for an API key in order to be able to query IEX’s data
- Register for an account
- Enter your email address and a password, and click “Create account”
- On the next page, scroll down to choose the Start (free) plan
- Once you’ve confirmed your account via a confirmation email, sign in to iexcloud.io
- Click API Tokens
- Copy the key that appears under the Token column (it should begin with pk_) into the
<value>in the next step
- Create a .env file and paste the following into it:
API_KEY=<value> - To start the web server, execute (without debugging):
$ python application.py - Alternatively, execute (with debugging):
$ export FLASK_APP=application.py $ flask run - Lastly, create a SQL database named
finances.db - To initialize the SQL database within application.py, add
db.create_all()belowInitialize Schemas. Once the code runs and the you've verified the database exists, removedb.create_all() - To initialize the SQL database in the python shell, execute:
$ python $ from application import db $ db.create_all() - To initialize the database with SQL command-line arguemnts (using MySQL syntax) run each
CREATE TABLEcommand (one at a time):
CREATE TABLE users ( id INTEGER PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) UNIQUE, hash VARCHAR(200) NOT NULL, cash INTEGER ); CREATE TABLE portfolio ( id INTEGER PRIMARY KEY AUTO_INCREMENT, user_id INTEGER, symbol VARCHAR(5), current_shares INTEGER ); CREATE TABLE bought ( id INTEGER PRIMARY KEY AUTO_INCREMENT, buyer_id INTEGER, time VARCHAR(100), symbol VARCHAR(5), shares_bought INTEGER, price_bought FLOAT ); CREATE TABLE sold ( id INTEGER PRIMARY KEY AUTO_INCREMENT, seller_id INTEGER, time VARCHAR(100), symbol VARCHAR(5), shares_sold INTEGER, price_sold FLOAT ); - Stock prices pulled from IEX Stock Quote API
- Hat icon made by Alice Noir from the Noun Project
- Feather icon made by Jacopo Mencacci from the Noun Project
- Illustrations by Freepik Storyset
Copyright Notice and Statement: currently not offering any license. Permission only to view and download. Refer to choose a license for more info.
