A stock portfolio management webapp
This README is divided into setup instructions for users and relevant instructions for project devs:
πΆ User Manual π£ Developer Manual
These instructions are intended for Lubuntu 20.4.1 LTS. Please use an upgraded Chrome browser for the best UI experience.
To install this project, get the .zip file containing the codebase either from the submission channel or via https://github.com/unsw-cse-comp3900-9900-21T3/capstone-project-9900-h18c-codependent
(Click Code > Download ZIP to obtain the .zip file)
After that, extract the .zip file contents to the desired location.
The fastest way to set up the project is through the provided shell scripts. Please run the following scripts in order from project root:
Please prefix all these scripts with the bash command to avoid permission issues.
./install.sh: Install the required packages and setup the environment./start-backend.sh: Start the backend server./start-frontend.sh: Start the frontend server Optional feature scripts:./start-price-alert.sh: Start the price alert script./start-challenge.sh: Start the Portfolio Challenge
-
Open the terminal
-
Run commands to install the required packages
sudo apt-get update sudo apt-get install python3 python3-venv -
Navigate to
stockzen-backendfolder -
Create a virtual environment by running the command:
python3 -m venv .venv -
Activate the virtualenv:
source .venv/bin/activate -
Install the package wheel (special requirement for Lubuntu):
pip3 install wheel -
Install packages for backend
pip3 install -r requirements.txt -
Create the environment file
.flaskenvfrom.flaskenv.default(copy the default file):cp .flaskenv.default .flaskenv -
Edit the variables in the
flaskenvfile-
FLASK_ENV: The mode of the backend. It should be set toproductionin live setup -
SESSION_KEY: The key of the session. It should be init to some random string -
MAIL_USERNAME: The username of a MailTrap account. See Price Alert section below. -
MAIL_PASSWORD: The username of a MailTrap account. See Price Alert section below. onlyNote: You may use our API credentials, but you will not be able to inspect the email response:
MAIL_USERNAME=a15b07c5c03683 MAIL_PASSWORD=69cce18ae605e1
-
-
Start the backend server by running:
flask run -
Open a browser and navigate to http://localhost:5000/ to access the Swagger documentation.
- Open a new terminal
- Run commands to install the required packages
sudo apt-get update sudo apt-get install nodejs npm - Navigate to
stockzen-frontendfolder - Install the required packed by running:
npm install - Start the frontend server by running:
npm run start - Open a browser and navigate to http://localhost:3000/ to access the website.
To activate the price alert functionality, the variables MAIL_USERNAME and MAIL_PASSWORD must be set, and backend must be setup and working.
*Note:*
- *If you would like to inspect the Price Alert responses in detail, please create a https://mailtrap.io/
account β account login cannot be provided here for security and privacy reasons.*
- *Otherwise, you may use our API credentials, but you will not be able to inspect the email response:*
```
MAIL_USERNAME=a15b07c5c03683
MAIL_PASSWORD=69cce18ae605e1
```
- Navigate to
stockzen-backendfolder - Activate the virtualenv by run
source .venv/bin/activate - Start the script by run
flask price-alert run - To stop the script, press Ctrl+C when it shows 'Sleeping' in the terminal
-
Navigate to
stockzen-backendfolder -
Activate the virtualenv by running:
source .venv/bin/activate -
Start the script by running:
flask challenge run prod -
To end the challenge, press Ctrl+C two times to force-step through the challenge phases (Normally this would take 2 weeks to naturally progress β this can be altered in the
config.pyfile if so desired).
Technical READMEs are located within the respective frontend / backend folders.
π³ Project Structure π Installation Guide πΈ Diary π£ IDE Tooling: Formatters & Extensions πΆ Branching / Pull Requests
- Frontend code:
./stockzen-frontend - Backend code:
./stockzen-backend- Backend server code:
./stockzen-backend/app - ML code:
./stockzen-backend/predict
- Backend server code:
- Diary storage:
./diary(see Pushing your diary)
The following instructions assume UNIX-based OS. If you are on Windows, you need to install WSL Ubuntu or develop on VLab.
-
Ensure your
node(v10.19.0) is installed. Do not updatenpm.Optional:
- you can manage your
nodeversion withnvm(Node Version Manager) - a
.nvmrcfile is committed to the repo to assist with this. Installvscode-nvmextension to always automatically use the correctnodeversion
- you can manage your
-
Ensure
yarnis installed. Otherwise:$ npm install --global yarn
-
Navigate into
stockzen-frontendand install withyarn:$ cd stockzen-frontend $ yarn -
Run:
$ npm install
Note:
npm installneeds to be run after everygit pullin case there are new dependencies -
To start the frontend development server, do:
$ yarn start
The build will recompile and deploy automatically on saving changes.
-
Ensure you have
python3(v3.8.2) installed/updated. -
Navigate into
./stockzen-backendand set up a Python virtual environment with::$ cd stockzen-backend $ python -m venv .venv -
Everytime you work on the backend, ensure you have done:
$ source .venv/bin/activate- Optional:
Add
alias venv="source .venv/bin/activate"to the bottom of your~/.bashrcfile so that the environment to be activated by just typing:$ venv
- Optional:
Add
-
While still in
stockzen-backend, activatevenvand then install Python dependencies with:$ pip install -r requirements.txt
This will have to be done after every
git pullto ensure you always have the latest dependencies -
Request for the
.flaskenvfile from another dev. It should sit in./stockzen-backend/and holds the environment variables and flask session secret key.- this is a good time to visit Alpha Vantage to get your own API Key for use in development
- add this key to the bottom of
stockzen-backend/.flaskenvas a new line:AV_API_KEY=<your-api-key> AV_API_KEYcan then be used anywhere with the Pythonalpha_vantagepackage when querying the API
-
To start the backend development server, from
stockzen-backenddo:$ flask run
The build will recompile and deploy automatically on saving changes, but a manual refresh of the Swagger page may be necessary to fetch the latest changes.
Note: remember to switch FLASK_ENV to "production" when deploying final build
β‘οΈ Shortcut:
Once you have set everything up, VSCode has been configured so you can just do: ctrl+p and entertask Dev to start all development servers at once
-
Checkout the diary branch:
$ git checkout diary
- If you have uncommitted changes on your current branch, then do this first:
$ git stash
- If you have uncommitted changes on your current branch, then do this first:
-
Pull to update
diarybranch:$ git pull
-
Commit your latest diary:
$ git add ./diary/zXXXXXXX.txt $ git commit -m "Update diary - <dev-initials>"where
<dev-initials>is likeKL -
Push your changes:
$ git push
-
Switch back to your original branch and unstash to resume work:
$ git checkout <orignal-branch-name> $ git stash pop
Note: diary branch will be merged into main at the end of each sprint
Below are suggestions for toolings.
The only necessary ones are the Formatters, so that committed code is consistent, keeping git diffs cleaner and Peer Reviews easier.
Note: The below assumes VS Code IDE is being used
| Language | Formatter | Linter | Lang. Server |
|---|---|---|---|
| Python | black | Python (MS) | Pylance |
| JS | _ Prettier _ | ESLint | - |
Other useful extensions:
- vscode-nvm - automatically uses the correct
nodeversion - Git Graph - clear graphical representation of
githistory - Todo Tree - nicely collects all
TODO:,FIXME:,BUG:, etc tags in a tab - SQLite - perform independent SQL queries in a separate window
- Types of branches:
feat- new feature, coming from a Jira subtaskbugfix- fixing something previously commited that has bugsreview- just a code review, but might refactor or make some changes
- Naming convention:
We will use the following pattern for branch names:
<type>-<f/b>/<descriptive-name>where f = frontend, b = backend
You will most often create a new branch when you start working on a new feature (i.e. when a new subtask is assigned to you)
Example subtask: Frontend Registration page and input validation
You can create a branch from either the command line or from VS Code.
-
With CLI:
git checkout -b feat-f/registration-page <--this is your local branch git push -u origin feat-f/registration-page <--this sets the remote ("online") branch
-
With VS Code: i. Click on the branch icon on the bottom left:
ii. Click on "Create new branch":
iii. Enter
feat-f/registration-pageiv. Click on the cloud icon to push your new branch to github:
You can now start working from here, and make commits and pushes etc.
Pull Requests are for when you're done with your part and you want to submit/merge your changes to main - someone will need to review your code before this can happen.
(You could also PR when you just need a peer review - use the draft PR option)
Please ensure you have tested your feature as much as possible before requesting a PR - the reviewer should not need to test that everything works.
-
Create a PR:
-
If you have recently pushed your branch to github, there will be a banner that says
Create pull requestwhich you can click on -
Otherwise navigate to the Pull Requests tab and click
New pull request
-
-
Follow the pre-loaded PR template instructions to complete the PR details.
-
Add a
reviewerand add yourself asinitiator -
Add an appropriate tag. Submit. Wait for feedback.


