Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
34e7cf0
first commit
nick-devos Sep 11, 2020
6c78bc6
updated application properties for mysql
nick-devos Sep 11, 2020
c52040e
update
nick-devos Sep 12, 2020
d4d057b
update
nick-devos Sep 13, 2020
70ffa43
StockOverview gets JSON data
nick-devos Sep 13, 2020
e565a22
update
nick-devos Sep 14, 2020
dad1a8d
update
nick-devos Sep 14, 2020
ead1389
update
nick-devos Sep 15, 2020
4a4fb02
update
nick-devos Sep 16, 2020
da3a472
update
nick-devos Sep 18, 2020
0833700
news jsp progress
nick-devos Sep 18, 2020
348326d
jsp update
nick-devos Sep 20, 2020
d73b1e7
update
nick-devos Sep 21, 2020
01876b2
update links
nick-devos Sep 21, 2020
a707032
added spring security and consolidated controllers
nick-devos Sep 22, 2020
cff1e0a
before starting registration tut
nick-devos Sep 22, 2020
da9b9d5
starting new login and registration implementation
nick-devos Sep 23, 2020
01812bf
merged casestudy with jsp login template - not finished
nick-devos Sep 23, 2020
ae688ce
potentially successful merge of login/registration template
nick-devos Sep 23, 2020
65fe547
stable state
nick-devos Sep 24, 2020
2d9379e
changed redirect path on login
nick-devos Sep 24, 2020
f7e5234
added logout functionality to all pages
nick-devos Sep 24, 2020
cf612d6
had to move styling for login from style.css to <script> block in HTML
nick-devos Sep 24, 2020
325904d
tweaked css
nick-devos Sep 24, 2020
46929e5
more css
nick-devos Sep 24, 2020
3cee6a3
added validation.properties path to application.properties
nick-devos Sep 25, 2020
6816bac
first draft of readme
nick-devos Sep 25, 2020
4c178a7
update
nick-devos Sep 25, 2020
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
682 changes: 682 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Binary file added 0.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 1.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 10.jpg
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 11.jpg
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 12.jpg
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 13.jpg
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 14.jpg
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 2.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 3.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 4.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 5.jpg
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 6.jpg
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 7.jpg
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 8.jpg
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 9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 53 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
# Full Stack Web Application
# Case Study Submission

* **Objective** - to create an implementation of a web service
* **Purpose** - to demonstrate the construction of a full-stacked web-application
* **Description**
* This Case Study is your first foray into building a full-stack application. You'll be building a Spring MVC based application, which means you'll learn about what it takes to build a functional application from the ground up yourself.
* This is exciting! It's a lot, but we've given you the tools to be able to build what you need, and you get to decide what you do with it. You also get to be creative in choosing what sort of application you want to build!
* You will be working individually to design your app. We hope you'll exercise creativity on this project, sketch some wireframes before you start, make sure you have time to run these ideas by your instructors to get their feedback before you dive too deep into coding! Remember to keep things small and focus on mastering the fundamentals.
* **Additional Resources**
* [The Original Case Study Document](./case-study.pdf)
* [Case Study Outline](./case-study-outline.pdf)
* [Case Study Deliverables](./README_deliverables.md)
* [Identifying Plagiarism](./README_plagiarism.md)
* [Suggested Project Topics](./README_suggested-project-topics.md)
## Project Overview
<i>The purpose of this project is to satisfy the requirements for graduation from Per Scholas program.</i> <br>

This application allows a user to make an account or login to an existing account and view stock market information. The user selects which companies to view information about and an API call is made to return a JSON object to this application, where the information is presented to the user.

# How to setup
<b>Step 1:</b> Navigate to https://github.com/nick-devos/casestudy.fullstack_webapplication and clone the project.
<img src="0.PNG"/>

## Minimum Features
* `RESTful` web service which consumes requests from a front-end web application and caches each request and the respective response to a database.
* The application must support a login functionality.
Use your `git bash` terminal to clone a copy of the project to the local directory of your choosing.
<img src="1.PNG"/>


<b>Step 2:</b> This project uses MySql to persist login credentials and requires some configuration to do so. First, navigate to your MySql Workbench and take note of the username, password (will not be shown), and host location needed to to access the DBMS.
<img src="2.PNG"/>

We will need to create a database for the program to use, so enter the DBMS and create a database by writing one simple statement. Here I have chosen to call the database `casestudy`. So, my statment is `create database casestudy;` Execute the statement and make sure it is successful by checking the output.
<img src="3.PNG"/>

## Developmental Notes
<b>Step 3:</b> Now we will make sure the program points to the correct database. Navigate to the project directory and open the `pom.xml` file in your IDE.
<img src="4.PNG"/>

### Tech Stack Selection
* Select at least 1 technology from each of the following categories:
* **Version Control System**
1. Github
2. Bitbucket

* **Wireframe**
1. Mockflow
2. Balsamiq
3. Lucidcharts
Once the project is built, navigate to the `application.properties`. If needed, change the `spring.datasource.url`, `spring.datasource.username`, and `spring.datasource.password` to reflect your own settings noted in step 2.
<img src="5.jpg"/>

* **Frontend**
1. Angular
2. React
3. Vue.JS

* **Business Logic**
1. Java
2. TypeScript
<b>Step 4:</b> Run the project. This can be accomplished by pressing `Shift + F10` if you're on a PC. Alternatively, in the menu on top of the window, click `Run` &rarr; `Run 'CasestudyApplication'`. If you have maven installed, you can use the command `mvn spring-boot:run`. If something is already running on port 8080, run the `kill-8080.bat` or `kill-8080.sh` included in the project files. Ensure that the project begins running.
<img src="6.jpg"/>

* **WebServer Implementation**
1. Spring Boot
2. At least 1 [backing service](https://12factor.net/backing-services) API
<b>Step 5:</b> Open an internet browser and navigate to `localhost:8080/login`. This is where you will login after creating an account. Click `Create an account` under the login button. This will redirect you to the registration page. Create a username and password (username must be 6-32 characters, password must be at least 8 characters).
<img src="7.jpg"/>

* **Data Layer**
1. MySQL
2. PostgreSQL
3. MariaDB
Upon successful creation of a user, you will be redirected to the welcome screen.
<img src="8.jpg"/>

* **Web Server Cloud Deployment**
1. Heroku
2. AWS EC2 Instance

* **Web Application Cloud Deployment**
1. Netlify
2. AWS EC2 Instance
From here you can use the links in the navbar to navigate to the pages available to logged-in users.

# Exploring the program

<b>Market News: </b> The market news page allows a user to see the 20 most recent news articles for the entire market provided by Finnhub's API.
<img src="9.jpg"/>

<b>Company Overview: </b> The company overview page is the most complex and powerful page of the project. Upon navigating to the page, it is auto-populated with data for Amazon.
<img src="10.jpg"/>

### Installation
* It is advised that you make install each of the following technologies to ensure that are at least accessible
* Install [NodeJs](https://nodejs.org/en/).
* Install [Angular](http://angular.io/).
* Install [AngularCli](https://cli.angular.io/).
However, a user may use the search bar at the top to enter the symbol/ticker of a desired stock, such as 'TSLA' for Tesla, and the page will show data for that particular stock. This page uses 3 seperate API's to populate data (Finnhub, AlphaVantage, and IEXCloud).
<img src="11.jpg"/>

One of the data points provided is a 5 day price chart of the stock price of the security. This is done using the Chart.js open-source library. (Note: Sometimes the chart fails to render on load, however if you resize the window, the chart will populate with data.)
<img src="12.jpg"/>

Under the chart is the company's description and general information about the company, financial information, and dividend information.
<img src="13.jpg"/>

On the bottom of the page is news articles directly related to the security specified. The program is designed to fetch the last month's worth of articles however, it also displays a max of 21 articles so you don't have hundreds of articles on one page for companies like Amazon with large quantities of articles.

When you're done using the program just click the `Logout` link at the top right of the window (far right of the navbar) and you will be logged out and redirected to the login page, where you will see a message displaying that you have successfully logged out.
<img src="14.jpg"/>

# How it works
Due to the constant changing of information in the stock market, the stock data is not persisted into the database. Each time you load the market news page one API call is made to Finnhub. Loading the company overview page and each subsequent change of stock symbols makes a total of 4 API calls (AlphaVantage: 1, Finnhub:1, IEXCloud: 2). Since data is not being persisted to the database, API calls are made in JavaScript and displayed in HTML. JavaScript receives JSON data from the external API's and uses templates created by me to display the parsed JSON elements in their desired locations. <b>Due to the use of free tokens from API providers, you may hit the limit for API calls and get an error instead of receiving company data if too many API calls are made in a short period of time.</b>

Login functionality is made possible with Spring Security. The program uses custom login and registration JSP pages to gather information from the user.

###### Technologies used
* Spring MVC &rarr; Java
* JSP &rarr; HTML, CSS, Js
* MySQL
* Git
52 changes: 0 additions & 52 deletions README_deliverables.md

This file was deleted.

20 changes: 0 additions & 20 deletions README_plagiarism.md

This file was deleted.

Loading