> For the complete documentation index, see [llms.txt](https://docs.openg2p.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openg2p.org/products/g2p-bridge/development/developer-install/installing-openg2p-bridge-on-linux.md).

# G2P Bridge

Installation of G2P Bridge on a developer machine

Developers can set up and run the G2P Bridge on their local machines. This guide outlines the steps to install G2P Bridge on a <mark style="color:purple;">**Linux-based**</mark> laptop or desktop.

## Prerequisites

* Python3
* Git
* PostgreSQL
* Redis
* Celery

## Installation of G2P Bridge

#### 1. Update system packages

* Log in to your Linux server using SSH and update the package list and upgrade the existing packages:

```bash
sudo apt update
sudo apt upgrade -y
```

#### 2. Install dependencies

```bash
sudo apt install -y python3-pip python3-dev build-essential libpq-dev
```

3\. Install and configure PostgreSQL

* G2P Bridge requires PostgreSQL as the database engine. Install PostgreSQL (if not already installed) and create a new database user for G2P Bridge.

  ```bash
  sudo apt install -y postgresql
  sudo su - postgres
  psql 
  CREATE ROLE bridgeuser WITH LOGIN NOSUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD 'password';
  CREATE DATABASE bridgedb WITH OWNER = bridgeuser CONNECTION LIMIT = -1;
  exit
  exit
  ```

4\. Clone the G2P Bridge Repository

* Clone the consolidated `g2p-bridge` monorepo to your local machine.

  ```bash
  git clone https://github.com/OpenG2P/g2p-bridge
  ```

{% hint style="info" %}
The G2P Bridge Python packages are **no longer published to PyPI** — install them from local source (editable installs) out of the cloned repo, as shown below. Only the external OpenG2P libraries (`openg2p-fastapi-common`, `openg2p-fastapi-auth`) come from PyPI. Module folders now live under `core/`, `extensions/` and `example-bank/` (the `openg2p-g2p-bridge-` prefix was dropped).
{% endhint %}

#### 5. Install Python Libraries and G2P Bridge Components <a href="#docs-internal-guid-f8d8e15e-7fff-3872-8a9f-bfbb05735977" id="docs-internal-guid-f8d8e15e-7fff-3872-8a9f-bfbb05735977"></a>

{% tabs %}
{% tab title="Bridge API" %}
**Setting up the Bridge API**

* Make a new Python virtual environment.

  ```bash
  cd g2p-bridge/core/partner-api
  python3 -m venv venv
  ```
* Activate the virtual environment.

  ```bash
  source venv/bin/activate
  ```
* Use `pip` to install the required Python packages, including the core libraries for the G2P Bridge.

  ```bash
  # External OpenG2P libs from PyPI
  python3 -m pip install openg2p-fastapi-common openg2p-fastapi-auth
  # In-repo packages from local source (editable)
  python3 -m pip install -e ../models
  python3 -m pip install -e .
  ```
* Create a .env file

  ```
  G2P_BRIDGE_DB_DBNAME='bridgedb'
  G2P_BRIDGE_DB_HOSTNAME='localhost'
  G2P_BRIDGE_DB_PASSWORD='password'
  G2P_BRIDGE_DB_PORT='5432'
  G2P_BRIDGE_DB_USERNAME='bridgeuser'
  G2P_BRIDGE_WORKER_TYPE='gunicorn'
  G2P_BRIDGE_HOST='0.0.0.0'
  G2P_BRIDGE_PORT='8000'
  G2P_BRIDGE_NO_OF_WORKERS=1
  ```
* Migrate the database schema

  ```
  python3 main.py migrate; 
  ```
* Run the API server on `127.0.0.1:8000`

  ```
  gunicorn "main:app" --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:8000
  ```

{% endtab %}

{% tab title="Bridge Celery Beat" %}
**Setting up the Bridge Celery Beat**

* Make a new Python virtual environment.

  ```bash
  cd g2p-bridge/core/celery-beat-producers
  python3 -m venv venv
  ```
* Activate the virtual environment.

  ```bash
  source venv/bin/activate
  ```
* Use `pip` to install the required Python packages, including the core libraries for the G2P Bridge.

  ```bash
  # External OpenG2P libs from PyPI
  python3 -m pip install openg2p-fastapi-common openg2p-fastapi-auth
  # In-repo packages from local source (editable)
  python3 -m pip install -e ../models -e ../../extensions/bank-connectors
  python3 -m pip install -e .
  ```
* Create a .env file

  ```
  G2P_BRIDGE_CELERY_BEAT_MAPPER_RESOLVE_API_URL='http://spar-mapper-api/sync/resolve' # Update the Spar Mapper Resolve URL
  G2P_BRIDGE_CELERY_BEAT_DB_HOSTNAME='localhost'
  G2P_BRIDGE_CELERY_BEAT_DB_PASSWORD='password'
  G2P_BRIDGE_CELERY_BEAT_CELERY_BROKER_URL='redis://127.0.0.1:6379/0'
  G2P_BRIDGE_CELERY_BEAT_CELERY_BACKEND_URL='redis://127.0.0.1:6379/0'
  G2P_BRIDGE_CELERY_BEAT_MAPPER_RESOLVE_FREQUENCY=60
  G2P_BRIDGE_CELERY_BEAT_FUNDS_AVAILABLE_CHECK_FREQUENCY=60
  G2P_BRIDGE_CELERY_BEAT_FUNDS_BLOCKED_FREQUENCY=60
  G2P_BRIDGE_CELERY_BEAT_FUNDS_DISBURSEMENT_FREQUENCY=60
  G2P_BRIDGE_CELERY_BEAT_MT940_PROCESSOR_FREQUENCY=60
  G2P_BRIDGE_CELERY_BEAT_PROCESS_FUTURE_DISBURSEMENT_SCHEDULES=true
  ```
* Run redis-server

  ```bash
  sudo systemctl start redis
  ```
* Run the celery beat

  ```bash
  celery -A main.celery_app worker --beat --loglevel=info
  ```

{% endtab %}

{% tab title="Bridge Celery Worker" %}
**Setting up the Bridge Celery Worker**

* Make a new Python virtual environment.

  ```bash
  cd g2p-bridge/core/celery-workers
  python3 -m venv venv
  ```
* Activate the virtual environment.

  ```bash
  source venv/bin/activate
  ```
* Use `pip` to install the required Python packages, including the core libraries for the G2P Bridge.

  ```bash
  # External OpenG2P libs from PyPI
  python3 -m pip install openg2p-fastapi-common openg2p-fastapi-auth
  # In-repo packages from local source (editable)
  python3 -m pip install -e ../models -e ../../extensions/bank-connectors
  python3 -m pip install -e .
  ```
* Create a .env file

  ```
  G2P_BRIDGE_CELERY_WORKERS_MAPPER_RESOLVE_API_URL='http://mapper/sync/resolve'
  G2P_BRIDGE_CELERY_WORKERS_MAPPER_RESOLVE_RETRY_DELAY=5
  G2P_BRIDGE_CELERY_WORKERS_DB_DBNAME='bridgedb'
  G2P_BRIDGE_CELERY_WORKERS_DB_USERNAME='bridgeuser'
  G2P_BRIDGE_CELERY_WORKERS_DB_PASSWORD='password'
  G2P_BRIDGE_CELERY_WORKERS_DB_HOSTNAME='localhost'
  G2P_BRIDGE_CELERY_BEAT_BANK_FA_DECONSTRUCT_STRATEGY='^account_number:(?P<account_number>.*)\.branch_code:(?P<branch_code>.*)\.bank_code:(?P<bank_code>.*)\.mobile_number:(?P<mobile_number>.*)\.email_address:(?P<email_address>.*)\.fa_type:(?P<fa_type>.*)$'
  G2P_BRIDGE_CELERY_BEAT_MOBILE_WALLET_DECONSTRUCT_STRATEGY='^mobile_number:(?P<mobile_number>.*)\.wallet_provider_name:(?P<wallet_provider_name>.*)\.wallet_provider_code:(?P<wallet_provider_code>.*)\.fa_type:(?P<fa_type>.*)$'
  G2P_BRIDGE_CELERY_BEAT_EMAIL_WALLET_DECONSTRUCT_STRATEGY='^email_address:(?P<email_address>.*)\.wallet_provider_name:(?P<wallet_provider_name>.*)\.wallet_provider_code:(?P<wallet_provider_code>.*)\.fa_type:(?P<fa_type>.*)$'
  G2P_BRIDGE_CELERY_PRODUCERS_FUNDS_AVAILABLE_CHECK_URL_EXAMPLE_BANK='http://127.0.0.1:8003/check_funds'
  G2P_BRIDGE_CELERY_PRODUCERS_FUNDS_BLOCK_URL_EXAMPLE_BANK='http://127.0.0.1:8003/block_funds'
  G2P_BRIDGE_CELERY_PRODUCERS_FUNDS_DISBURSEMENT_URL_EXAMPLE_BANK='http://127.0.0.1:8003/initiate_payment'
  G2P_BRIDGE_CELERY_WORKERS_CELERY_BROKER_URL='redis://127.0.0.1:6379/0'
  G2P_BRIDGE_CELERY_WORKERS_CELERY_BACKEND_URL='redis://127.0.0.1:6379/0'
  ```
* Run redis-server (if not already started)

  ```bash
  sudo systemctl start redis
  ```
* Run the celery beat

  ```bash
  celery -A main.celery_app worker -Q g2p_bridge_celery_worker_tasks --loglevel=info
  ```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.openg2p.org/products/g2p-bridge/development/developer-install/installing-openg2p-bridge-on-linux.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
