Introduction
Para is a flexible backend service, created as an open-source project from the very beginning, in 2013. It was born out of our need to have a robust system which would allow us to persist objects easily to anything - RDBMS, NoSQL and in-memory databases. We needed a simple solution with an API which would scale well and provide a solid foundation for our future projects.
Para is a stateless, schemaless, 3-layer backend system with a REST API in front of it. The first layer is the database, the second layer is the search index and the third – the cache. Depending on how you use it, Para can either be a standalone backend service or a persistence framework that is part of your code base. Each request to the API is stateless, meaning you can scale out easily. The data model requires no schema – it’s based around plain old Java/JSON objects and is optimized for schemaless key-value data stores, but also works with traditional databases.
Para is also multitenant, which means you can deploy it as a standalone service on one or more nodes and host one or more applications on it (“apps”). An app can be a website, mobile app, desktop app or even a command-line tool. This is made possible by the REST API which talks JSON to your apps, and with the help of the client libraries below, it’s easy to get started. If you’re building an application on the JVM, you can also add Para as Maven dependency to your project. You can still keep the REST API or turn it off completely.
Quick start
- Download the latest executable JAR
- Create a configuration file
application.conffile in the same directory as the JAR package. - Start Para with
java -jar -Dconfig.file=./application.conf para-*.jar - Install Para CLI with
npm install -g para-cli - Create a new dedicated app for your project and save the access keys:
Alternatively, you can use the Para Web Console to manage data, or integrate Para directly into your project with one of the API clients below.# run setup and set endpoint to either 'http://localhost:8080' or 'https://paraio.com' # the keys for the root app are inside application.conf $ para-cli setup $ para-cli new-app "myapp" --name "My App"
Users are created either programmatically with paraClient.signIn(...) or with an API request to POST /v1/jwt_auth. See
Sign in or Authentication sections for more details.
Docker
Tagged Docker images for Para are located at erudikaltd/para on Docker Hub.
It’s highly recommended that you pull only release images like :1.51.0 or :latest_stable
because the :latest tag can be broken or unstable.
First, create an application.conf file and a data folder and start the Para container:
$ touch application.conf && mkdir data
$ docker run -ti -p 8080:8080 --rm -v $(pwd)/data:/para/data \
-v $(pwd)/application.conf:/para/application.conf \
-e JAVA_OPTS="-Dconfig.file=/para/application.conf" erudikaltd/para:latest_stable
Environment variables
JAVA_OPTS - Java system properties, defaults to -Dloader.path=lib
Plugins
You can create a custom Para container with all plugins and JDBC drivers you need by using docker compose.
Below is an example build of Para, using para-dao-sql, para-search-lucene and PosgreSQL as a database.
- First, create a new
Dockerfile-pluginswhich does a multi-stage build like so:
-
View contents of
Dockerfile-pluginsARG PARA_VERSION="0.0.0" ARG SQL_DAO_VERSION="0.0.0" FROM erudikaltd/para:v${PARA_VERSION} AS base FROM erudikaltd/para-dao-sql:${SQL_DAO_VERSION} AS dao FROM erudikaltd/para-search-lucene:${SEARCH_VERSION} AS search FROM base AS final COPY --from=dao /para/lib/*.jar /para/lib COPY --from=search /para/lib/*.jar /para/lib # EXAMPLE: Add a PostgreSQL JDBC Driver ARG PG_JDBC_VERSION="0.0.0" ADD https://jdbc.postgresql.org/download/postgresql-${PG_JDBC_VERSION}.jar /para/lib/
- Then, create a
docker-compose.ymlfile:
-
View contents of
docker-compose.ymlservices: para: depends_on: - db build: context: . dockerfile: Dockerfile args: PARA_VERSION: "1.51.0" SQL_DAO_VERSION: "1.49.1" PG_JDBC_VERSION: "42.7.7" image: para-with-plugins pull_policy: never ports: - "8080:8080" volumes: - type: volume source: paraData target: /para/data - type: volume source: paraLib target: /para/lib - type: bind source: ./para-application.conf target: /para/application.conf restart: always environment: - JAVA_OPTS=-Dconfig.file=/para/application.conf -Dloader.path=/para/lib db: image: postgres:latest ports: - "5432:5432" volumes: - type: volume source: postgresData target: /var/lib/postgresql/data restart: always environment: - POSTGRES_PASSWORD=mysecretpassword - PGDATA=/var/lib/postgresql/data volumes: paraData: paraLib: postgresData:
- Also reate the Para configuration file
para-application.conf:
-
View contents of
para-application.confpara.env = "production" para.dao = "SqlDAO" para.sql.driver = "org.postgresql.Driver" para.sql.url = "postgresql://db:5432/para" para.sql.user = "postgres" para.sql.password = "mysecretpassword"
- Finally, run
docker compose build para && docker compose up
Maven
The Java client for Para is a separate module with these Maven coordinates:
<dependency>
<groupId>com.erudika</groupId>
<artifactId>para-client</artifactId>
<version>{VERSION}</version>
</dependency>
In your own project you can create a new ParaClient instance like so:
ParaClient pc = new ParaClient(accessKey, secretKey);
// Para endpoint - http://localhost:8080 or https://paraio.com
pc.setEndpoint(paraServerURL);
// Set this to true if you want ParaClient to throw exceptions on HTTP errors
pc.throwExceptionOnHTTPError(false);
// send a test request - this should return a JSON object of type 'app'
pc.me();
The Java, JavaScript and Android Para client libraries have asynchronous versions of every API method. The rest of the client libraries only have synchronous methods.
In certain environments like serverless (AWS Lambda, CloudFlare Workers, etc.) the environment restricts code to run on a single thread.
In those cases, applications connecting to Para with a client must not use async functions or set para.executor_service_enabled = false.
We’ve built a full-blown StackOverflow clone with Para - check it out at https://scoold.com
Client libraries
Kubernetes
There’s a Helm chart inside the helm/ folder. First edit helm/para/values.yaml and then you can deploy Para to
Kubernetes with a single command:
cd helm; helm install para ./paraFor more info, check the quick start guide at helm/README.md.
Building Para
Para can be compiled with JDK 8 and up.
To compile it you’ll need Maven. Once you have it, just clone and build:
$ git clone https://github.com/erudika/para.git && cd para
$ mvn install -DskipTests=true
To generate the executable “uber-jar” run $ mvn package and it will be in ./para-jar/target/para-x.y.z-SNAPSHOT.jar.
Two JAR files will be generated in total - the fat one is a bit bigger in size.
To run a local instance of Para for development, use:
$ mvn spring-boot:run