Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Milestone pull request submission #45

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.DS_Store
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Your Project Name
# Stock Tracker Ripoff that isn't named yet

This is the starter code for WDI projects. Please update this README file with information specific to your project. Replace this paragraph for instance, with a short description of your project. Then update the sections below. Refer to your project specificaion for instructions on how to submit your projects.
This is a stock tracker app that is still WIP. When finished, it can double as a real time stock tracker cum stock trading simulator to help users better keep in touch with the market and better manage their trading portfolios.

## Getting Started

Provide instructions here about how to get your project running on our local machine. Do we just need to clone and open a certain file or do we need to install anything first.

### Prerequisites

What is needed to install and run the project, how do we install them
Download this and then install whatever dependencies using yarn. Then start the server

```
Code example
$ yarn install
$ nodemon
```
It is recommended that you use nodemon to run the server.

### How to Use

Expand Down Expand Up @@ -51,7 +53,28 @@ What did you use to build it, list the technologies, plugins, gems, packages etc

## Workflow

Did you write user stories, draw wireframes, use task tracking, produce ERDs? Did you use source control, with regular commits? Include links to them here.
The below wireframes detail the homepage,summary page, positions page, registration page and login page, in that order.


![alt text](https://github.com/empludo/project-2/blob/master/images/homepage.png )

![alt text](https://github.com/empludo/project-2/blob/master/images/summary.png )

![alt text](https://github.com/empludo/project-2/blob/master/images/positions.png )

![alt text](https://github.com/empludo/project-2/blob/master/images/register.png )

![alt text](https://github.com/empludo/project-2/blob/master/images/login.png )


Entity Relationship Diagram (Subject to change)

![alt text](https://github.com/empludo/project-2/blob/master/images/erd.png )


## User Stories

This app seeks to help investors track their investments in real time, with the help of the API Alpha Vantage, which gives real time updates on share prices. (WIP not implemented yet) Users will have to create an account, and upon creation of their accounts, they can begin to input the shares that they have bought. The positions that they have taken will be stored, and can be condensed into a summary detailing their total profits and losses. The app can also double as a trading simulator for shares until the user feels confident enough to trade with real money.

## Authors

Expand Down
42 changes: 42 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const express = require('express')
const app = express()
const session = require('express-session')
const expressValidator = require('express-validator')
const methodOverride = require('method-override')
const mongoose = require('mongoose')
const exphbs = require('express-handlebars')
const path = require('path')
const server = require("http").createServer(app)//sockets
const io = require("socket.io")(server)
const flash = require('connect-flash')
const passport = require('passport')
const port = process.env.PORT || 3000

const routes = require('./routes/routes')
const dbConfig = require('./config/dbConfig')

//db Configuration
mongoose.Promise = global.Promise
mongoose.connect(dbConfig.url, { useMongoClient : true })
.then(()=>{ console.log("-- Mongoose ok ---")}, (err) =>{ console.log(err) } )

app.use(cookieParser()); // read cookies (needed for auth)
app.use(bodyParser.json())// get information from html forms
app.use(bodyParser.urlencoded({ extended: true }))

app.use(express.static(path.join(__dirname, 'public'))) //Set static path to public
app.engine('handlebars', exphbs({ defaultLayout: 'main'}))
app.set('view engine', 'handlebars')

app.use(session({ secret: 'cogitoergoest', resave: false,
saveUninitialized: true })); // session secret

//Routes
app.use('/', routes)


app.listen(port, ()=>{
console.log('express-connected');
})
3 changes: 3 additions & 0 deletions config/dbConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"url" : "mongodb://localhost/ztest"
}
9 changes: 9 additions & 0 deletions controllers/authController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const User = require('../models/user')

exports.login = (req, res) => {
res.render('users/login')
}

exports.register = (req, res) => {
res.render('users/register')
}
21 changes: 21 additions & 0 deletions controllers/homeController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

// const User = require('../models/user');

//Index Home page
exports.index = (req, res)=>{
res.render('home')
}

exports.positions = (req, res)=>{
res.render('positions')
}

exports.summary = (req, res)=>{
res.render('summary')
}

//Index Home page
exports.home = (req, res)=>{

res.render('home')
}
Binary file added images/.DS_Store
Binary file not shown.
Binary file added images/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/positions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/register.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/.DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const userSchema = new Schema({
name: {
type: String,
required: [true, 'Please type in your name']
},
email: {
type: String,
required: [true, 'Please type in your email']
},
password: {
type: String,
required: true
}
})

const User = mongoose.model('User', userSchema)
module.exports = User
28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
{
"name": "project-2",
"name": "ztest",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/wdi-sg/project-2.git",
"author": "Prima Aulia Gusta <primaulia@gmail.com>",
"license": "MIT"
"main": "app.js",
"author": "fuckoff",
"license": "MIT",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"bcrypt": "^1.0.3",
"body-parser": "^1.18.2",
"bulma": "^0.6.1",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.3",
"express": "^4.16.2",
"express-handlebars": "^3.0.0",
"express-session": "^1.15.6",
"express-validator": "^4.3.0",
"method-override": "^2.3.10",
"mongoose": "^4.13.7",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"socket.io": "^2.0.4"
}
}
18 changes: 18 additions & 0 deletions routes/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const express = require('express')
const router = express.Router()

//Controllers
const homeController = require('../controllers/homeController.js')
const authController = require('../controllers/authController.js')

//Routes
router.get('/', homeController.home)
router.get('/positions',homeController.positions)
router.get('/summary', homeController.summary)

router.get('/users/login', authController.login)
router.get('/users/register', authController.register)



module.exports = router
Binary file added views/.DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions views/home.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


<div class="container">
<h3 >Welcome </h3>

A simple portfolio manager to help manage your investments

<p >
<br>Track your portfolio of stocks in real-time
</p>


</div>
</body>
59 changes: 59 additions & 0 deletions views/layouts/main.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Pirated Trade Hero Wannabe</title>

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css">
<body>

<nav
class="navbar is-dark" role="navigation" aria-label="main navigation"

>
<div class="navbar-brand">

<a class="navbar-item" href="/">Investment Assistant</a>

</div>

<div class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="/">Home</a>
<a class="navbar-item" href="/summary">Summary</a>
<a class="navbar-item" href="/positions">Stock Positions</a>

</div>

<div class="navbar-end">
<a class="navbar-item" href="/users/register">Register</a>
<a class="navbar-item" href="/users/login">Login</a>

</div>
</div>
</nav>
<div >
{{{ body }}}
</div>
<footer class="footer">
<div class="container">
<div class="content has-text-centered">
<p>
Copyright 2017. API by <a href="https://www.alphavantage.co/">Alpha Vantage</a>
</p>
</div>
</div>
</footer>





<script src="https://code.jquery.com/jquery-3.2.1.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.bundle.min.js" charset="utf-8"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this plugin for?


</body>
</html>
64 changes: 64 additions & 0 deletions views/positions.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to reduce the usage of <br> in your views

<strong>Positions Taken </strong>
<br>
<form action="/positions" method="post">
<label for="name">Name</label>
<input type="text" name="position[name]" placeholder="">

<label for="ticker">Ticker Symbol</label>
<input type="text" name="position[ticker]" placeholder="">

<label for="units">Unit Quantity</label>
<input type="number" name="position[units]" placeholder="">

<label for="price">Price</label>
<input type="number" name="position[price]" placeholder="USD">

<label for="buyDate">Buy Date</label>
<input type="date" name="position[buyDate]" placeholder="dd/mm/yyyy">




<br>



<br>
<label for="closingPrice">Closing price</label>
<input type="number" name="position[closingPrice]" placeholder="USD">

<button type="submit" name="button">Buy</button>

</form>


<table >

  <thead>
    <tr>
      <th>Name</th>
      <th>Ticker</th>
      <th>Buy date</th>
<th>Sell date </th>
      <th>Units owned</th>
      <th>Price</th>
      <th>Amount Invested <br> (USD)</th>
      <th>Closing Price</th>
<th>Current Price <br> (USD)</th>

    </tr>

  </thead>


    <tr>

      <th>Total Value</th>

    </tr>


</table>

<a href="/summary">Portfolio Summary</a>
19 changes: 19 additions & 0 deletions views/summary.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<br>
<strong>Portfolio Summary</strong>


<table >

  <thead >
    <tr>
      <th>Total amount invested <br> (USD)</th>
      <th>Current Portfolio Value <br> (USD) </th>
<th>Total Gain(Loss) <br> (USD) </th>


    </tr>
  </thead>



</table>
18 changes: 18 additions & 0 deletions views/users/login.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<strong>Login</strong>

<form action="/login" method="post">
<br>


<label for="email">Email :</label>

<input type="email" name="user[email]" placeholder="e.g. ebereiweala@gmail.com">
<br>

<label for="password">Password :</label>

<input type="password" name="user[password]" placeholder="password">
<br>

<button type="submit" name="button">Submit</button>
</form>
Loading