DEV Community

Cover image for Building a 3-Tier Application on AWS
Ijay
Ijay

Posted on

Building a 3-Tier Application on AWS

When I hear the word "3-tier architecture," it sounds like one of those big concepts people often mention in all these tech talks. Most times, I just add it to my list of things to read later.
But something interesting happened when I started looking into it more closely.
I realized that 3-tier architecture is actually something many of us already interact with, especially when using Backend as a Service platforms.
Sometimes a concept becomes clearer when someone explains it in a simple way. After attending a session from Solavise Technologies Institute, the idea stopped feeling abstract.

Instead of only reading about it, I decided to build something small to understand how it actually works.

With their guidance, I built a Nigerian passport application system deployed using a 3-tier architecture on AWS.

Architecture Diagram

Below is a simple overview of how the system is structured.

                User
                 |
                 |  HTTP Request
                 v
        -----------------------
        Presentation Layer
        EC2 Instance
        Nginx Web Server
        (HTML, CSS, JS)
        -----------------------
                 |
                 |  POST Request
                 v
        -----------------------
        Logic Layer
        EC2 Instance
        Flask API
        (Application Logic)
        -----------------------
                 |
                 |  SQL Query
                 v
        -----------------------
        Data Layer
        Amazon RDS
        MariaDB Database
        -----------------------
Enter fullscreen mode Exit fullscreen mode

A 3-tier architecture simply means an application separated into three different layers:

1. Presentation Layer

This is the frontend of an application. It is what users see and interact with.

2. Logic Layer

This is the backend. It processes requests and handles the application logic.

3. Data Layer

This is where the data is stored. It can be a database hosted by a cloud provider or any other database system.

The Idea Behind the Project

The goal was not to build a complex application but to understand how real systems work across layers.

Imagine a simple website where someone fills out a passport application form.

When a user submits the form, a few things need to happen.

  • The application receives the request.
  • The system processes the data.
  • The information is stored in a database.

Instead of putting everything on one server, the system splits these responsibilities across different layers.

This separation is what defines a 3-tier architecture.

Breaking Down the Architecture

1. Presentation Layer: The first layer of the architecture is the presentation layer. It is the part users interact with.

For this project, the frontend consists of a simple form, which I built with:

  • HTML
  • CSS
  • JavaScript

The frontend runs on an EC2 instance configured with Nginx.

Its responsibility is straightforward. It collects user input from the passport form and sends the data to the backend.

2. Logic Layer: The second layer of the architecture is the logic layer. This layer processes the requests coming from the frontend.

In this project, the logic layer runs on a separate EC2 instance running a Flask API.

When the frontend sends a request, the Flask application receives the form data, processes it, and prepares it to be stored in the database.

3. Data Layer: The final layer is the data layer. This layer is responsible for storing and managing the application data.

For this project, I used Amazon RDS with MariaDB to store the passport application records.

Whenever the backend receives a valid request, it inserts the data into the RDS database.

How the System Works

Once all three layers are in place, the interaction between them follows a simple flow.

  • A user opens the website and fills out the passport form.

  • The frontend sends the form data to the Flask API.

  • The backend processes the request and stores the information in Amazon RDS.

Each layer performs a specific task, which keeps the system organized and easier to manage.

What was the Challenge?

At one point during the project, everything seemed ready.

  • The servers were running.
  • The code looked correct.
  • The database was configured. But the form refused to work.

After troubleshooting for hours, I realised the issue had nothing to do with the application code.

The problem was coming from the network configuration.

The backend server was not reachable because the security group did not allow traffic on the required port.

Once I corrected the security group configuration and fixed the API endpoint, communication between the 3 layers started working immediately.

What This Project Helped Me Understand

Before building this project, a 3-tier architecture felt like a theoretical concept:

  • Now it feels much more practical.
  • Makes the applications easier to maintain, scale, and troubleshoot.

Project Repository

passport application

The full project code is available here:

In summary

  • The frontend focuses on user interaction.
  • The backend handles the application logic.
  • The database stores and manages the data.

If you found this documentation helpful, share it with others who may find it interesting.


Other Helpful Resources


Stay updated with my projects by following me on Twitter, LinkedIn, and GitHub.

Thank you for reading

Top comments (0)