Skip to content

System Arcitecture

Stein Korsveien edited this page Feb 20, 2023 · 48 revisions

Buisness Goals

Thoruput

A capability of bugfix should be implemnnetd in 1 week

Quality

Only 3 of 10 implemented capability must be changed in later iterations

No showstoppers in production

Requirments

Reliablity

As a Developer I want that only 1 of 10 commits brake the build so that As a Developer I wan that on avarage of 10 broken build it should take 15 minute before sucessfull build so that As a Developer I want that when I commit source code the deployment fails only on 2 of 10 times so that

As a Developer I want that that 70% code coverage of the unit and integration tests so that

Security

As A Developer I want that only the frontend component should be allowd access to the backend component trough API so thatr¨

As a Developer I want that only my account and the service account should have access to manage Google Cloud Project Resources so that

Maintainability

As a developer I want that it should take 8 hours to get a deploy the todo system to a new enviroment so that

As a developer I want that it should take 8 hours from staring development of a software capability until it is relased to production so that so that

As a Developer i want to observer the state of software product during execution so that bugs is fixed in short time

Performance

As a Developer I want that the time from I click on a button until action is don to be 3 sek when 20 users uses the system so that user is satisfied.

As a Developer I want that when I commit the code change should the changes be possible to use with a acceptabe quality in 10 minutes so that

As a Developer I want that the todo development enviroment should be ready for development within 1 hour on a Mach Prod that only contains MacOS so that

Usability

Operability

As a Developer I want that anyone should be able to run the automated test on their own machine or on test enviroment so that

As a Developer I want that anyone should be able to build and deploy their changed code in to test and production enviroment so that As a Developer I want the anyone should be able to commit their code changes and build the sofware product so that

Functionality

Comlpiance

As a User I want to add a todo activity so that

Security

As a Developer I want that only approved clients should have access to servere so that

Suiteability

As a user I want to be effective in handling mye activites so that

Principles

The Twelve-Factor App Principles

The system archicture should follow the twelve factor app descriebe in «The Twelve-Factor App Adam Wiggins»

Utdrag fra: Adam Wiggins. «The Twelve-Factor App.» Apple Books.

Code Base

The code base is stored in the Github repositoris . The sotfware product that is build in Travis from the code base is deployd to the test and proudction enviroment on Google Cloud App Engine. Before commit the source code is run on MacBook developer machine.

Dependnecies

The third party libaray is declared explisiet the frontend Javascript with the use of npm and declare the dependencie in package.json the backend Java with use of gradle and declare the dependencies in build.gradle

Config

Store Configuration in the enviroment All the configuraton files is stored in GitHub repository. The configuraion is stored as envroment variables in files that are read by the javacript component dotenv . Wich configuraion file to use is decided by NODE_ENV in commands in package.json

The service account key encrtpted before it is stored.

Build, Relase ,Run

The source code is build in a buid job Travis. The config file is combined with the build and deployd to the test enviroent

Prosesses

The application is deployd as 2 services the frontend and backend. These serveice are intansiated as sepearted prosesse.

Show the front end code

General Principles

Build the quality in to the software product

Deliver increments to production often

Always know the quality of the software product

Desing as simple as posible. No extra complexity. You ain´t gonna need it (YAGIN)

Automate as much as possible of the software development process

Keep the technical debt low

Deliver buissness value frequenluy before cloud vendor portability

Only one item pr team member as Work In Progress

Small Batches goal delver a item in 4h

Trunck based delivery only one branch pr team member goal to integrate into main barnch in 4 h

All product artifacts should be under version controll

Application and Infrastucture is concurrenly developed and tested.

All artifacts has shared ownership

Patterns

Model View Controller

Portability

Poseebility to use different View

Installability

 Automation of cration of google cloud project with Ansible
 Automation of deployment of docker components with Travis
Adaptability
Replaceability
Coexistence

Maintainabilit

Analysability

 Seperation of responsibility make code easier to understand
  
 Follow a code standard make code easier to udererstand
 Uses : 
  Eslint for Javascript
 Checkstyle and PDM for Java

  Arcitecure Adherance
  Uses Doxgeg and Evolotonary Archecture stadard to adhernace archictacture this make arcitecture easier to understand

 Exutable Speisifation k

Changeability

Stability

Testability

Easyer to test buisess logic trouh a api (servive) than to gui uses cypress to test API

Template View React Pages

Page Controller

The basic responsibilities of a Page Controller are: Decode the URL and extract any form data to figure out all the data for the action. Create and invoke any model objects to process the data. All relevant data from the HTML request should be passed to the model so that the model objects don't need any connection to the HTML request. Determine which view should display the result page and forward the model information to it. @Controller @Request Mapping

Model @Serveice

Dependncy Injection (Inversion of Control)

@SpringBootApplication

@Bean @Controller @Service

@SpringBootTest

Maintainability

Testability

Dependency injection should make your code less dependent on the container than it would be with traditional Java EE development

Layers

Client/Server

Structure

Implementaion Structure

Distibution Structure

Pipelines

Tooling Structure

Tooling

Development

Testing

Continuose Integraion

 Autoation reduce errors and integration time

Deployment

Automated Deploymnet reduce errors and deployment time

Clasess

Technology

Java Junit 5 Spring Boot Spring Boot Test Gradle Javadoc Jacco Mockito APITesttool

Javascipt React Jest Cypress Cucumber React Test Libary React Mock Eslint npm

Gitlab SonarCloud Google Cloud Appengin Docker Ansible Pulium AWS Git Github

#Test Strategy

React

Functional Unit Testing

The testing of the React Components is exeuted by use of Jest and Enzyme An example on a test are:

Functial Integraion Testing

The testing of fuctionality the need more than one react compnent is exuted by Rest

Functional System Test

The fucntion of the system is test with Cypress, Cucumber and Seleniun

Java

Web Layer

Functional Unit Test

The functional unit tets is done with Junit 5 and @WebMvcTest. A exmple on this teste is testing Hellow World Controller

@RestController public class HelloWorldController{ HelloWorldController() {} @CrossOrigin(origins = "*" ) @RequestMapping(method= RequestMethod.GET,path="/hello-world") public String helloWorld() { return "Hello World"; }

The test for this class look like this @WebMvcTest(HelloWorldController.class) public class HelloWorldAPITest {

`@Autowired`
`private MockMvc mvc;`


  

   `@Test`
    `public void shouldReciveHelloWorld() throws Exception {`
	 `this.mvc.perform(get("/hello-world"))`
	 `.andExpect(status().isOk())`
	 `.andExpect(content().contentType("text/plain; charset=UTF-8"))`
     `.andExpect(content().string(containsString("Hello World")));`
    `}`

AWS Infrastructure

Developing

Provison and testing AWS infrastructure is done by use of Typescript, Pulumi and AWS API on AWS cloud. Least Privilige and zero trust security

Pulumi

Testing

Low Level Testing

Unit testing of the code

Pulumi unit test Jest Pulumi Mocking to make the files indepenable tesable Secuity Testing What access to resources has the tested resource.

Low Level tesing of runing resource

Use of AWS api and jest to test idividual resources

Static Test

Eslint on coded

Synax check

Javasript syncax check

Middel Level Testing

Testing each tire indviually Examle: serverless arcitecture Test the database ture, the lamda function tire, the API getway tire and the web tire. The web tire can be isolated by using web mock The API gate way can be isolate by **** The function can be isolate by using memory database Use AWS API and Jest

Top Level

Tesing of a service wher all the tire is deployed and connected. Examle Hello World servirce Testing Tools are Cypress, Cucumber, Eslint

Monitoring

Datadog

CI/CD Pipline

Tests

Application

Infrastructure

Fitnessfunction

Technicl Debth

References

https://12factor.net/config