Build a Social Media App in 60 Minutes Using Low Code

The graphic shows an example of a social media app built using a low-code application platform.
What Exactly Does This Social Media App Do?
The goal is to build a simple social media app with the following functionality:- Users can post photos by selecting and uploading them from their local device and adding a comment with those photos.
- The users can also scroll and see what their friends have posted, like their pictures and keep count of the likes on each image.
Build a Social Media App Using Oracle APEX, Step by Step
Build the Data Model
Low-code platforms provide the tools necessary to be productive and deliver on time. Oracle APEX provides the Quick SQL utility to rapidly design and prototype data models using a markdown-like shorthand syntax that expands to standards-based Oracle SQL. Quick SQL is designed to reduce the time and effort required to create SQL tables, triggers and index structures. Let’s first understand this application’s data model. The data model includes two tables — a table for the posts and a table for the reactions to the posts. These tables each have a primary key and a foreign key relationship linking reactions to posts. A constraint is added to ensure users can only react to a post once. In this example, we prefix our database objects with `SM_ `(short for social media), as shown in the following model:
The graphic shows the data model for the APEX social media application.
# prefix: "sm_"
# apex: true
posts /auditcols
post_comment vc4000
file_blob blob
file_mime vc255
file_name vc255
lat num
lon num
reactions /auditcols
post_id /fk posts
reaction vc16
lat num
lon num

The graphic shows the Quick SQL interface, where you enter the shorthand syntax, generate SQL and save the SQL script.
Build the Basic Application
To start building the app, you have different options. You can sign up for an Oracle Cloud Free Tier account and then either create an Always Free APEX Service or provision an always-free version of Oracle Autonomous Database. You can also request a free workspace on apex.oracle.com or stand up your APEX instance locally. Once a service is available, you need to create an APEX workspace and can then start building applications using the declarative Create App Wizard. As a low-code application platform, Oracle APEX includes intelligent wizards to guide you through rapidly creating applications and components. The social media app we are building in this example is a single-page app. Create a blank application using the Create App wizard with just the Home page. Name the app APEX SocialMedia. Change the Home page name to Timeline. Select the Install Progressive Web App checkbox in the Create App Wizard to allow the app to be installed on a device as a progressive web application (PWA). Using modern web APIs, PWAs give users an experience that looks and feels like a native app. This application will look great on either desktop or mobile devices.
The graphic shows the Create App Wizard. You update the homepage name as Timeline and select the Install Progressive Web App feature checkbox.

The graphic shows the Timeline page opened in Page Designer. You remove the navigation menu from the page by turning on the Override User Interface Level switch.

The graphic shows the Timeline page opened in Page Designer. You remove the default breadcrumb.

The graphic shows the basic application built using Oracle APEX.
Build the Form Inline Dialog to Add and Submit a Post
Each application page consists of regions, page items and buttons. A region is an area on a page serving as a content container. A page can have any number of regions. An item is part of an HTML form, such as a checkbox, date picker, file browse field, popup list of values (LOV), select list, text field, text area, etc. Page items are placed on a page and have associated user interface properties. APEX allows you to add these components by dragging and dropping them from the Gallery within the Page Designer. You can also add components to a page using the Gallery context menus. Next, let’s build page regions within this application. In this example, we need a Form region and a Cards region. The Form region will present a UI enabling users to choose an image file from their device (or take a picture on mobile) and enter an associated comment for the post. 1. First, navigate to Page Designer, and create a Form region on the Timeline page. The source of this Form Region should be the `SM_POSTS` table we made from the Quick SQL script earlier. We now have a Form that labels the columns as input fields that support keyboard entry.
The graphic shows the Form region with the SM_POSTS table as the source. APEX populates the available columns from the table as page items in the Form.

The graphic shows how to delete unnecessary page items in the Form region.

The graphic shows configuring the P1_FILE_BLOB page item attributes.

The graphic shows configuring the Form region properties.

The graphic shows configuring the Add Post button properties and creating a dynamic action.

The graphic shows creating and configuring the Submit Process to insert a new record into the `SM_POSTS` table.

The graphic shows the Posted message to confirm the post that has been submitted using the Form dialog.
Build the Cards Region to Display the Posts
Next, we need a Cards region to display the posts. A Cards region supports declarative customization of layout and appearance, and the inclusion of icons, badges, media and actions. You can use Cards to embed and share media sourced from a BLOB column, URL or video in iFrame. Let’s create a Cards region on the Timeline page. The Cards region will show photos or images in a grid format as they’re posted into the `SM_POSTS` table through the Form region. The cards region will also serve as our scaffolding for other features, such as displaying the post comment, reaction counts, buttons for reacting to/liking a post and enabling users to delete their posts. The source SQL query for this Cards region fetches data from the `SM_POSTS` and the `SM_REACTIONS` tables. In the next step, we must configure which columns from the query results will be used in which parts of the Cards.
The graphic shows configuring the Cards region attributes.

The graphic shows the Cards region with a post that has been submitted and includes an image and a comment.
Add the Like and Delete Buttons
Next, we need to customize the Cards region by adding two buttons: Like and Delete. The Like button will display the current likes count next to a heart icon. The user will be able to see the number of likes in total, and they will be able to click the button and add their like to the post. If the user has already liked the post, clicking it again will remove the like. We also need to create a button for deleting posts, and add a condition to this button so that it only displays for posts that belong to the logged-in user. 1. To create a link from a Cards page, you create an Action and then select an Action type. In the Page Designer, for the Cards region, create an Action. For the label, enter `&REACTIONS.` (including the period). This is called APEX string substitution syntax, and it will render the count of reactions as the label for this button on each post. The REACTIONS column is defined in the SQL query source for this Cards region. Set the Link type to `Redirect to URL`. We need the LIKE button to have a URL that can be linked to JavaScript later so that the database operation can be performed. The target URL can be, for example, `#action$like?id=&ID.` (including the period). 2. Update the Appearance attributes as appropriate. For example, select Text with Icon for display type and enter` fa-heart &USER_REACTION_CSS.` (including the period) for Icon. Note that the `USER_REACTION_CSS` column is defined in the SQL query source for this Cards region. For the CSS classes property, enter `js-heart-button`, which will be used by our dynamic action JavaScript later.
The graphic shows creating the Like button and configuring its attributes.

The graphic shows creating the Delete button and configuring its attributes.
apex.actions.add([{
name: "like",
action: (event, element, args) => {
apex.items.P1_ACTION_ID.value = args.id;
apex.event.trigger(document, 'action-like');
}
}, {
name: "delete",
action: (event, element, args) => {
apex.items.P1_ACTION_ID.value = args.id;
apex.event.trigger(document, 'action-delete');
}
}]);

The graphic shows the card’s region with a post that has been submitted along with the Like and Delete buttons.
Add Dynamic Actions
Both the Like and Delete buttons are available on the cards, but clicking these buttons does not currently have any visible effect. Behind the scenes, the URL Link targets call the JavaScript on the page and set the `P1_ACTION_ID`. But we must create a dynamic action with a custom event for each button. This design pattern dramatically simplifies the amount of JavaScript required to make the magic happen. First, create a dynamic action with a custom action-like event. We need to configure the True actions for the action-like dynamic action. We need two True actions to:- Update the UI on the client with either one more or one less Like (using a little JavaScript code).
- Invoke the database work necessary to record the desired state for the user for the corresponding post (using a little PL/SQL code).

The graphic shows a dynamic action with a custom action-like event and the two True actions configured for this Dynamic Action.
- Confirm deletion.
- Invoke the database work necessary to delete the desired post (using a little PL/SQL code).
- Update the UI on the client by removing the deleted post.

The graphic shows a dynamic action with a custom action-delete event and the three True actions configured for this dynamic action.

The graphic shows the Cards region with a post. Clicking the Delete button will open the delete confirmation dialog.
Improve the Appearance of Your App
Let’s fine-tune the app to improve its look and feel. This needs a little bit of CSS. When we like a post, we should be able to see the heart icon in red. Also, if we are using this app on a small screen (like a mobile device), it would be better to relocate the Add Post button to the bottom right of the screen. We can do this with two small blocks of inline CSS on the page level. To do this, update the CSS > Inline section of the page properties with the CSS code below:
.user-has-liked {
color: red;
}
@media (max-width: 640px) {
.new-post-button {
position: fixed;
bottom: 24px;
right: 24px;
z-index: 1000;
}
}

The graphic shows updating the appearance and layout properties of the File Browse page item.

The graphic shows the Like button, a heart icon in red.