Create a Backend Admin Dashboard and REST APIs without Coding in 5 minutes

Current full stack development trends see front-end development using modern javascript frameworks such as React, Vue, Angular, etc., while the back-end uses Python, Node.js, Java, C#, Php, and more. With the rise of back-end supporting services like Firebase and Amplify, it is becoming easy to focus on front-end development and use the libraries to interact with the back-end. So, it’s important for front-end developers to also have sufficient knowledge of the back-end technologies. Today, almost all web and mobile applications have a back-end admin dashboard to administer and manage the application. However, with no knowledge of back-end development, functionality can still be developed using headless CMS tools.

In this blog, we will explore Strapi – an open source headless CMS in JavaScript.

Strapi can:

  • Create a customisable back-end dashboard
  • Create users (while also supporting external auth providers like Auth0, Cognito, etc.)
  • Create data using multiple tables with relationships
  • Create APIs (REST and GraphQL)
  • Upload media and assets (supports S3 through plugin)
  • Create webhooks on table operations

 

To demonstrate this, we will create a blog application backend.

Step 1: Installation

Prerequisites: Install Node v18.x and Node.js package manager (npm v6)

Run the following on terminal:

npx create-strapi-app@latest my-project --quickstart

It will open the URL – http://localhost:1337/admin/auth/register-admin

  • Register as the first admin user
  • It will create a default SQLite Database in the .tmp/data.db directory
  • The database can be configured later on. The ptions are PostgreSQL and MySQL

Step 2: The Admin Dashboard

Once registered as the first admin user, the following screen will appear. This is the dashboard.

The local table can be seen by SQLite Browser (https://sqlitebrowser.org/dl/)

The admin panel dashboard supports creating multiple users. A user table is already created, with the option to add more fields if required.

Content-Type Builder helps to create collections (tables)

Collection Types: Allows you to create database tables and identify relationships with each other. These can be linked to the users table for creating relationships.

Single Types: Allows you to create tables which are common to the application and don’t have users. This includes common page functionalities like home page content, contact details, and more.

Content-Type Builder helps to create collections (tables)

Collection Types: Allows you to create database tables and identify relationships with each other. These can be linked to the users table for creating relationships.

Single Types: Allows you to create tables which are common to the application and don’t have users. This includes common page functionalities like home page content, contact details, and more.

Step 3: Create blog table (fields - Title, Post, PostImage)

Create Fields – Title, Post, PostImage

Many field types are supported, including text, rich text, number, date, JSON, media, and more.

SAVE first to continue. Tables should be saved in order to create relationships with other tables.

Next, create a relationship with users table.

Create relationship with users table (one blog has one user).

Strapi supports one-to-one, one-to-many, many-to-one, many-to-many relationships.

FINISH and SAVE

Step 3: Create a Blog entry

SAVE and PUBLISH the record.

The tables can be seen on the SQLite browser.

Step 4: Create APIs

Generate an API token from Settings > API Tokens

Various access levels and permissions can be chosen to generate the API token. Copy the token and use it in the Postman for API authentication.

Use Postman to test the REST API endpoint – http://localhost:1337/api/blogs

http://localhost:1337/api/blogs?populate=* to get all the data

The above process will take no more than five minutes. Depending on the use cases, any complex application backend can be created in hours.

Here are a few interesting things to know about Strapi

  • The Strapi dashboard design can be fully customised (JavaScript skills are needed to do this)
  • The self-hosted version of Strapi is free
  • Deployments of Strapi can be done on anywhere using EC2/ECS and RDS (MySQL and PostgreSQL) as a database
  • Plugins are available to support many out-of-the-box features. Plugins can be developed to extend the functionality of Strapi
  • The i18n plugin allows users to create and distribute localised content in different languages

 

Paid alternatives to Strapi are Kontent.ai, Contenful etc. Paid options provide managed platform and support services. Open source alternatives including AppWrite and Directus are usually self-managed and support is available on demand.

Read more about STRAPI here – https://strapi.io/

Enjoyed this blog?

Share it with your network!

Move faster with confidence