Software Architecture: Digipus Application

Samuel Dimas
3 min readMay 14, 2020

--

This week’s article will be more technical, and I would like to discuss how is the software architecture of my group’s project, Digipus. But before we talk about the implementation itself, let us talk shortly why does software architecture is so important in a software development process.

Introduction

Designing a software architecture is done by structuring an application to fit all the requirements needed in a technical and business point of view. By designing software architecture, we can also optimize its performances as everything is well structured and it obviously minimizes the unneeded actions in our software.

I will discuss more on how does our team uses Docker Swarm as an orchestration tool, but an overview of the web framework (Django) and the database (PostgreSQL) is needed as the usage of Docker Swarm itself is based on that tools we used.

Django and PostgreSQL

Django and PostgreSQL architecture

We implemented Django as our web framework stack, as it serves as a full-stack framework, so it eases us to manage our application and the architecture is not that complicated. With the standard MVT (Models, Views, Template) design pattern on our application, each HTTP request from a client will be processed by urls.py and will call an associated function from views.py. Views.py will then call models.py if a GET or POST request to the database is needed. A database context will then be returned to the views.py and rendered to an HTML file to be finally returned as an HTTP response. We modified the database from a predefined dbsqlite3 to PostgreSQL as it’s free to use, the usage (especially some syntax) is a whole lot easier to use, as we use it too in the Database course project.

Docker Orchestration

docker.com

A docker orchestration, or commonly known as container orchestration (well because Docker is one of the container types) is to automate the managing process of containers, here in Digipus project it will be so important as two different tech stacks (Django and PostgreSQL) so it can work well together. Digipus project uses Docker Swarm as it’s orchestration tool, as the documentation to compose Django and PostgreSQL is “quite” defined in the Docker documentation.

Docker Orchestration: Implementation

The implementation is very straightforward actually, by defining a Dockerfile as a Python dependencies requirement, and a .yml file (conventionally named docker-compose.yml) as a script to be run on the virtual OS.

Dockerfile
docker-compose.yml

Some of the Django files needed modification so it could work well with Docker Swarm, so we head to settings.py and modify the SECRET_KEY, DEBUG, and DATABASE default values so the virtual OS could create its own variables, well we at the development process needed to create an environment variables file so it could work well too.

settings.py
settings.py (2)
.env

Finally, we compose our application using the command

docker-compose up -d --build

to build and up our application to the virtual OS, and

docker-compose exec web python manage.py migrate — noinput

to run the migrations, and we’re done.

--

--