paint-brush
Part One: An open-source python REST API (Tribal) using Django framework by@strivecode
311 reads
311 reads

Part One: An open-source python REST API (Tribal) using Django framework

by Abdul-Razak AlhassanMarch 3rd, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Tribal is an API of all the tribes of the world, from tribes with millions of members to the smallest. We will use Django and Postgresql to build the entire API. Django is arguably the most powerful Python web framework used by mega-tech companies to build enterprise-grade and data-intensive web applications.
featured image - Part One: An open-source python REST  API (Tribal) using Django framework
Abdul-Razak Alhassan HackerNoon profile picture

Introduction

Every library or framework intends to address the challenges of existing tools or express a different philosophy in application architecture to achieve a better developer experience or improve the speed and performance of web applications. But the real reason for the countless libraries and frameworks out there is to make application development faster and more secure because of the ever involving industry needs and market entry challenges.


Thankfully, the flexibility of languages like Python has made it possible for programmers to build industry-ready frameworks to achieve early market entry without compromising security, flexibility, extensibility and versatility. Python is the most popular programming language and has enjoyed many engineering contributions making it the preferred solution for web, scientific, and data science computations.


There are several web frameworks built with python. Examples of these frameworks are Flask, Django, FastAPI and numerous others. Any of these frameworks is a powerful data-driven and concurrent web application development interface. But we shall focus on the Django framework. The focus of this tutorial is to take anyone with beginner-level skills to advance web API development using Django.


Because Django is a web framework, we shall not waste precious time trying to build the database and its table in raw PostgreSQL. The framework has the tools to help us program our project from beginning to end without dealing directly with the database design process. We shall examine every library used along the way. I must indicate that we can not use all the features of the Django framework in this tutorial, but we shall exhaust the most common ones.

Nature of the project

Before we delve into Django and web API programming, let us understand the nature of the project we shall program. In this series of tutorials, we shall build an open-source API known as TRIBAL starting from the development planning to a complete and hosted API. Tribal is an API of all the tribes of the world, from tribes with millions of members to the smallest.


The API will capture information about each tribe’s name, population, and GPS locations of their lands to specific information such as magic and mythological systems and beliefs. We will cover the details of the various tables of our database at the appropriate stages of development. We will use Django and Postgresql to build the entire API.

The Django Framework

Let us now understand the Django web application framework. Django is arguably the most powerful Python web framework used by mega-tech companies to build enterprise-grade and data-intensive web applications. From the Django project website, Django makes it easier to build better web applications more quickly and with less code.


By definition, Django is a complete open-source Python web framework for the quick and clean development of web applications. Django is a highly opinionated framework and compels the developer to adopt a design philosophy that removes the initial challenges of web project configurations and allows the developer to focus on his application logic.

Why use Django?

In the fast-paced business world, companies compete at early entry into the market quickly and securely. Because Django takes care of the initial challenges of web development, it makes it easy for developers to focus on product development logic without the needless development of generic solutions.


The inspiration behind Django was to help web developers move from concepts to complete solutions securely and quickly. Django has batteries included, so many already made solutions to handle user authentication, content administration, site maps, RSS feeds, and authorization right out of the box. These solutions cut down development time.


Django creators were security-conscious right from the beginning of the framework. Django handles common security challenges such as cross-site request forgery and clickjacking, cross-site scripting, and SQL injection attacks. The already-made solutions were baked into the framework right from the beginning to ensure the applications created with Django are flexible and can scale quickly to handle heavy web traffic. Django's versatility has led to numerous applications, from social networks to scientific computing platforms.

Definition of PostgreSQL

PostgreSQL is an open-source object-relational database with a reputation for power, reliability, feature-rich and performant. The success of PostgreSQL is the strength of the open-source community behind it.

Why PostgreSQL?

PostgreSQL has a rich feature ecosystem to enable easy and secure development of applications and protection of data in a fault-tolerant environment. PostgreSQL is great for both big and small data-driven applications. Aside from all the great features, PostgreSQL allows you to define custom data types and functions and write code from other major object-oriented programming languages without recompiling your existing database.


PostgreSQL can store data in JSON format, making it possible to use the database as NOSQL compliant. PostgreSQL is the most SQL-compliant relational database out there.


The second chapter of our journey will consist of project planning, feature identification, the number of tables and their relations, and identifying the appropriate data types. See you in the next face of our journey. I welcome comments and inputs that will enrich the quality of the API under development. We never stop learning. I undertake this to learn and create an entirely new application.