greatday4april / the-investors-game

4 stars 1 forks source link

The Investor's Game

a investment game Inspired by Monopoly and Paper Trading

DEMO

https://investors-game.herokuapp.com/

setup

  1. yarn install
  2. bundle install && rails db:setup
  3. rails db:seed to seed the data
  4. gem install foreman
  5. foreman start to run

development

  1. you dont need to restart the server whenever you made change
  2. if you encounter weird frontend issues, delete public/pack
  3. to completely re-create DB: run rails db:drop && rails db:create && rails db:migrate && rails db:seed

Create the backend resource chain (example)

run rails g model user && rails g scaffold_controller api/user --api (for pure api resource) (replace api/user with your model name), it will generate the following files for you:

Frontend implementation

// ComponentDidMount()
useEffect(() => {
  fetchAllTicks('2009-01-02 07:06:00', '1d', 'AAPL');
}, []);

// ComponentDidMount() and ComponentDidUpdate()
useEffect(() => {
  fetchAllTicks('2009-01-02 07:06:00', '1d', 'AAPL');
});

// ComponentWillUnMount()
useEffect(() => {
  fetchAllTicks('2009-01-02 07:06:00', '1d', 'AAPL');
  return () => alert('unmounting')
});

Run server

notes

  1. to actually upgrade the packages to latest we could do yarn global add npm-check-updates && npm-check-updates -u && yarn upgrade

Backend Routes

HTML

API Endpoints

ticks

Postgres Database Schema

ticks

column name data type details
id integer
tick_time datetime
open float
close float
low float
high float
volume integer