Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Fix issues for fresh setup #547

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/clientProdDeploy

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/pullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
- run: npm run lint
- run: npm run shared
- run: npm run tsc
- run: npm run test
90 changes: 37 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Prerequisite
# Environment
```
# setup redis
sudo apt install redis-server
Expand All @@ -15,76 +15,60 @@ sudo apt-get install -y nodejs
sudo npm install -g pm2
```

# Prerequisite
- Create a postgres database "melody-invest"
- Get a Tiingo API KEY

# Quick Start
```
cp ./client/.env.example ./client/.env
cp ./server/.env.example ./server/.env
cp ./client/.env.example ./client/.env # Replace env vars if needed
cp ./server/.env.example ./server/.env # Replace env vars if needed, including redis, database, mailer configs
npm install
npm run basic
npm run dev
npm run shared
cd server
npm run migrate
cd ../
npm run dev # open http://127.0.0.1:3099 in browser
```

# Project Structure:
# Data Preparation
## Initial Preparation
Save your Tiingo key on "Profile" page
Create tickers on "Manage Tickers" Page
```
scripts ->
mocks -> files used by unit test
devOps -> files used by devOps

interfaces -> shared interfaces for the whole project
constants -> shared constants for the whole project
helpers -> shared functions for the whole project

client -> frontend site for general users
index.tsx -> React root
index.css -> basic global styles
locales -> translation files used by client only
containers -> React components
blocks -> larger reusable components depend on state
elements -> smaller reusable components do not depend on state
enums -> constants used by client only
tools -> pure functions used by client only
adapters -> wrappers for outer resources
hooks -> general hooks to handle specific tasks
actions -> Redux actions and async actions
selectors -> Redux selectors
stores -> Redux stores

server -> backend APIs for the whole project
index.ts -> Express root
cli.ts -> NPM command root
cron.ts -> Node Cron root
adapters -> wrappers for outer resources
tools -> pure functions used by server only
enums -> constants used by server only
locales -> translation files by server only
middlewares -> Express middlewares
models -> database representative functions
routers -> Express routers
logics -> specific business logic functions
services -> api or cli request handlers
shared -> single purpose data parsing functions
tasks -> cli command handlers
templates -> email templates
migrations -> Knex migrations
cd server
npm run build
```

# Manual Schedules
Daily:
## Daily Preparation
```
npm run syncTickerPrices
# Sync prices of your tickers
npm run syncTickerPrices yyyy-MM-DD

# Calculate price movements based on ticker prices
npm run calcPriceMovements

# Prepare daily ticker data for final calculation
npm run calcDailyTickers
```
Weekly:

## Weekly Preparation
```
npm run syncTickerFinancials
# Sync financial statements of your tickers
npm run syncTickerFinancials yyyy-MM

# Calculate financial movements based on financial data
npm run calcFinancialMovements
npm run calcDailyTickers

# Update indicator tables with most up to date data
# Calculate economy indicator movemeents based on economy data
npm run calcIndicatorMovements

# Prepare daily indicator data for final calculation
npm run calcDailyIndicators
```

# Indicator Data Collect
## Indicator Data References
Yearly Inflation: https://www.usinflationcalculator.com/inflation/current-inflation-rates/
Yearly GDP: https://en.wikipedia.org/wiki/Economy_of_the_United_States
Quarterly Seasonal GDP: https://fred.stlouisfed.org/series/NA000254Q
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ProfileDashboard = () => {
<AddButton
data-testid='addProfileBtn'
onClick={handleClickAddProfile}
disabled={!user.access.canFollowTrader}
disabled={!user.access.canFollowTrader || !envs.length}
title={localeTool.t('dashboard.newBtn')}
tooltip={
user.access.canFollowTrader
Expand Down
2 changes: 1 addition & 1 deletion client/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"translation": {
"shared.dataSource": "Tiingo, Alpha Vantage",
"shared.dataSource": "Tiingo",

"unwatchEnvModal.title": "Unwatch this environment",
"unwatchEnvModal.desc": "Unwatch this environment will automatically unwatch all the trader profiles you followed from this environment as well. Do you want to continue?",
Expand Down
1 change: 0 additions & 1 deletion constants/src/entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const DataSource = Object.freeze({
Tiingo: 'Tiingo',
AlphaVantage: 'AlphaVantage',
})

export const DataMarkup = '*****'
4 changes: 2 additions & 2 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ DB_USER=test
DB_PASS=123
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=melody
DB_NAME=melody-invest

CACHE_HOST=127.0.0.1
CACHE_PORT=6379
Expand All @@ -23,7 +23,7 @@ DATA_KEY_SECRET=345
CLIENT_HOST=127.0.0.1:3099
CLIENT_TYPE=http

EMAIL_SENDER=[email protected]
EMAIL_SENDER=
EMAIL_HOST=smtp-mail.outlook.com
EMAIL_PORT=587
EMAIL_PASS=123
Expand Down
1 change: 0 additions & 1 deletion server/adapters/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export const create = async ({
return record[0]
} catch (e) {
await transaction.rollback()
console.log(222)
console.error(e)
throw errorEnum.Custom.CreationFailed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ exports.up = (knex) => {
return knex.schema
.createTable('entity', (table) => {
table.increments('id')
table.string('dataKey', 20)
table.text('dataKey')
table.string('dataSource', 20)
table.boolean('isValidKey')
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports.up = (knex) => {
table.increments('id')
table.integer('entityId').notNullable()
table.foreign('entityId').references('id').inTable('entity')
table.string('name', 50).notNullable()
table.string('symbol', 10).notNullable()
table.boolean('isDelisted').defaultTo(false).notNullable()
table.specificType('region', 'CHAR(2)').notNullable()
Expand Down
17 changes: 17 additions & 0 deletions server/migrations/0023_policy_seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.up = (knex) => {
return knex('policy').insert([
{
type: 1,
content: 'Privacy policy',
createdAt: new Date(),
},
{
type: 2,
content: 'Terms and Conditions',
createdAt: new Date(),
},
])
}

exports.down = (knex) => {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ exports.up = (knex) => {

exports.down = (knex) => {
return knex.schema.dropTable('daily_indicators')
}
}
20 changes: 0 additions & 20 deletions server/migrations/20230416150000_create_entity_table.js

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions server/migrations/20230416200000_drop_ticker_category_table.js

This file was deleted.

15 changes: 0 additions & 15 deletions server/migrations/20230416213000_remove_isSystem_to_env_table.js

This file was deleted.

13 changes: 0 additions & 13 deletions server/migrations/20230418203000_remove_name_to_ticker_table.js

This file was deleted.

This file was deleted.

Loading
Loading