Skip to content

A minimal tracker for stocks and cryptocurrencies

License

Notifications You must be signed in to change notification settings

kajgm/stocktracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Tracker · GitHub license Node.js CI PRs Welcome

A minimal tracker for Stocks and Cryptocurrencies. Intended for use on external Raspberry Pi based displays (3.5inch) or within a browser.

Example

Developed With

Prerequisites

  1. Please ensure the following software is installed
  1. (Optional) To display exchange-traded stock tickers (AAPL, MSFT, etc.), create a Finanical Modeling Prep API key

Project Setup

Install client and server dependencies

cd client
npm install
cd ../server
npm install

Create a .env file within /client (using .env.template) and add parameters

FMP_KEY="<your_api_key>"

Compile and Hot-Reload for Development

cd client
npm run dev

Start the configuration server

Run in another terminal

cd server
npm run dev

Type-Check, Compile and Minify Client for Production

npm run build

Run Client Unit Tests with Vitest

npm run test

Lint Client with ESLint

npm run lint

Docker Deployment

To deploy within Docker, please follow these steps:

  1. Install Docker Engine

    Tip: Run sudo usermod -aG docker <user> to avoid prefixing the following commands with sudo

  2. Create the .env files from the templates in /client and /server

  3. Build the dockerfile within the /client directory

docker build -t kajgm/stocktracker-client .
  1. Build the dockerfile within the /server directory
docker build -t kajgm/stocktracker-server .
  1. Create a network for these containers
docker network create -d bridge backend-net
  1. Run the client, server, and database containers

    Note: If running on a raspberry pi, you will need to download an alternative mongodb image. Please see steps under Deployment on Raspberry Pi

docker run -d -p 8080:80 --name stocktracker-client --network backend-net --restart always kajgm/stocktracker-client
docker run -d -p 3000:3000 --name stocktracker-server --network backend-net --env-file=./.env --restart always kajgm/stocktracker-server
docker run -d --name mongodb-server --network backend-net -v stocktracker:/data/db --restart always mongo

Deployment on Raspberry Pi

Ensure the Docker deployment steps from above are followed on the target Raspberry Pi

  1. Mongodb currently does not support the ARM architecure used on raspberry pis. Please use the alternative image provided by themattman mongodb-raspberrypi-docker

  2. If running these commands over ssh, export the display

export DISPLAY=:0
  1. Run chromium in fullscreen mode
chromium-browser --kiosk --app=http://localhost:8080/ --start-fullscreen --incognito

Alternatively, you may have to append nohup and & to run the command in the background (if executing via ssh):

nohup chromium-browser --kiosk --app=http://localhost:8080/ --start-fullscreen --incognito &

As an alternative, a startup script has been provided in the root directory ./startup.sh. Ensure that the script is executable before running or referencing in any automated startup routine.

chmod +x <username> ./startup.sh