Skip to content

Instantly share code, notes, and snippets.

@NylonEric
Forked from trentgoing/001 - Journal Homepage.md
Last active July 12, 2021 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NylonEric/372516f2fe3c9f708d20e7e2f77007cb to your computer and use it in GitHub Desktop.
Save NylonEric/372516f2fe3c9f708d20e7e2f77007cb to your computer and use it in GitHub Desktop.
FEC Engineering Journal

FEC Engineering Journal

This gist details the decisions I made, technologies used and important design patterns for the Front End Capstone Project: Atelier

https://github.com/Idakka/Project-Atelier/

Goals

Design and implement the Ratings And Reviews widget for the Atelier FEC project for Hack Reactor Remote Part Time cohort 28

Achievements

Desing and implement an Amazon s3 storage bucket and all API connections to it.

Reflections

Daily Summary

May 26, 2021

Overview

Today was the second class day of the project. I spent an hour before class reviewing the visual docs and the various components in the business doc.

Log

7:00pm -

Challenge/Motivation

The challenge is to quickly gain a 30k foot view of the entire project and plan the skeleton and first steps without getting bogged down in any details yet.

Actions Taken

I read the documents and started copying spec files and other resources into our group Trello to keep everything in one place as the source of truth.

Results Observed

I felt more comfortable with our scope and workflow after reviewing docs and planning with the team.

11:00pm - finish setting up all collaborative tools (trello, github, docs, standup calendar etc.)

Challenge/Motivation

I wanted to make sure I had a mental model for the heirarchy of the project and workflow.

Actions Taken

I put reference to all of the spec docs into Trello as our ticket system will be the place of truth for feature, implementation, and research work.

Results Observed

I am much more comfortable with the skeleton of the journey we are about to embark on.

May 27, 2021

Overview

Today was spent organizing documents and researching file upload approches.

Log

11:00am - 1pm

Challenge/Motivation

What is/are the best way(s) to upload images to our application server.

Actions Taken

I found documentation for using formdata with both axios and regular browser methods.

Results Observed

I felt comfortable on starting to implement the file upload methods and components.

May 27, 2021

Overview

Today was spent investigating the 4 major widgets of the app. We did a classtime workshop and split off to plan within the team.

Log

1:00pm - 3:30pm

Challenge/Motivation

Who will be responsible for which component? What are the first steps to get a skeleton rendered?

Actions Taken

I made a basic component and pushed the commits and made a pull request.

Results Observed

I felt comfortable on starting to implement the file upload methods and components.

May 31, 2021

Overview

Log

11:00am - 3:30pm

Challenge/Motivation

I wanted to get a skeleton with all div/elements and sub-components represented and get it rendered on the browser.

Actions Taken

I made an outline of all html elements over the visual example we were given with relative nexting represented by different colors.

Results Observed

I initially had a bug preventing render caused by some confusion about naming convention for our different components. I sent a slack message and we arrived at PascalCase and so I added that to my commit. I should have separated this debugging concern out but I needed to fix it for anything else to work. I'll only stage the files needed for that one concern going forward to keep commits and PRs granular.

Log

5:00pm - 7:30pm

Challenge/Motivation

Actions Taken

Results Observed

June 8, 2021

Overview

I worked on rendering more aspects of the Ratings and Reviews component as well as getting Mock Data from the API using Postman and including it in the client side of the app.

Log

11:00am - 2:30pm

Challenge/Motivation

I wanted to import the star-review component that Milo created and make sure I understand how parameters are passed in and handled.

Actions Taken

Put the star review component into the appropriate div and passed a hard coded value as a placeholder.

Results Observed

Since the component already had div classNames and data-testid, there were redundant nesting of divs and the test suite broke. I removed the encapsulating divs from the top-level component and will continue to do so as I add sub-components. It will also be helpful to create the remaining components with react fragments to reduce the nested div clutter going forward.

Log

5:00pm - 7:30pm

Challenge/Motivation

I wanted to put a mock version of the various API GET query returns in the client side so all of the devs can use that to mock up the rendering of their components. It is also important to not keep querying the APIs since there are rate limits and we have already hit them before during development.

Actions Taken

I added mock data for all of the API GET requests. The data is currently imported into ProductDetailPage.jsx in the same data type as it returns from API GET requests (array/object). This is a temporary measure just to get the client passing the data in without constantly hitting the external API. I also created several tests for mock data types.

Results Observed

The data is being passed into a console.log statement and the tests are are currently directly accesssing the data exports from the folders structure. I want to refactor the mock data using jest or another API mock suite to accomplish testing the handling of data via API calls without overtaxing the API limits.

June, 9 2021

Overview

Today was spent deciding on short-term solution to state management. The entire cohort had a QnA session and passed ideas around about different approaches.

The primary options are:

  • classful component at top level with state passed via props and API request on Component lifecycle methods
  • classful sub components handling their own state w/ API requests
  • redux (we opted not to pursue this)
  • React hooks (Some of our components are moving to this and we will refactor more in coming weeks)

Log

9:00pm - 10:30pm

Challenge/Motivation

Our main work was to get all PRs having to do with mock data and API requests merged so everyone can start passing state to their components.

Actions Taken

We decided on putting the mock data at the client level for now. If the route already exists in the server, then leave it, but we'll put an alternate server mock next week after MVP demo.

Results Observed

We are getting data into the components that are setup to handle it and have a unified source of truth for the current structure.

June 1, 2021

Overview

Trello ticket creation and Amazon s3 setup.

Log

11:00am - 1:30pm

Challenge/Motivation

I spent time making more detailed Trello tickets and drilled down into implementation level tasks

Actions Taken

I copied the spec into the about section of the tickets and imagined the scope of each aspect of the tickets to decide if I needed to break the task down into more implementation tickets.

Results Observed

I feel I have a better grasp on the scope of my widget and how the tasks are going to be broken down.

Log

5:00pm - 7:30pm

Challenge/Motivation

Investigate S3 storage and how to retrieve urls to send to Atelier API

Actions Taken

read S3 documentation and created a bucket. REST API endpoints are at s3-website-us-east-1.amazonaws.com with a bucket name "hr-nylon-eric-fec-bucket"

Results Observed

I setup an account and successfully uploaded an image to the s3 bucket.

June 21, 2021

Overview

Added Modal component for Review form S3 bucket multiple file upload

Log

5:00am - 7:30pm

Challenge/Motivation

Get S3 route working as well as temporary storage of uploaded files on the client.

Actions Taken

I got single files working but was searching for a good solution to multiple file upload. Found a clever solution using generated local URLs to keep reference and load photos into the preview window.

https://medium.com/@650egor/react-30-day-challenge-day-2-image-upload-preview-2d534f8eaaa

Results Observed

I got the files to upload to the state array in the component. The display still needs to be worked on and I'll have to create a component(s) to display and map the 1-5 photos for preview.

Log

9:00pm - 11:30pm

Challenge/Motivation

Finish basic Modal form for Review uploads.

Actions Taken

I borrowed the patterns from the stateful class-based modal in the Overview module. I had to copy some interesting click handlers and deal with how they will work nested in a new component.

Results Observed

The basic form is rendering and I understand how the visible/invisible state is handled at the tope ProductDetailPage level. It is important to pay close attention to "this" identity as props and event handlers are being passed from one class-based stateful component to another for this modal functionality.

June 23, 2021

Overview

Deploy all the things! http://frontendcapstone.com

Log

10:00om - 2:00am

Challenge/Motivation

Get repo onto AWS instance and connect through a persistant IP or domain name

Actions Taken

deploy! set up domain frontendcapstone.com w/ google domains (domains.google.com)

AWS

https://aws.amazon.com/ec2/getting-started/

set up security policy on AWS EC2 I started with everything open and then restricted to port 80 UDP/TCP traffic for incomming. I also openned ICMP traffic for pinging purposes as well as ssh port 22 for logging into server.

set up elastic IP so it will persist after reboot/termination. you have to associate it to the instance from the elastic IP tab

Linux/UNIX instance:

  • AMI name: amzn2-ami-hvm-2.0.20210617.0-x86_64-gp2

Logging in:

ssh from local: set permissions to pem file: chmod 400 hr-nylon-eric.pem

ssh -i hr-nylon-eric.pem ec2-user@ec2-35-172-51-196.compute-1.amazonaws.com

Then navigate to and create folder for project:

  • install git git clone https://github.com/Idakka/Project-Atelier.git

sudo yum install git

Setting up Node:

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

This is a special Node build for AWS instances. Don't use standard Yum/apt install. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

nvm install node

. ~/.nvm/nvm.sh

node -e "console.log('Running Node.js ' + process.version)"

npm install -g npx

router/ reverse proxy:

  • AWS version of nginx: sudo amazon-linux-extras install nginx1

sudo service nginx start

  • message: Redirecting to /bin/systemctl start nginx.service

cat /etc/nginx/sites-available/default

  • this didn't work and I had to go find the etc/nginx/nginx.conf file and edit it with nano: sudo nano /etc/nginx/nginx.conf

server { listen 80; server_name tutorial; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:3000; } }

  • Most of this config was filled out, Just needed to add the location block and change to port 1234 for our server

link config files

sudo service nginx restart

  • npm start in project folder, need ed to install nodemon

install webpack

npm install webpack

npm start

  • IT WORKS!!!

keep it running:

https://medium.com/hackernoon/tutorial-creating-and-managing-a-node-js-server-on-aws-part-2-5fbdea95f8a1#.mnlkymeti

npm i -g pm2

pm2 start tutorial/index.js

  • To make sure that your PM2 restarts when your server restarts pm2 startup
  • you will be given a custom string similar to this but specific to your machine, copy that: sudo env PATH=$PATH:/home/ec2-user/.nvm/versions/node/v16.4.0/bin /home/ec2-user/.nvm/versions/node/v16.4.0/lib/node_modules/pm2/bin/pm2 startup systemd -u ec2-user --hp /home/ec2-user

save config with everything running (no nginx at this point) pm2 save

pm2 start nodemon server/server.js

That’s it! You can log out/in to SSH, even restart your server and it will continue to run on port 80.

  • To list all processes use pm2 ls

nginx persistent:

systemctl start nginx systemctl enable nginx

having trouble restarting nginx on reboot, sudo systemctl enable nginx

  • is supposed to solve it. needed to start nginx/ make persistant and THEN redo the pm2 process above

Results Observed

I got the app deployed pretty quickly but had to troubleshoot making the node server and nginx reverse-proxy persist after reboot.

June 28, 2021

Overview

  • Review form validation
  • Fix state-change rendering bug
  • initial google page speed for optimizations

Log

1:00pm - 3:30pm

Challenge/Motivation

get inputs validated during entry.

Actions Taken

Found approaches and landed on html validation on inputs with validation functions called on upload.

Results Observed

The basic validation options were pretty simple and effective. The next step would be to do some conditional styling like red outlines and UI feedback when users enter disallowed text.

Log

9:00pm - 10:30pm

Challenge/Motivation

Solve issues with the form elements not re-rendering on state change. This was particularly noticeable with the radio button as the button was one change behind. I also noticed that console.log of the state in every case was behind the actual state.

Actions Taken

I researched several articles and found 2 important concepts:

  • React setState only creates a pending queue for state transitions.
  • You should remove the event.preventDefault() from the event handler to make state update immediately.

https://www.bennadel.com/blog/2893-setstate-state-mutation-operation-may-be-synchronous-in-reactjs.htm

Results Observed

Every change in radio button/ text field updates state and re-renders the form view. You can also pass a callback as a second argument to setState(state, () => {}); and perform operations after the async change.

1:00am - 3:30am

Challenge/Motivation

Get initial google page speed.

Actions Taken

Pulled down latest main branch on AWS deployment and built/transpiled newest changes. Results:

Results Observed

The results on desktop were middling at 73/100. Big issues are size of payload/bundle.js file as well as full size images being loaded. The results on mobile are worse at 23/100 especially because of the larger image sizes. We are working on using lazy loading as well as image compression to deal with these issues. It would also be good to limit image upload sizes and have a resolution conversion at the server for images that get uploaded via our routes to s3 storage.

, 2021

Overview

Log

11:00am - 3:30pm

Challenge/Motivation

Actions Taken

Results Observed

Log

5:00pm - 7:30pm

Challenge/Motivation

Actions Taken

Results Observed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment