Creating a new service

Since the OpenTera architecture allows for stand-alone services, there is not imposed constraints on the technical choices behind the creation of new services.

Service creation steps

To create a new service using OpenTera, the following general steps should be used:

  1. Assign a local listening port for the service and adjust the NGINX config file accordingly.

  2. Create the basic service structure (using the OpenTera PyPi package if developing in Python).

  3. Develop the service backend and, optionally, the frontend

NGINX configuration

If your service expose a public API / front end, you will need to modify the NGINX config file.

Basically, you will need to add a new endpoint url and the correct local listening port for your service in the NGINX config file.

Of course, if you are developing a local service that doesn’t have public access (such as a service to process data without any user interaction), this step might not be required.

Basic service structure

There is no imposed service structure, as long as the service uses the service API and the communication mechanisms to communicate and exchange data with the core TeraServer service.

To ease the creation of new services, examples can be found in the main OpenTera project. Those examples can serve as a building block to create your own services.

Also, providing some basic authentication and applying the communication mechanisms can be facilitated by using the OpenTera PyPi package which only needs to be imported in your Python project.

Service backend and frontend

A service can provide a backend (such as a REST API) and a frontend.

While there’s many way to do so, services source files are usually structured in two folders: Frontend, which should contain the necessary files for the service frontend (whether it is based on a web framework such as Angular or React or something else) and a Backend folder containing the required source files to process data and present a REST API (based on Flask or something else) to the user.