github

spaceuptech / space-cloud

  • понедельник, 15 апреля 2019 г. в 00:18:26
https://github.com/spaceuptech/space-cloud

Go
Space Cloud is an open source, web server that provides instant Realtime APIs on any database of your choice. Build highly scalable apps with the agility of a prototype!



Space Cloud

Instant Realtime APIs on any database

WebsiteDocsSupport

Build Status
Apache License

Space Cloud replaces your traditional backend servers and simplifies app development:

  • Instant: Various pre-built modules such as User Management, Realtime CRUD and File Storage
  • Secure: Authentication and authorization baked in by default
  • Extensible: Provision to write custom backend logic

Table of Contents

Motivation

Making enterprise scale apps at the speed of prototyping is still a distant dream for many of us. Even a simple chat app becomes complicated at scale. Following best practices when starting something from scratch is very time consuming. Securing your app is a different ball game altogether.

Well, there are some excellent tools out there which help simplify app development like Google Firebase. But these tools come with their own vendor lock-ins. They either force you to use their own cloud or only work with a particular database. The next-gen apps on the other hand always require multiple task-specific databases and should even run on a private cloud.

We believed that technology should adapt to your needs and not the other way around. You should be able to choose any database, cloud vendor or technology of your preference. Agility should not come at the cost of flexibility. Space Cloud was born to solve precisely these problems.

About Space Cloud

Note: Space Cloud is still in Beta.

Space Cloud is essentially a web server that automatically integrates with an existing or a new database to provide instant realtime APIs over REST, websockets, gRPC, etc. Written in Golang, it provides a high throughput data access layer which can be consumed directly from the frontend. It's completely unopinionated and works with the tech stack of your choice.

Basic Space Cloud architecture

In a nutshell, Space Cloud provides you with all of the following without having to write a single line of backend code:

  • Ready to use functionalities like User Management, Realtime CRUD and File Storage.
  • Baked-in security.
  • Freedom from vendor lock-ins.
  • Flexibility to work with the tech stack of your choice.

How it works

Space Cloud is meant to replace any backend php, nodejs, java code you may write to create your endpoints. Instead, it exposes your database over an external API that can be consumed directly from the frontend. In other words, it allows clients to fire database queries directly.

However, it's important to note that the client does not send database (SQL) queries to Space Cloud. Instead, it sends an object describing the query to be executed. This object is first validated by Space Cloud (using security rules). Once the client is authorized to make the request, a database query is dynamically generated and executed. The results are sent directly to the concerned client.

We understand that not every app can be built using only CRUD operations. Sometimes it's necessary to write business logic. For such cases, Space Cloud offers you APIs to write functions (which runs as microservices alongside Space Cloud). These functions can be invoked from the frontend or by other functions. In this scenario, Space Cloud acts merely as an api gateway between your functions and the client.

Detailed Space Cloud architecture

Apart from these, Space Cloud also integrates with tons of cloud technologies to give you several other features like realtime database (changes in the database are synced with all concerned clients in realtime), file storage, etc.

Design Goals

There are a lot of design decisions taken by us while creating Space Cloud. These form the guiding principles which heavily influence the roadmap ahead. Understanding them would also make our objectives of creating Space Cloud a lot more clear.

Ease of use

The main reason Space Cloud was born was to simplify the app/web development process. Right from making simple CRUD operations to syncing data reliably in a distributed environment, everything must be as simple as a function call. This is the prime reason we chose to have a consistent API across all the databases/technologies we support.

This also means that Space Cloud needs to be as unopinionated as possible to reuse the existing skill sets and tech you might be well versed with.

Security

We take security a bit too seriously. In fact, we are close to being paranoid about it. All products built with Space Cloud must be highly secure.

The idea of exposing your database over a public API doesn't sound like a good one. But to make sure we can do it in a secure manner, we have added a powerful yet flexible feature called security rules. These security rules (written in JSON or YAML) along with JWT tokens help you take care of a wide variety of authentication and authorization problems.

Enterprise-ready

We believe that each app built with Space Cloud must be extremely robust and future proof. We shall never comprise on the robustness of the platform at any cost. This also implies that we need to maintain strict backward compatibility.

Leverage the existing tools

The goal of this project is not to re-invent the wheel over and over again. In fact, integration with proven technologies is preferred over implementing them ourselves. For example, we are using Apache Kafka under the hood, to make our realtime database feature reliable. Also, Nats is used to implement the functions modules for high throughput and scale.

Documentation

We are working hard to document every aspect of Space Cloud to give you the best onboarding experience. Here are links to the various docs we have:

Getting started

Let's see how to build a realtime todo app using Space Cloud

Prerequisites

Note: MongoDB is not a dependency of Space Cloud. The sample app in this quick start uses MongoDB as it's database.

Step 1: Download Space Cloud

The first step is to download the space-cloud binary. This binary is the server creating the endpoints and connecting to your database. You need to download a binary for your operating system or you could build it directly from its source code. You will need go version 1.11.2 or later to build it from source.

Download the binary for your OS from here:

You can unzip the compressed archive

For Linux / Mac: unzip space-cloud.zip

For Windows: Right click on the archive and select extract here.

Make the space-cloud binary executable and add it to your path.

For Linux / Mac: chmod +x space-cloud

Step 2: Download the config file

Space Cloud needs a config file in order to function properly. It relies on the config file to load information like the database connection string, security rules, etc.

You can find a sample config for the todo app here. Feel free to explore the file.

Step 3: Start Space Cloud

You can start space-cloud with the following command. Make sure MongoDB is running before this step.

For Linux / Mac: ./space-cloud run --config config.yaml

For Windows: space-cloud.exe run --config config.yaml

That's it. Your backend is up and running!

Step 4: Download the TODO App

Our backend is up and running. Time to show off its awesome powers. We have built a realtime todo app using HTML and javascript which uses the backend you have just set up.

Open it in two different windows by double clicking the HTML file twice, login into both and then try adding some todos to see the magic.

Support & Troubleshooting

The documentation and community will help you troubleshoot most issues. If you have encountered a bug or need to get in touch with us, you can contact us using one of the following channels:

Contributing

Space Cloud is a young project. We'd love to have you on board if you wish to contribute. To help you get started, here are a few areas you can help us with:

  • Writing the documentation
  • Making sample apps in React, Angular, Android, and any other frontend tech you can think of
  • Deciding the road map of the project
  • Creating issues for any bugs you find
  • And of course, with code for bug fixes and new enhancements

License

Space Cloud is Apache 2.0 licensed.