Skip to content

Commit

Permalink
GITBOOK-1229: SPAR & Bridge Installation Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahzeer authored and gitbook-bot committed Jan 10, 2025
1 parent 1d190b6 commit a009265
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 213 deletions.
54 changes: 27 additions & 27 deletions g2p-bridge/development/developer-install/example-bank.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ sudo apt upgrade -y

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

```

3\. Install and configure PostgreSQL

* G2P Bridge requires PostgreSQL as the database engine. Install PostgreSQL and create a new database user for G2P Bridge.
* 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
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt bankuser
CREATE ROLE bankuser WITH LOGIN NOSUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD 'password';
CREATE DATABASE bankdb WITH OWNER = bankuser CONNECTION LIMIT = -1;
exit
```

Expand All @@ -59,7 +59,7 @@ sudo apt install -y python3-pip python3-dev build-essential

* Make a new Python virtual environment.

```
```bash
cd openg2p-g2p-bridge/openg2p-g2p-bridge-example-bank-api
python3 -m venv venv
```
Expand All @@ -72,29 +72,29 @@ sudo apt install -y python3-pip python3-dev build-essential

```bash
python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-g2p-bridge-example-bank-models==1.0.0 \
openg2p-g2p-bridge-example-bank-api==1.0.0
```
* Update the .env
* Create a .env file

```
EXAMPLE_BANK_DB_HOSTNAME: localhost
EXAMPLE_BANK_DB_DBNAME: example_bank_db
EXAMPLE_BANK_DB_USERNAME: bankuser
EXAMPLE_BANK_DB_PASSWORD: password
EXAMPLE_BANK_CELERY_BROKER_URL: redis://127.0.0.1:6379/0
EXAMPLE_BANK_CELERY_BACKEND_URL: redis://127.0.0.1:6379/0
EXAMPLE_BANK_DB_HOSTNAME='localhost'
EXAMPLE_BANK_DB_DBNAME='bankdb'
EXAMPLE_BANK_DB_USERNAME='bankuser'
EXAMPLE_BANK_DB_PASSWORD='password'
EXAMPLE_BANK_CELERY_BROKER_URL='redis://127.0.0.1:6379/0'
EXAMPLE_BANK_CELERY_BACKEND_URL='redis://127.0.0.1:6379/0'
```
* Migrate the database schema

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

```
```bash
gunicorn "main:app" --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:8000
```
{% endtab %}
Expand All @@ -104,7 +104,7 @@ sudo apt install -y python3-pip python3-dev build-essential

* Make a new Python virtual environment.

```
```bash
cd openg2p-g2p-bridge/openg2p-g2p-bridge-example-bank-celery
python3 -m venv venv
```
Expand All @@ -117,26 +117,26 @@ sudo apt install -y python3-pip python3-dev build-essential

```bash
python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-g2p-bridge-example-bank-models==1.0.0 \
openg2p-g2p-bridge-example-bank-celery==1.0.0
```
* Run redis-server
* Run redis-server (if not already started)

```
bash sudo systemctl start redis
```
* Update the .env
* Create a .env file

```
EXAMPLE_BANK_CELERY_DB_HOSTNAME: localhost
EXAMPLE_BANK_CELERY_DB_DBNAME: example_bank_db
EXAMPLE_BANK_CELERY_DB_USERNAME: bankuser
EXAMPLE_BANK_CELERY_DB_PASSWORD: password
EXAMPLE_BANK_CELERY_CELERY_BROKER_URL: redis://127.0.0.1:6379/0
EXAMPLE_BANK_CELERY_CELERY_BACKEND_URL: redis://127.0.0.1:6379/0
EXAMPLE_BANK_CELERY_MT940_STATEMENT_CALLBACK_URL: http://openg2p-g2p-bridge-api/upload_mt940
EXAMPLE_BANK_CELERY_DB_HOSTNAME='localhost'
EXAMPLE_BANK_CELERY_DB_DBNAME='bankdb'
EXAMPLE_BANK_CELERY_DB_USERNAME='bankuser'
EXAMPLE_BANK_CELERY_DB_PASSWORD='password'
EXAMPLE_BANK_CELERY_CELERY_BROKER_URL='redis://127.0.0.1:6379/0'
EXAMPLE_BANK_CELERY_CELERY_BACKEND_URL='redis://127.0.0.1:6379/0'
EXAMPLE_BANK_CELERY_MT940_STATEMENT_CALLBACK_URL='http://openg2p-g2p-bridge-api/upload_mt940'
```
* Run the celery beat and worker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ sudo apt install -y python3-pip python3-dev build-essential

3\. Install and configure PostgreSQL

* G2P Bridge requires PostgreSQL as the database engine. Install PostgreSQL and create a new database user for G2P Bridge.
* 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
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt g2p_bridge_user
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
```

Expand All @@ -59,7 +60,7 @@ sudo apt install -y python3-pip python3-dev build-essential

* Make a new Python virtual environment.

```
```bash
cd openg2p-g2p-bridge/openg2p-g2p-bridge-api
python3 -m venv venv
```
Expand All @@ -72,25 +73,24 @@ sudo apt install -y python3-pip python3-dev build-essential

```bash
python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-g2pconnect-common-lib==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-g2pconnect-common-lib==1.0.0 \
openg2p-g2p-bridge-models==1.0.0 \
openg2p-g2p-bridge-api==1.0.0
```
* Update the .env
* Create a .env file 

```
G2P_BRIDGE_DB_DBNAME: openg2p_g2p_bridge_db
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'
G2P_BRIDGE_OPENAPI_ROOT_PATH: '/api/g2p-bridge'
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

Expand All @@ -109,7 +109,7 @@ sudo apt install -y python3-pip python3-dev build-essential

* Make a new Python virtual environment.

```
```bash
cd openg2p-g2p-bridge/openg2p-g2p-bridge-celery-beat-producers
python3 -m venv venv
```
Expand All @@ -122,35 +122,32 @@ sudo apt install -y python3-pip python3-dev build-essential

```bash
python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-g2pconnect-common-lib==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-g2pconnect-common-lib==1.0.0 \
openg2p-g2p-bridge-models==1.0.0 \
openg2p-g2p-bridge-bank-connectors==1.0.0 \
openg2p-g2p-bridge-celery-beat-producers==1.0.0
```
* Update the .env
* 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_BANK_FA_DECONSTRUCT_STRATEGY: ^account_number:(?P<account_number>.*)\.branch_code:(?P<branch_code>.*)\.bank_code:(?P<bank_code>.*)\.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_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
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
```bash
sudo systemctl start redis
```
* Run the celery beat

Expand All @@ -164,7 +161,7 @@ sudo apt install -y python3-pip python3-dev build-essential

* Make a new Python virtual environment.

```
```bash
cd openg2p-g2p-bridge/openg2p-g2p-bridge-celery-workers
python3 -m venv venv
```
Expand All @@ -177,35 +174,35 @@ sudo apt install -y python3-pip python3-dev build-essential

```bash
python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-g2pconnect-common-lib==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-g2pconnect-common-lib==1.0.0 \
openg2p-g2p-bridge-models==1.0.0 \
openg2p-g2p-bridge-bank-connectors==1.0.0 \
openg2p-g2p-bridge-celery-workers==1.0.0
```
* Update the .env
* 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: openg2p_g2p_bridge_db
G2P_BRIDGE_CELERY_WORKERS_DB_USERNAME: bridgeuser
G2P_BRIDGE_CELERY_WORKERS_DB_PASSWORD: password
G2P_BRIDGE_CELERY_WORKERS_DB_HOSTNAME: localhost
G2P_BRIDGE_CELERY_WORKERS_BANK_FA_DECONSTRUCT_STRATEGY: bank_(?P<account_number>\d+)_(?P<bank_code>\d+)_(?P<branch_code>\d+)_(?P<account_type>\w+)
G2P_BRIDGE_CELERY_WORKERS_MOBILE_WALLET_DECONSTRUCT_STRATEGY: mobile_(?P<mobile_number>\d+)_(?P<mobile_wallet_provider>\w+)
G2P_BRIDGE_CELERY_WORKERS_EMAIL_WALLET_DECONSTRUCT_STRATEGY: email_(?P<email_address>\w+)_(?P<email_wallet_provider>\w+)
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
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
* Run redis-server (if not already started)

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

Expand Down
53 changes: 31 additions & 22 deletions spar/development/developer-install/spar-mapper-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ description: >-

The following dependencies are managed in the installation steps below.

```sh
```
annotated-types==0.6.0
anyio==3.7.1
asyncio==3.4.3
Expand Down Expand Up @@ -81,16 +81,22 @@ websockets==12.0

### Steps to install

* Clone the repository
* Install dependencies

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

* Clone the repository&#x20;

```sh
git clone https://github.com/OpenG2P/openg2p-spar-mapper-api.git
```

* Navigate to the project root
* Navigate to the project root and switch to branch 1.0.0

```sh
cd openg2p-spar-mapper-api
cd openg2p-spar-mapper-api && git checkout 1.0.0
```

* Create a virtual environment with Python 3
Expand All @@ -113,8 +119,27 @@ pip install greenlet &&
pip install -e .
```

* Configure database credentials and other environment variables in the \`.env\` file
* [See Configuration section below](spar-mapper-api.md#configuration)
* Create a '.env' file and configure database
* Set the following environment variables to configure the \`spar-mapper-api\`:

```xml
# Application Port
SPAR_MAPPER_PORT='8007'

# Database credentials
SPAR_MAPPER_DB_HOSTNAME='localhost'
SPAR_MAPPER_DB_USERNAME='sparuser'
SPAR_MAPPER_DB_PASSWORD='password'
SPAR_MAPPER_DB_DBNAME='spardb'
```
* Database setup

```sql
CREATE ROLE sparuser WITH LOGIN NOSUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD 'password';
CREATE DATABASE spardb WITH OWNER = sparuser CONNECTION LIMIT = -1;
```


* &#x20;Run migrations to set up the database:

```sh
Expand All @@ -132,22 +157,6 @@ python main.py run
* Access Swagger API Documentation
* [http://localhost:8007/docs](http://localhost:8007/docs)

### Configuration

#### Environment Variables

Set the following environment variables to configure the \`spar-mapper-api\`:

```xml
# Application Port
SPAR_MAPPER_PORT='8007'

# Database credentials
SPAR_MAPPER_DB_HOSTNAME='localhost'
SPAR_MAPPER_DB_USERNAME='sparuser'
SPAR_MAPPER_DB_DBNAME='spardb'
```

### Testing

To run unit tests with `pytest`:
Expand Down
Loading

0 comments on commit a009265

Please sign in to comment.