DEV Community

Vinicio Ochoa
Vinicio Ochoa

Posted on • Edited on

Building a Basic Web Architecture

Design the architecture

When a team or person will want to create a general architecture, always try to generalize to five layers and tries to answers the questions:

  • Access to Data:

How do I consume and persist the information?
What kind of database do I should use?

  • Business Logic

How do I ensure an atomic transaction without loss of data?

  • Service Layer

What kind of protocol do I should use for publishing my services?

  • Presentation Layer

Do I need a mobile, desktop, or web application?
What framework or library do I should use?

  • Security Layer

What security mechanism do I should use?

Answer the Questions

To answer the questions you have to analyze the story to implement at his company, for example:
The ACME Corporation needs to manage its inventory with a web system and needs to access it a cell phone. The system has to ensure that doesn't lose the information. The company has a PostgresSQL database for other systems.

What do you think is the best solution to the problem? Let's try to analyze the problem based on the questions proposed in the previous section.

Data Layer:

Question Answer Observation
Do you need save the inventory information? YES
Do you need to ensure the atomicity in the information? YES It’s a transactional system
Does the company manage any databases? YES The company manages a relational database. Is there any relational database? Yes, PostgresSQL Is there any NoSQL database? No, there isn't any database
If the company does not have any database, what database would you recommend to the company? Why? Based on the questions above, I recommend a relational database to manage inventory data and a NoSQL database for the logging events, because, there is a minor probability of the lost data than in the NoSQL database.

Business Layer:

Question Answer Observation
Does the database manage transactionality? YES
Does the system need to support stateless and stateful transactions? YES The system can be managed in stateless or stateful transactions.

Service Layer:

Question Answer Observation
Does the system need any web service? YES The inventory system needs to access in a cell phone
What kind of web service protocol do you need? YES The mobile applications work fine with a lightweight protocol, hence I going to use RESTful Web Service.

Presentation Layer:

Question Answer Observation
Do I need a mobile, desktop, or web application? YES The inventory system needs to access a cell phone and a web app.
What framework or library do I should use? The resources need to manage in the front end to try to save the server resources. There are many JavaScript libraries, for example, Vuejs, angular, react, etc. The service layer will help to manage the web services to interact with JavaScript libraries

Security Layer:

Question Answer Observation
Does the system needs security? YES The inventory system needs to ensure the security to prevent unauthorized access to private resources
What security mechanism do I should use? There are many security mechanisms, for example, OAuth, JWT, User, and password. It will depend on the strategies and the criticality of the system. I think the intermediate strategy is JWT for web service security and mobile security, I recommend OAUTH, because many users use a third account credential, for example, Google.

Conclusion

A basic architecture implicates many things, many frameworks, many programming languages in other cases, you will need batch applications to run scheduled processes.

The necessity of the final user is the most important thing to architecture an application because should ensure hight flexibility to low cost and it is complex. I recommended understanding the business logic before designing any system.

I hope the article has been helping you and if you believe that I forget anything, please comment and I will put it in the article.

Regards everybody,

Vinicio

Top comments (0)