Design Monolithic Architecture for E-Commerce Applications with Step by Step
In this article, we are going to learn how to design E-Commerce Applications with Monolithic Architecture and Step by Step.
Designing an e-commerce application using Monolithic architecture can be a complex task. We will iterate the architecture design one by one as per requirements. But before designing E-Commerce application, We should ask ourselves: What we have in our design toolbox ?
I have just published a new course — Design Microservices Architecture with Patterns & Principles.
Architecture Design Flow
Before we design any architecture we will always start from Problem which is Business Problem that drive our design considerations.
After that, we have learned Architecture Design Patterns and Principles about Monolithic Architectures that you can check articles below:
- Monolithic Architecture is Shining
- When to use Monolithic Architecture
- Benefits and Challenges of Monolithic Architecture
- Software Architecture Principles: KISS, YAGNI, DRY
So now, according to our Architecture Design flow at above, We are at Design step. But before design our system We should ask ourselves:
- What we have in our design toolbox ? What we have learned so far ?
So that means, every time when we design our architecture, We should always start with writing down FRs and NFRs. Also its good to write-down Constraints or Limitations of project, for example cost, time and so on.
Architecture Design Toolbox
Here you can see the Architecture Design Toolbox that we will use during the article when designing our E-Commerce application:
Functional Requirements — FRs
Basically we are going to design simple e-commerce application and we need to write down business cases that means write down Functional-requirements:
- List products
- Filter products as per brand and categories
- Put products into the shopping cart
- Apply coupon for discounts and see the total cost all for all of the items in shopping cart
- Checkout the shopping cart and create an order
- List my old orders and order items history
Non-Functional Requirements — N-FRs
After getting requirements, as a Software Architect, we should consider Non-Functional Requirements. Since this is the first iteration of our e-commerce application, we don’t aim to super scalability and handle millions of request. Instead we will start with small and basics thats why I have added to
- Availability
- Small number of concurrent users that we should handle in the first design.
Architecture Styles
After understanding Functional and Non-Functional requirements, now we can see our Design toolbox which includes Architectures, Patterns, Principles and Best Practices that we have learned and will apply on our project. Lets see which architecture styles that we have learned of course we have only 1 architecture style now which is Monolithic Architectures.
Patterns & Principles
Its good to add principles in our picture in order to remember them always. And If we expand our Patterns & Principles, we can see that
- DRY
- KISS
- YAGNI
We are going to consider these principles when design our architecture. So for now we have learned only these items and load our design toolbox with these items. But with continue our course we will discover new architectures, patterns and principles.
According to our design toolbox, now lets design the first version of our e-commerce application with using Monolithic architecture.
Design: First version of Monolithic Architecture
Here you can see the our architecture.
Its not so fancy right ? We have learned so many things so why we put only 1 box here ?
Because, this is our first design according to Patterns & Principles. And this is one of the best architecture for us because if this architecture handle our requirements with FR and N-FR, there is no need to design more complex one.
That means, we have followed KISS and YAGNI principles in here. And refactor our design as per requirements and step by step iterate together. Lets start to iterate this architecture together according to FRs.
Design & Iterate : Monolithic Architecture — E-Commerce Application
We are going to iterate current design of e-commerce application with the monolithic architecture step by step. We will iterate the architecture design one by one as per requirements.
Now we can refactor our design as per Functional Requirements. Lets remember again or FRs with looking our Design Toolbox. If we look at the FRs, understand that we need to store catalog, shopping cart and order in database.
So lets add database into our current design.
Now we need database and add database into our architecture in order to store our data with persistence manner.
According to this design: Whole application the same server and same code base both front and backend. And we only add database and database is separated from our application server. After that, we can at least separate client and backend server.
This monolithic application has a massive codebase that includes all modules. If you introduce new modules to this application, you have to make changes to the existing code and then deploy the artifact with a different code to the Tomcat server.
Again we followed our KISS principle that is keep it simple. And refactor our design as per requirements and step by step iterate together.
Evaluate : Monolithic Architecture — E-Commerce App
If we evaluate the current Monolithic Architecture for E-Commerce Application, you can see the Benefits and Drawbacks at below :
Problem: Code Become Too Complex Over Time
We are going to discover Problems of current Monolithic Architecture — E-Commerce Application. So when we are in discover Problem step,
we should ask ourselves
- What's wrong with this current architecture ?
- How can we improve the current design when project goes more advanced level ?
Here you can see Problems and potential solutions of current design:
Design & Iterate : Monolithic Architecture — E-Commerce Application
If we design & iterate e-commerce application with Layered Monolithic architecture, we can reach the architecture in the image below:
There is a big single Monolithic Application Server and one big relational databases, but at least we have applied layered architecture style and scale the application server.
Design Microservice Architecture — E-Commerce App
If we design e-commerce application with Microservice architecture, you can see the image below:
Product microservice can use NoSQL document database Shopping Cart microservice can use NoSQL key-value pair database and Order microservice can use Relational database as per microservice data storage requirements.
What’s Next ?
- Macro-services to Nano-services: Evolution of Software Architecture
- Microservices Architecture: Problems and Solutions with Pattern and Principles
Step by Step Design Architectures w/ Course
I have just published a new course — Design Microservices Architecture with Patterns & Principles.
In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.