subZero GraphQL/REST API Starter Kit

Base project and tooling for authoring data API backends with subZero.

subZero Starter Kit

Runs Anywhere

Run subZero stack as a hassle-free service (free plan available) or deploy it yourself anywhere using binary and docker distributions.


āœ“ Out of the box GraphQL/REST endpoints created by reflection over a PostgreSQL schema
āœ“ Cross-platform development on macOS, Windows or Linux inside Docker
āœ“ PostgreSQL database schema boilerplate with authentication and authorization flow
āœ“ OpenResty configuration files for the reverse proxy
āœ“ RabbitMQ integration through pg-amqp-bridge
āœ“ Lua functions to hook into each stage of the HTTP request and add custom logic (integrate 3rd party systems)
āœ“ Debugging and live code reloading (sql/configs/lua) functionality using subzero-cli
āœ“ Full migration management (migration files are automatically created) through subzero-cli/sqitch/apgdiff
āœ“ SQL unit test using pgTAP
āœ“ Integration tests with SuperTest / Mocha
āœ“ Docker files for building production images
āœ“ Community support on Slack
āœ“ Enhanced PostgREST+ binary that creates prepared statements instead of inline queries
āœ“ Live events (with authentication/authorization) through RabbitMQ WebSTOMP plugin
āœ“ Scriptable proxy level caching using nginx proxy_cache (other backends like Redits possible)

Directory Layout

ā”œā”€ā”€ db                        # Database schema source files and tests
ā”‚   ā””ā”€ā”€ src                   # Schema definition
ā”‚       ā”œā”€ā”€ api               # Api entities avaiable as REST endpoints
ā”‚       ā”œā”€ā”€ data              # Definition of source tables that hold the data
ā”‚       ā”œā”€ā”€ libs              # A collection modules of used throughout the code
ā”‚       ā”œā”€ā”€ authorization     # Application level roles and their privileges
ā”‚       ā”œā”€ā”€ sample_data       # A few sample rows
ā”‚       ā””ā”€ā”€ init.sql          # Schema definition entry point
ā”œā”€ā”€ openresty                 # Reverse proxy configurations and Lua code
ā”‚   ā”œā”€ā”€ lua                   # Application Lua code
ā”‚   ā”œā”€ā”€ nginx                 # Nginx configuration files
ā”‚   ā”œā”€ā”€ html                  # Static frontend files
ā”‚   ā””ā”€ā”€ Dockerfile            # Dockerfile definition for building custom production images
ā”œā”€ā”€ tests                     # Tests for all the components
ā”‚   ā”œā”€ā”€ db                    # pgTap tests for the db
ā”‚   ā”œā”€ā”€ graphql               # GraphQL interface tests
ā”‚   ā””ā”€ā”€ rest                  # REST interface tests
ā”œā”€ā”€ docker-compose.yml        # Defines Docker services, networks and volumes
ā””ā”€ā”€ .env                      # Project configurations



Create a New Project

subzero-cli provides you with a base-project command that lets you create a new project structure:

subzero base-project

? Enter the directory path where you want to create the project .
? Choose the starter kit (Use arrow keys)
āÆ subzero-starter-kit (REST & GraphQL) 
  postgrest-starter-kit (REST) 

After the files have been created, you can bring up your application (API). In the root folder of application, run the docker-compose command

docker-compose up -d

The API server will become available at the following endpoints:

Try a simple request

curl http://localhost:8080/rest/todos?select=id,todo

Try a GraphQL query in the integrated GraphiQL IDE at http://localhost:8080/graphiql/


Development workflow and debugging

Execute subzero dashboard in the root of your project.
After this step you can view the logs of all the stack components (SQL queries will also be logged) and if you edit a sql/conf/lua file in your project, the changes will immediately be applied.


The starter kit comes with a testing infrastructure setup. You can write pgTAP tests that run directly in your database, useful for testing the logic that resides in your database (user privileges, Row Level Security, stored procedures). Integration tests are written in JavaScript.

Here is how you run them

npm install                     # Install test dependencies
npm test                        # Run all tests (db, rest, graphql)
npm run test_db                 # Run pgTAP tests
npm run test_rest               # Run rest integration tests
npm run test_graphql            # Run graphql integration tests



Anyone and everyone is welcome to contribute.

Support and Documentation


Copyright Ā© 2017-present subZero Cloud, LLC.
This source code in this repository is licensed under MIT license
Components implementing the GraphQL interface (customized PostgREST and OpenResty docker images) are available under a commercial license
The documentation to the project is licensed under the CC BY-SA 4.0 license.

Subzero Starter Kit

Starter Kit and tooling for authoring GraphQL/REST API backends with subZero

Subzero Starter Kit Info

ā­ Stars 127
šŸ”— Homepage
šŸ”— Source Code
šŸ•’ Last Update a year ago
šŸ•’ Created 4 years ago
šŸž Open Issues 4
āž— Star-Issue Ratio 32
šŸ˜Ž Author subzerocloud