Design Layered Architecture for E-Commerce Applications with Step by Step
In this article, we are going to learn how to design E-Commerce Applications with Layered Architecture and Step by Step.

Designing an e-commerce application using Layered 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 Layered Architectures that you can check articles below:
- Layered (N-Layer) Architecture with SOLID Design Principles
- Software Architecture Principles: KISS, YAGNI, DRY
- Software Architecture Design Principles: SoC, SOLID
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.
- Maintainability
and also in this for this section, I have added to “Maintainability” which required for the organizing project codes properly.
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 using Monolithic architecture style but also we will use Layered (N-Layer) architecture in our design.
As you know that, Layered Architecture also still following Monolithic architecture in terms of server design perspective so we can say that Layered Architecture is a sub-architecture style of Monolithic architecture.
Because we will still have big application server, we won’t decompose servers now, instead we will separate logical layers into our 1 big application server in order to organize our projects better.
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
And also we have learned and added below principles for this chapter;
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 Layered architecture.
Design: Layered Monolithic Architecture Steps
Here you can see the our monolithic architecture evolution. You can see that we have start very basic of architecture with putting only 1 application server and manage all business logic inside of that. After that we will separate client application and continue to apply layered architecture with separating logical layers for UI, Business Logic and Data Access layers. Also we can separate additional logical layers like adding Domain layer and separating Application and Business Layers one more step.

Design Layered Architecture — E-Commerce App
Here you can see the final architecture design for our e-commerce application which is applying Layered architecture.

Let me explain flow of request in our architecture:
- Client will be send request from web, and this request accommodate from our big monolithic application server but our project organized by layered architecture which every layers concerns their own responsibilities and perform database calls in order to persist data on relational database.
So for now this is one of the best architecture for us because if this architecture handle our requirements with FR and N-NR, there is no need to design more complex one.
Adapt Technology Stack — E-Commerce App — Layered Architecture
We will implement possible Technology choices. As you know that we have designed our architecture with applying Layered Architecture and Design principles which is SOLID and SoC principles.
You can see image of “Way of Learning — The Design Flow” of our articles: According to Flow, now its time to Adapting Technology Chooses.

In this step we will Apply Software Tools, Application Frameworks and Databases for our current design. So, I have created 2 different Technology stack, one for Java another for Microsoft .Net ecosystem:

As you can see the image, for Java Technology stack. I have added Tomcat Web Server to deploy our monolithic application into this. And Developing our application with Java Enterprise Edition and created 1 big jar or war file to deploy to our Tomcat web server Application , Java Single WAR Artifact and Tomcat Container. And perform database operations with relational database which is MySQL, or you can pick PostgreSQL or Oracle in here. If we look at the Microsoft .Net ecosystem: tools changed a bit: We use IIS for Web Server for .Net applications. We use Asp.Net as an application framework when developing our layered architecture and we use SQL Server as a relational database for performing database crud operations.
As you can see that we have design and adapt with technology stack for our e-commerce application.
DEMO: Layered Monolithic Architecture Code Review — E-Commerce App
We are going to code review of e-commerce application which is implemented with .net ecosystem and asp.net and use SQL server for relational databases. This is Asp.Net e-commerce web application I have developed this repository a long time ago but it is still relevant for our topic.
Here you can see 2 GitHub link at below. In the first link we go to GitHub repository page: Code review of Asp.Net e-commerce web application:
- https://github.com/aspnetrun/run-aspnetcore-basics
- https://github1s.com/aspnetrun/run-aspnetcore-basics
Please goto links and examine Readme file. With Second link you can open repository as a project folder view. This is implementation of aspnetrun-basic template on real-world basic e-commerce web application project; You can see the animation we have developed for all FR of our e-commerce application like listing products, add to basket, checkout order and so on.
The idea of this project one project for fastest idea implementations to building modern web applications with latest ASP.NET Core & EF Core technologies. So this is the reason why monolithic architecture still valid in software industry. See Layers:
Data Folder: Includes Entity Framework Core Context and tables in this folder. When new entity created, it should add to context and configure in context. The Infrastructure project depends on Microsoft.EntityFrameworkCore.SqlServer and EF.Core related nuget packages, you can check nuget packages of Infrastructure layer. If you want to change your data access layer, it can easily be replaced with a lighter-weight ORM like Dapper.
Repository Folder: Implementation of Core interfaces in this project with Entity Framework Core and other dependencies. Most of your application’s dependence on external resources should be implemented in classes defined in the Infrastructure project. These classes must implement the interfaces defined in Core. If you have a very large project with many dependencies, it may make sense to have more than one Infrastructure project (eg Infrastructure.Data), but in most projects one Infrastructure project that contains folders works well.
Pages UI Folder: Development of UI Logic with implementation. Interfaces drives business requirements and implementations in this layer. The application’s main starting point is the ASP.NET Core web project. This is a classical console application, with a public static void Main method in Program.cs.
Evaluate: Layered Monolithic Architecture
If we evaluate the current Layered Architecture for E-Commerce Application, you can see the Benefits and Drawbacks at below :

That means, even we have separate logical layers, it has lots of Drawbacks.
Problem: Highly Coupling Dependent Layers
We are going to discover Problems of current Layered 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:

If you look at the design image, you can see that UI directly dependent to Business layer, Business Layer dependent Data Access Layer. We should broke these dependencies and organize the code with loosely coupling services and provide flexibility of our codebase with shifting different frameworks. And the solutions are
- Clean Architecture
- The Dependency Rule
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 ?
- Clean Architecture Design with Dependency Rule
- 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.






