DeveloperPlayBook
Python
Python
  • Introduction
  • Architecture
    • Technology Stack
    • ADR Records
  • Design
  • Bootstraping
  • Development Environment
    • Accounts (AWS, GCP, CircleCI)
  • Services/API
    • Serverless
    • Containers
    • Python
    • Firebase
    • Chatbots
    • Testing
  • Frontend
    • Serverless
    • Containers
    • Chatbot
  • Plattform
  • IAM - IAMaaS
  • Persistance - DBaaS
    • Serverless
    • Container
  • Event Driven / Streaming aaS
    • Kinesis
  • AI - AIaaS
  • Production / Reliability Engineering
  • create-k8s-secrets
  • VI
  • Tools
Powered by GitBook
On this page
  • Frontend
  • Development Process
  • Technology Stack
  • Rapid Prototyping
  • Build a mock?
  • Build an app with component based development
  • Make AJAX / REST Calls from the Frontend with axios
  • Dockerize a React App
  • Deploy the Frontend
  • Build Our App
  • Code Quality & Testing
  • Micro-Frontends How to integrate multiple Frontends into one (token in local storage?)?

Frontend

PreviousTestingNextServerless

Last updated 7 years ago

Frontend

After you defined the business functionality - expressed most clearly by the APIs of a domain - by creating your API mocks, you start building your UI.

Architectural Decisions

  1. *TODO: Create ADR* I stick with React up to the point that the others are at least on the same functional level: Native and Frontend.

Development Process

  1. Decide if you deploy the application serverless or use docker containers (vendor independent)

Technology Stack

  • Build Setup: ES6, webpack, babel, npm

  • Frontend Framework: React ( / ) - JSX, State, Life Cycle Methods

  • State Management: Redux + Redux Saga

  • Web/Desktop:

    • React with Create-React-App

    • CSS Framework - Bulma /

  • Web/Mobile:

    • CSS Framework - Bulma

  • Native:

    • React Native

Rapid Prototyping

To get feedback fast create a first prototype:

Define Application Structure (Paper? + Photo or Balsamiq + screenshot from rolemodels):

Build a mock?

Build an app with component based development

Create sampleapp-client

create-react-app sampleapp-client
cd sampleapp-client

Setup Project Structure

src
 ├── components
 │
 ├── containers
 │  ├── auth.js
 │  ├── productList.js
 │  └── productDetail.js
 │
 ├── reducers (aka ducks)
 │  ├── index.js (combineReducers + complex selectors)
 │  ├── auth.js (reducers, action types, actions creators, selectors)
 │  └── product.js (reducers, action types, actions creators, selectors)
 │
 ├── sagas
 │  ├── index.js (root saga/table of content of all the sagas)
 │  ├── auth.js
 │  └── product.js
 │
 └── services
    ├── authenticationService.js
    └── productsApi.js

Create Router and setup basic Application structure

Install: npm i react-router-dom

Create Placeholder Components/Containers:

Setup CSS Framework for Styling

Install storybook.js and configure it

npm i --save-dev @storybook/react

Further Setup:

Create Container/Componente LoginPage (might be a container in the future):

/src/container/LoginPage

in its own folder in this folder you then find the LoginPage.js file, .css , pictures (.svg) and the story LoginPage-story.js

Example how IBM is doing it:

Developer Components in Stylebook:

Run Storybook: npm run storybook

  • Using ReactRouter with history:

    • use withRouter on at least App and otherwise use a manual history object

  • Frontend Tracking with Google Analytics:

Make AJAX / REST Calls from the Frontend with axios

Dockerize a React App

Deploy the Frontend

  1. Upload the assets of our app

  2. Use a CDN to serve out our assets

  3. Point our domain to the CDN distribution

  4. Switch to HTTPS with a SSL certificate

Create the Bucket

Select Create Bucketand pick a name for your application and select the US East (N. Virginia) Region Region. Since our application is being served out using a CDN, the region should not matter to us.

Now click on your newly created bucket from the list and navigate to its permissions panel by clicking Permissions.

{
  "Version":"2012-10-17",
  "Statement":[{
    "Sid":"PublicReadForGetBucketObjects",
        "Effect":"Allow",
      "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::developerportal-client/*"]
    }
  ]
}

Now select Use this bucket to host a website and add ourindex.htmlas the Index Document and the Error Document. Since we are letting React handle 404s, we can simply redirect our errors to ourindex.htmlas well. Hit Save once you are done.

This panel also shows us where our app will be accessible. AWS assigns us a URL for our static website. In this case the URL assigned to me is http://developerportal-client.s3-website.eu-central-1.amazonaws.com.

Build Our App

Create React App comes with a convenient way to package and prepare our app for deployment. From our working directory simply run the following command.

npm run build

This packages all of our assets and places them in thebuild/directory.

Upload to S3

Now to deploy simply run the following command; whereYOUR_S3_DEPLOY_BUCKET_NAMEis the name of the S3 Bucket we created before.

aws s3 sync build/ s3://YOUR_S3_DEPLOY_BUCKET_NAME 
// aws s3 sync build/ s3://developerportal-client

Code Quality & Testing

  • unit testing framework

  • component based testing frameworks

how to build this into the build pipeline?

Micro-Frontends How to integrate multiple Frontends into one (token in local storage?)?

  • Code splitting to multiple pages in react:

  • single-spa:

Design:

LandingPage (login or not)2. Personal Service Page (only logged in)

Theory:

Link: /

Setup Routers:

I currently use / and :

Include link to css in index.html or (recomended)

Basic Setup:

Configure Storybook []

Component

Config:

Storybook:

Webpack config (to use):

How to use in project:

Sample:

AWS provides quite a few services that can help us do the above. We are going to use to host our assets, to serve it, to manage our domain, and to handle our SSL certificate.

First, log in to yourand select S3 from the list of services.

All this command does is that it syncs thebuild/directory with our bucket on S3. Just as a sanity check, go into the S3 section in your and check if your bucket has the files we just uploaded.

Authenticated Session with the SSO / Login page and inquiry without user interaction:

Serverside Rendering:

AWS Amplify:

Create new Component Mock and Create new StoryBook (e.g. copying the one of the old component):

Implement new component logic

I use a basic css framework Bulma, because more powerful frameworks cost to much time understanding without understanding the basics.
Design and Develop API Mock
Understand the tech stack
Rapid Prototyping
Build an app with component based development
Dockerize a react application
ecosystem overview
course
blueprintjs
https://moqups.com/pricing/sign-up?p=Ewy0d
https://projects.invisionapp.com/d/signup
https://hackernoon.com/my-journey-toward-a-maintainable-project-structure-for-react-redux-b05dfd999b5
Code on github
https://github.com/ReactTraining/react-router
https://reacttraining.com/react-router/web/guides/quick-start
Code on github
Code on github
Bulma
BulmaThemes
FontAwesome
use npm
Code on github
Tutorial on using Bulma
Example how to use Bulma
https://storybook.js.org/basics/guide-react/
Code
what are action, decorators ...
with bulma.io
customize SASS
https://github.com/carbon-design-system/carbon-components-react/tree/master/src/components/Accordion
https://github.com/carbon-design-system/carbon-components-react/blob/master/.storybook/config.js
http://react.carbondesignsystem.com/?selectedKind=Accordion&selectedStory=Default&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel
https://github.com/carbon-design-system/carbon-components-react/blob/master/.storybook/webpack.config.js
https://github.com/carbon-design-system/carbon-components-react#usage
https://github.com/kadira-samples/react-storybook-demo/blob/master/components/stories/MainSection.js
Code on github
https://stackoverflow.com/questions/42701129/how-to-push-to-history-in-react-router-v4
https://reacttraining.com/react-router/web/guides/redux-integration
https://github.com/ReactTraining/react-router/blob/master/FAQ.md#how-do-i-access-the-history-object-outside-of-components
https://stackoverflow.com/questions/43279135/reactjs-router-v4-history-push-not-working/43280171
https://github.com/ReactTraining/react-router/issues/4924
https://reacttraining.com/react-router/web/example/auth-workflow
https://github.com/react-ga/react-ga
https://web-design-weekly.com/2016/07/08/adding-google-analytics-react-application/
https://medium.com/codingthesmartway-com-blog/getting-started-with-axios-166cb0035237
http://mherman.org/blog/2017/12/07/dockerizing-a-react-app/
https://www.peterbe.com/plog/how-to-create-react-app-with-docker
S3
CloudFront
Route 53
Certificate Manager
AWS Console
https://medium.com/@eliotjunior/prettier-eslint-facebook-code-quality-the-auto-magical-react-styling-tutorial-19481acb10dd
https://medium.com/@tomsoderlund/micro-frontends-a-microservice-approach-to-front-end-web-development-f325ebdadc16
https://community.auth0.com/questions/7605/sharing-authentication-between-2-sites
https://blog.logrocket.com/quick-guide-to-webpack-bundle-and-code-splitting-with-react-43d1045f1064
https://stackoverflow.com/questions/39314251/reactjs-how-to-have-multiple-spas-on-the-same-website
https://medium.com/canopy-tax/a-step-by-step-guide-to-single-spa-abbbcb1bedc6
https://www.thoughtworks.com/de/radar/languages-and-frameworks/single-spa
https://github.com/CanopyTax/single-spa
https://github.com/phodal/serverless-react-server-side-render/blob/master/src/index.js
https://github.com/d0ruk/serverless-notes-app/tree/master/client
https://github.com/denseidel/spa-starter/commit/94d64cbfa949108977a159ccf4ad409fd0c317ea
https://github.com/denseidel/spa-starter/commit/726cd1e16be73186ea535e5ac1129e3aee16206c
https://medium.com/refactoring-ui/7-practical-tips-for-cheating-at-design-40c736799886
AWS Console