Backend
This setup is meant for development. If you want a quick trial of Hyperswitch (without contributing), use this guide.
Supported Methods:
Setup using docker compose
Rust environment setup along with other dependencies
Set up a development environment using Docker Compose
Install Docker Compose.
Clone the repository and switch to the project directory:
git clone https://github.com/juspay/hyperswitch cd hyperswitch(Optional) Configure the application using the
config/docker_compose.tomlfile. The provided configuration should work as is. If you do update thedocker_compose.tomlfile, ensure to also update the corresponding values in thedocker-compose.ymlfile.Start all the services using Docker Compose:
docker compose --file docker-compose-development.yml up -dThis will compile the payments router, the primary component within hyperswitch and then start it. Depending on the specifications of your machine, compilation can take around 15 minutes.
(Optional) You can also choose to start the scheduler and/or monitoring services in addition to the payments router.
Verify that the server is up and running by hitting the health endpoint:
curl --head --request GET 'http://localhost:8080/health'If the command returned a
200 OKstatus code, proceed with trying out our APIs.
Set up a Rust environment and other dependencies
If you are using nix, please skip the setup dependencies step and jump to Set up the database.
Set up dependencies on Ubuntu-based systems
This section of the guide provides instructions to install dependencies on Ubuntu-based systems. If you're running another Linux distribution, install the corresponding packages for your distribution and follow along.
Install the stable Rust toolchain using
rustup:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shWhen prompted, proceed with the
defaultprofile, which installs the stable toolchain.Optionally, verify that the Rust compiler and
cargoare successfully installed:rustc --versionBe careful when running shell scripts downloaded from the Internet. We only suggest running this script as there seems to be no
rustuppackage available in the Ubuntu package repository.Install PostgreSQL and start the
postgresqlsystemd service:sudo apt update sudo apt install postgresql postgresql-contrib libpq-dev systemctl start postgresql.serviceIf you're running any other distribution than Ubuntu, you can follow the installation instructions on the PostgreSQL documentation website to set up PostgreSQL on your system.
Install Redis and start the
redissystemd service:sudo apt install redis-server systemctl start redis.serviceIf you're running a distribution other than Ubuntu, you can follow the installation instructions on the Redis website to set up Redis on your system.
Install
diesel_cliusingcargo:cargo install diesel_cli --no-default-features --features postgresMake sure your system has the
pkg-configpackage and OpenSSL installedsudo apt install pkg-config libssl-dev
Once you're done with setting up the dependencies, proceed with setting up the database.
Set up dependencies on Windows (Ubuntu on WSL2)
This section of the guide provides instructions to install dependencies on Ubuntu on WSL2. If you prefer running another Linux distribution, install the corresponding packages for your distribution and follow along.
Install Ubuntu on WSL:
wsl --install -d UbuntuRefer to the official installation docs for more information. Launch the WSL instance and set up your username and password. The following steps assume that you are running the commands within the WSL shell environment.
Note that a
SIGKILLerror may occur when compiling certain crates if WSL is unable to use sufficient memory. It may be necessary to allow up to 24GB of memory, but your mileage may vary. You may increase the amount of memory WSL can use via a.wslconfigfile in your Windows user folder, or by creating a swap file in WSL itself. Refer to the WSL configuration documentation for more information.Install the stable Rust toolchain using
rustup:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shWhen prompted, proceed with the
defaultprofile, which installs the stable toolchain.Optionally, verify that the Rust compiler and
cargoare successfully installed:rustc --versionBe careful when running shell scripts downloaded from the Internet. We only suggest running this script as there seems to be no
rustuppackage available in the Ubuntu package repository.Install PostgreSQL and start the
postgresqlservice:sudo apt update sudo apt install postgresql postgresql-contrib libpq-dev sudo service postgresql startFor more information, refer to the docs for installing PostgreSQL on WSL. If you're running any other distribution than Ubuntu, you can follow the installation instructions on the PostgreSQL documentation website to set up PostgreSQL on your system.
Install Redis and start the
redis-serverservice:sudo apt install redis-server sudo service redis-server startFor more information, refer to the docs for installing Redis on WSL. If you're running a distribution other than Ubuntu, you can follow the installation instructions on the Redis website to set up Redis on your system.
Make sure your system has the packages necessary for compiling Rust code:
sudo apt install build-essentialInstall
diesel_cliusingcargo:cargo install diesel_cli --no-default-features --features postgresMake sure your system has the
pkg-configpackage and OpenSSL installed:sudo apt install pkg-config libssl-dev
Once you're done with setting up the dependencies, proceed with setting up the database.
Set up dependencies on Windows
We'll be using winget in this section of the guide, where possible. You can opt to use your favorite package manager instead.
Install PostgreSQL database, following the official installation docs.
Install Redis, following the official installation docs.
Install rust with
winget:winget install -e --id Rustlang.Rust.GNUInstall
diesel_cliusingcargo:cargo install diesel_cli --no-default-features --features postgresInstall OpenSSL with
winget:winget install openssl
Once you're done with setting up the dependencies, proceed with setting up the database.
Set up dependencies on MacOS
We'll be using Homebrew in this section of the guide. You can opt to use your favorite package manager instead.
Install the stable Rust toolchain using
rustup:brew install rustup rustup default stableOptionally, verify that the Rust compiler and
cargoare successfully installed:rustc --versionInstall PostgreSQL and start the
postgresqlservice:brew install postgresql@14 brew services start postgresql@14If a
postgresdatabase user was not already created, you may have to create one:createuser -s postgresInstall Redis and start the
redisservice:brew install redis brew services start redisInstall
diesel_cliusingcargo:cargo install diesel_cli --no-default-features --features postgresIf linking
diesel_clifails due to missinglibpq(if the error message is along the lines ofcannot find -lpq), you may also have to installlibpqand reinstalldiesel_cli:brew install libpq export PQ_LIB_DIR="$(brew --prefix libpq)/lib" cargo install diesel_cli --no-default-features --features postgresYou may also choose to persist the value of
PQ_LIB_DIRin your shell startup file like so:echo 'PQ_LIB_DIR="$(brew --prefix libpq)/lib"' >> ~/.zshrcInstall a command runner called
just:In order to make running migrations easier, you can use a command runner called just
cargo install just
Once you're done with setting up the dependencies, proceed with setting up the database.
Set up the database
Create the database and database users, modifying the database user credentials and database name as required.
export DB_USER="db_user" export DB_PASS="db_pass" export DB_NAME="hyperswitch_db"On Ubuntu-based systems (also applicable for Ubuntu on WSL2):
sudo -u postgres psql -e -c \ "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;" sudo -u postgres psql -e -c \ "CREATE DATABASE $DB_NAME;"On MacOS:
psql -e -U postgres -c \ "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;" psql -e -U postgres -c \ "CREATE DATABASE $DB_NAME"Clone the repository and switch to the project directory:
git clone https://github.com/juspay/hyperswitch cd hyperswitchRun database migrations:
Export the
DATABASE_URLenv variableexport DATABASE_URL=postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAMERun the migrations
If you have just installed
just migrateUsing the diesel-cli command
diesel migration run
Once you're done with setting up the database, proceed with configuring the application.
Configure and Run the ApplicationLast updated
Was this helpful?

