# investbook

### Problem Statement 
Although people choose to invest in stocks indirectly under a retirement account such as an IRA or a 401k, according to the [pew research center](https://www.pewresearch.org/fact-tank/2020/03/25/more-than-half-of-u-s-households-have-some-investment-in-the-stock-market/) approximately 48% of U.S. Households do not hold any investments in the U.S. stock market and over 80% of households do not own individual stocks. Americans of modest incomes are significantly less invested in the stock market than wealthier Americans are.

With the advent of technology, access to information has never been easier. 
Like everything in life, investing is hard to understand until you try it and learn from your mistakes. Doing the same with real money may not be an option for majority of the people. Investbook allows you to build your portfolio with paper money and see how you perform over time.
> "Buy a stock the way you would buy a house. Understand and like it such that you'd be content to own it in the absence of any market." - Warren Buffett

### Investbook Links
 [GitHub Repository](https://github.com/maheshrai/investbook) 

 [Vercel App](http://investbook.vercel.app/) 

### Architecture
Investbook is developed using [nextjs](https://nextjs.org/) framework and [tailwindcss](https://tailwindcss.com/) . The backend is hosted on  [AWS](https://aws.amazon.com/)  and uses DynamoDB for database, AppSync for GraphQL APIs and Cognito for user management, authentication and authorization. The application also uses  [IEX Cloud](https://iexcloud.io/)  for financial data. The application is deployed on [Vercel](https://vercel.com/). 
Below is the high level architecture diagram.
![Screen Shot 2021-02-07 at 10.47.31 AM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1612720264180/nAaRa96HF.png)

### Data Model
Here is the data model of the application. 
![Screen Shot 2021-02-07 at 3.10.26 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1612735866358/U07nczdUR.png)

### Tools and Libraries Used
[AWS Amplify](https://aws.amazon.com/amplify/) was used to configure the application's backend. Amplify generates the needed GraphQL queries and mutations automatically. Below is an example of getting a portfolio by username using the GraphQL API

```
import { API } from 'aws-amplify';
import { getPortfolio } from "../graphql/queries";

const portfolio = await API.graphql({
    query: getPortfolio,
     variables: { id },
});

``` 
### Deployment
[Vercel for Github](https://vercel.com/docs/git/vercel-for-github#) makes it really easy to deploy application from GitHub. 

### Demo

%[https://www.loom.com/share/6eee1847107540b7beeb146b0332cb4d]





