The implementation of RESTful API for social media events platform



Стаття | Article    

Download

Bodak Bohdan

Igor Sikorsky Kyiv Polytechnic Institute

Kyiv, Ukraine

bohdan.bodak@outlook.com

Doroshenko Anatoliy

Igor Sikorsky Kyiv Polytechnic Institute

Kyiv, Ukraine

a-y-doroshenko@ukr.net

Abstract. Nowadays, there are many great applications for local search and recommendations, for example Foursquare, Swarm, and Snapchat to some extent. Swarm is a mobile application, which allows users to share their locations with friends and create a record of their experiences in their personal logbook. In addition, a spin-off from and companion app to the older Foursquare, Swarm lets users to check-in to a particular location and interact with people nearby. Besides, these check-ins are listed chronologically in order to create the person’s logbook, which in fact represents a digital library. However, many people agree that any social media platform requires a well-designed, scalable, and fast API. In this research, we used RESTful API principles to design a heavily loaded server for the new application. This paper mostly focuses on applying REST and OpenAPI standards using a social media platform as an example. The new specifications and methodologies outlined in this article may be used in the design phase of a heavily loaded backend service.

Keywords: Social media, local search, OpenAPI, REST, RESTful, scalable API, software architecture.

INTRODUCTION

Considering the popularity of various social media applications, our goal was to come up with a successful design and implementation of a backend service. This solution provides users a unified platform for managing, creating, and participating in events. Users will be able to retrieve information about existing events, create custom points of interest, share location and other assets, and invite friends. The REST [1] used by clients can be thought of as the cornerstone of the World Wide Web. With the rise of cloud platforms and services, REST API’s are a perfect choice to allow users to manage and interact with these web services in a platform-independent environment. Moreover, even key companies in the IT industry, such as Google, Amazon, and Microsoft are using it. This kind of API adopts existing HTTP methodologies defined by the RFC 2616 protocol [2]. With REST, all calls should be stateless, which is useful in cloud applications because components can easily scale and accommodate load changes. RESTful API design was defined by Dr. Roy Fielding [3] and it states that a web service must be in compliance with the next six architectural principles:

– Use of a uniform interface (UI)

– Client-server based

– Stateless operations

– RESTful resource caching

– Layered system

– Code on demand

SYSTEM REQUIREMENTS

The developed social media platform provides a unified database of existing events with detailed information, location, and cost. In addition, it allows a user to create his or her own event in a few steps with automated generation of invitations for friends. The storage of live stories and videos from an event is supported as well. Throughout the beginning of the system design process, we were able to outline the key features of the platform, which are provided in a list below:

– Token-based authentication. The API has to use JWT or any other type of token to grant permissions to a user.

– Integration with other social media platforms. The API has to support at least two providers: Google and Facebook.

– Retrieval of event’s list. The API must return a list of available events to user in form of JSON. Each event contains detailed information, such as location, image, hashtags, status, etc.

– Event creation. The API must have an option for user to create event (private or public), specify details and invite friends. The creator also has an ability to modify the event or delete it.

– Private events. The API provides an interface to create a closed event for a particular group of invited users only.

– Event invitations. The API gives an ability to create and send invitations to user’s friends by phone numbers or emails.

– Resources storage. The API provides methods to upload additional information about event, such as images or video into a cloud.

API IMPLEMENTATION

As a backend technology for this API, we decided to select ASP.NET Core, since it is stable and widely supported framework for building REST applications. This suite provides developers with various support lifecycle options to meet the needs of the application. First of all, the database model for our service was created (Fig. 1).

Fig. 1. Database model

After that, the data layer was generated with a help of Entity Framework, which represented a set of CRUD operations for each entity in the database. Microsoft Azure provides an MSSQL server as a service, which we used to deploy the database schema. Since this service supports Entity Framework migrations, there is no issue in updating or rolling back changes in a database. The RESTful API for our social media events platform includes five endpoints documented with OpenAPI v3.0 standard [4]:

– Auth

– Category

– Comments

– Event

– Storage

Each endpoint is also documented according to the standard and provides sample request/response parameters as well as expected status codes with description (Fig. 2).

Fig. 2. Documented API methods

DEPLOYMENT PROCESS

In order to maintain the access to the newest version of the server, it is important to set up an environment and deployment. In our case, it was crucial to deploy the REST API online, so we can test the client application with it. Microsoft Azure is a perfect choice for deploying web applications and services, since it has all pre-build pipelines for building .NET Core backend and publishing it to the virtual machine Azure Pipelines [5] combines continuous integration (CI) and continuous delivery (CD) to constantly and consistently test and build your code and ship it to any target. Continuous integration was used to automate tests and builds in our project. Every time the new code gets pushed to master, Azure automatically runs a build, tests, and saves a result. CD uses these builds to drive automated deployments. To avoid the problem of breaking the operation of the server, the pipeline features at Azure was used (Fig. 3):

Fig. 3. Azure pipelines

After setting up, every push request at project’s Git will trigger a build at Azure, and it will pull from GitHub, and build automatically. This result can be verified at Dashboard of Azure builds. Usually, the code will be published to the staging server for testing purpose, and if the submitted source code was stable and it was decided to publish, it was promoted to the production stage manually.

CONCLUSION

The system described in the article represents a RESTful API for a social media platform. This API was designed according to new methods and standards for a heavily loaded service in order to ensure high performance, scalability, and ease of use. In addition, we demonstrated the continuous integration and delivery process using Microsoft Azure pipelines, which plays a significant role in the testability and overall quality of the product. As a result, developed methodologies may be utilized in future for designing a heavily loaded service.

REFERENCES

[1] What is a RESTful API [Electronic Resource] / Tech Target NetworkSearch App Architecture – Access mode: https://searchapparchitecture.techtarget.com/definition/RESTful\-API.

[2] RFC 2616 transfer protocol [Electronic Resource] / W3C – AccessMode: https://www.w3.org/Protocols/rfc2616/rfc2616.html.

[3] Architectural Styles and the Design of Network-based SoftwareArchitectures [Electronic Resource] / Roy Thomas Fielding, University ofCalifornia, Irvine – Access mode: https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm.

[4] About Swagger specification [Electronic Resource] / Swagger.io –Acess mode: https://swagger.io/docs/specification/about/.

[5] Build, test, and deploy .NET Core apps [Electronic Resource] / Microsoft– Access mode: https://docs.microsoft.com/en\-us/azure/devops/pipelines/ecosystems/dotnet\-core?view=azure\-devops.

May 30, 2020