This repository contains code to run your own personal monthly spending tracking sheet. We will use a service called Plaid to securely connect to banks and credit card websites to download transactions.
There are 3 main sub-systems in this repo.
- Python Flask-based api server under the
/api
directoryy - React JS web app under the
connect-plaid-once
directory - streamlit web app user the
/scripts
directory
You will connect your financial accounts only once. This will download all your transactions and store them in a local database. You will then use the data visualization app to view your spending.
- Start the backend server using this command
flask run
from theapi
directory - Start the frontend web app using this command
npm start
from theconnect-plaid-once
directory
- Click the 'Connect with Plaid' button and follow the instructions to connect your accounts.
- Once you have connected your accounts, you can stop the backend server and the frontend web app. You will not need them again.
- Now that we have an access token, we can download all transactions from the connected accounts. Run the
scripts/fetch_transactions.py --start_date=YYYY-MM-DD
script to download all transactions from the given date. Check the instance folder for the database file calledprod.db
. This is where the transactions are stored. - You can now use the data visualization app to view your spending. Start the data visualization app using this command
streamlit run scripts/streamlit_app.py
from the top-level directory.
To keep the transactions table up to date, run the scripts/fetch_transactions.py
periodically. You can run this script from a cron job or a scheduled task. For eg. you may want to run the script every day at 2am.
python scripts/fetch_transactions.py --start_date=<yesterday>
Create an .envrc
file at the top-level and add these two lines
export PLAID_CLIENT_ID=[XXX]
export PLAID_SECRET=[YYY]
Replace XXX and YYY with your Plaid API credentials which you can get here
These environment variables need to be loaded into your shell before you start the server. You can do this by running source .envrc
from the top-level directory. Alternately, if you use direnv, you can run direnv allow
from the top-level directory, which will automatically load the environment variables into your shell when you cd
into the directory.
cd api
pip install -r requirements.txt
flask --debug run