Skip to content

SuperTokens Architecture

Rishabh Poddar edited this page Sep 29, 2020 · 6 revisions

SuperTokens is a full-stack solution. This means that we offer SDKs that integrate with your frontend, your backend and your database. This way, we can make it easy for you to add any aspect of auth to your application.

Main components

  • SuperTokens core: This is a Java HTTP service that contains the main logic for SuperTokens, and also interacts with a database. Deployment options are listed below. This repository contains the code for this service.
  • Database plugin: This is a Java extension that "plugs" into the core to provide support for a specific database. We have plugins for MySQL, PostgreSQL, MongoDB, and more are on the way. By default, we use an in-memory database using the SQLite plugin.
  • Backend SDK / Drivers: These are SDKs written for the various backend web frameworks like NodeJS, Flask, Golang etc. These make it very easy for you to interact with the core by exposing high-level functions like createNewSession and middlewares for session verification.
  • Frontend SDK: These are SDKs written for the various frontend clients like for Websites, iOS, Android and React Native. These provide automatic refreshing of sessions, ability to check if a session exists, get the user ID of the currently logged-in user, etc.

The frontend SDK talks to the backend SDK, which talks to the SuperTokens core, which uses the Database plugin to communicate with the database.

Other components

For each of the above components to talk to each other, there needs to be an interface they agree on. Each interface has its own versioning:

  • Plugin interface: This is a Java interface that allows the core to use a database plugin that implements this interface. There are separate interfaces for SQL and NoSQL databases.
  • Core Driver Interface (CDI): This is an http API spec that is used to communicate between the core and the driver (backend SDKs)
  • Frontend Driver Interface (FDI): This is a http "header" interface that is used to communicate between the frontend SDKs and the driver (backend SDKs). A header interface is one that defines how the http headers should be set depending on certain operations.

SuperTokens core deployment options

Docker

We provide docker images for each database type. This way, each image has the minimum possible size. Each docker image also has an in memory database that can be used for quickly getting started. The docker pull command and it's README, for a specific database, can be found here.

Manual installation

You can get a ZIP file containing support for your specific database once you sign up for SuperTokens here. You would need to extract the ZIP file, and run the install command on your system as mentioned here.

Building from source

The instructions for this can be found here.

Clone this wiki locally