From fbf30471f06890d471c029fba4994b17533b853c Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 6 Oct 2025 06:49:17 -0400 Subject: [PATCH] Added event composer --- core_composer/Dockerfile | 26 ++++ core_composer/docker-compose.yml | 7 +- core_composer/entrypoint.sh | 8 + core_composer/requirements.txt | 45 ++++++ event_composer/.env.event | 28 ++++ event_composer/docker-compose.yml | 33 ++++ event_composer/openapi.yml | 251 ++++++++++++++++++++++++++++++ product/.env.core | 2 +- 8 files changed, 396 insertions(+), 4 deletions(-) create mode 100644 core_composer/Dockerfile create mode 100644 core_composer/entrypoint.sh create mode 100644 core_composer/requirements.txt create mode 100644 event_composer/.env.event create mode 100644 event_composer/docker-compose.yml create mode 100644 event_composer/openapi.yml diff --git a/core_composer/Dockerfile b/core_composer/Dockerfile new file mode 100644 index 0000000..2370abf --- /dev/null +++ b/core_composer/Dockerfile @@ -0,0 +1,26 @@ +# Use an official Python runtime as a parent image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Expose port 5000 for the Flask app +EXPOSE 5000 + +# Set environment variables +ENV FLASK_APP=app.py +ENV FLASK_RUN_HOST=0.0.0.0 + +CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "--timeout", "120", "wsgi:wsgi_app"] + +#RUN exec gunicorn -w 4 -b 0.0.0.0:5000 wsgi:wsgi_app + +#RUN chmod +x entrypoint.sh +# +#ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/core_composer/docker-compose.yml b/core_composer/docker-compose.yml index 584c78d..87f1651 100644 --- a/core_composer/docker-compose.yml +++ b/core_composer/docker-compose.yml @@ -1,8 +1,8 @@ services: digifi-core: image: "registry.simbrellang.net/digifi/banktoproductcore:latest" - build: - dockerfile: Dockerfile +# build: +# dockerfile: Dockerfile env_file: - .env.core ports: @@ -10,9 +10,10 @@ services: environment: - FLASK_APP=wsgi.py - FLASK_ENV=production - #- DATABASE_URL=postgresql+psycopg2://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} + - SQLALCHEMY_DATABASE_URI_FULL="oracle+oracledb://FIRSTADVSTG:Pchanged_56789@10.2.110.30:1521/?service_name=firstadv" volumes: - .:/app + #network_mode: "host" # Uses the host's network restart: always diff --git a/core_composer/entrypoint.sh b/core_composer/entrypoint.sh new file mode 100644 index 0000000..9a12075 --- /dev/null +++ b/core_composer/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# echo "Running DB migrations..." +# flask db migrate -m "Migration on $(date)" +# flask db upgrade + +echo "Starting Gunicorn server..." +exec gunicorn -w 4 -b 0.0.0.0:5000 wsgi:wsgi_app diff --git a/core_composer/requirements.txt b/core_composer/requirements.txt new file mode 100644 index 0000000..81888de --- /dev/null +++ b/core_composer/requirements.txt @@ -0,0 +1,45 @@ +# Flask and Extensions +Flask==2.3.3 + +# Database +flask-sqlalchemy +flask-migrate +psycopg2-binary +alembic +oracledb + +# Schema for validations +Flask-Marshmallow==0.15.0 +marshmallow==3.19.0 + +# CORS +Flask-Cors==3.0.10 + +# Deployment +gunicorn + +# Swagger +flask-swagger-ui + + +# Env +python-dotenv + +# Requests +httpx + + +# JWT +flask-jwt-extended + + +# Kafka +confluent-kafka==1.9.2 + + + +python-dateutil + +Flask-Mail==0.10.0 +pandas==2.1.3 +openpyxl==3.1.5 \ No newline at end of file diff --git a/event_composer/.env.event b/event_composer/.env.event new file mode 100644 index 0000000..2287481 --- /dev/null +++ b/event_composer/.env.event @@ -0,0 +1,28 @@ + +APP_PORT=5000 +API_URL="/swagger.json" + +KAFKA_TIMEOUT=1000.0 +KAFKA_TOPICS="PROCESS_PAYMENT,LOAN_REPAYMENT" + +DATABASE_USER=FIRSTADVSTG +DATABASE_PASSWORD=Pchanged_56789 +DATABASE_HOST=ig-x6-uat-scan +DATABASE_PORT=1521 +DATABASE_NAME=FIRSTADVSTG +DATABASE_SID=firstadv +SQLALCHEMY_DATABASE_URI_FULL="oracle+oracledb://FIRSTADVSTG:Pchanged_56789@10.2.110.30:1521/?service_name=firstadv" + +KAFKA_BROKER="10.2.110.20:9092" + + +BANK_CALL_APP_ID="app1" +BANK_CALL_API_KEY="testtest-api-key-12345" + +BANK_CALL_BASE_URL="https://first-advance-middleware-develop.fbn-devops-dev-asenv.appserviceenvironment.net" +BANK_CALL_DISBURSE_LOAN_ENDPOINT="/api/DisburseLoan" +BANK_CALL_COLLECT_LOAN_ENDPOINT="/api/CollectLoan" +BANK_CALL_TRANSACTION_VERIFY="/api/TransactionVerify" + +FLASK_APP=wsgi.py +FLASK_ENV=development \ No newline at end of file diff --git a/event_composer/docker-compose.yml b/event_composer/docker-compose.yml new file mode 100644 index 0000000..ae27645 --- /dev/null +++ b/event_composer/docker-compose.yml @@ -0,0 +1,33 @@ +version: "3.8" + +services: + digifi-event: + image: "registry.simbrellang.net/digifi/eventmanager:latest" + build: . + env_file: + - .env.event + ports: + - "5000:5000" + environment: + - FLASK_APP=app.py + - FLASK_RUN_HOST=0.0.0.0 + volumes: + - .:/app + restart: always + networks: + - digital + + swagger: + image: swaggerapi/swagger-ui:v5.1.0 + ports: + - "9000:8080" + volumes: + - ./openapi.yml:/usr/local/openapi.yml + environment: + - SWAGGER_JSON=/usr/local/openapi.yml + restart: always + networks: + - digital +networks: + digital: + driver: bridge diff --git a/event_composer/openapi.yml b/event_composer/openapi.yml new file mode 100644 index 0000000..ac23bb9 --- /dev/null +++ b/event_composer/openapi.yml @@ -0,0 +1,251 @@ +openapi: 3.0.3 +info: + title: Event Manager API + description: The documentation for Event Manager API + version: 1.0.0 + contact: + name: API Support + email: support@example.com + license: + name: MIT + url: https://opensource.org/licenses/MIT + +servers: + - url: http://localhost:5000 + description: Local development server + - url: http://www.simbrellang.net:5000 + description: Remote Temporary development server + - url: https://event-core.simbrellang.net + description: Remote development server + +paths: + /health: + get: + summary: Returns a health message + responses: + 200: + description: A successful response + /status-call: + post: + summary: Perform a status call + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + requestId: + type: string + example: "R02802" + countryCode: + type: string + example: "NGR" + transactionId: + type: string + example: "Tr201712RK9232P115" + debtId: + type: string + example: "173021" + transactionType: + type: string + example: "Disbursement" + customerId: + type: string + example: "CN621868" + responses: + 200: + description: A successful response + /sms: + post: + summary: Send a SMS + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + text: + type: string + example: "This is a test message for SMS request method." + dest: + type: string + example: "+2348039409144" + unicode: + type: boolean + example: false + responses: + 200: + description: A successful response + /bulk-sms: + post: + summary: Send a bulk SMS + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: object + properties: + text: + type: string + example: "This is a test message for SMS request method." + dest: + type: string + example: "+2348039409144" + unicode: + type: boolean + example: true + responses: + 200: + description: A successful response + /autocall/refresh-verify-disbursement: + get: + summary: Refresh the disbursement to verify + responses: + 200: + description: A successful response + /autocall/refresh-disbursement: + get: + summary: Refresh the disbursement + responses: + 200: + description: A successful response + /autocall/refresh-verify-collection: + get: + summary: Refresh the disbursement to verify + responses: + 200: + description: A successful response + /autocall/refresh-collection: + get: + summary: Refresh the disbursement + responses: + 200: + description: A successful response + /autocall/payment-callback: + get: + summary: The Payment callback + responses: + 200: + description: A successful response + /autocall/penal-charge: + post: + summary: Penal Charge Request + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + type: object + properties: + transactionId: + type: string + example: "T004" + fbnTransactionId: + type: string + example: "Tr201712RK9232P115" + debtId: + type: string + example: "273194670" + customerId: + type: string + example: "CN621868" + accountId: + type: string + example: "2017821799" + penalCharge: + type: number + example: "1.2" + lienAmount: + type: number + example: "101.2" + countryId: + type: string + example: "01" + comment: + type: string + example: "Testing PenalCharge" + responses: + 200: + description: A successful response + /autocall/analytic-salary-detect: + post: + summary: Salary Detect Endpoint + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + customerId: + type: string + example: "CN621868" + accountId: + type: string + example: "OP621868" + status: + type: string + salaryAmount: + type: number + example: 200000 + salaryDate: + type: string + example: "2025-01-01" + responses: + 200: + description: A successful response + + /autocall/report: + get: + summary: Generate and send a report + responses: + 200: + description: A successful response + /autocall/overdue-loans: + get: + summary: Get all overdue loans + responses: + 200: + description: A successful response + /autocall/direct/loan: + post: + summary: Direct call for loan disbursement + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + transactionId: + type: string + example: "TXN123456" + responses: + 200: + description: A successful response + /autocall/direct/repayment: + post: + summary: Direct call for loan repayment + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + transactionId: + type: string + example: "TXN123456" + + responses: + 200: + description: A successful response + + \ No newline at end of file diff --git a/product/.env.core b/product/.env.core index bb6e29d..09a45d3 100644 --- a/product/.env.core +++ b/product/.env.core @@ -23,7 +23,7 @@ SQLALCHEMY_DATABASE_URI_FULL="oracle+oracledb://FIRSTADVSTG:Pchanged_56789@10.2. KAFKA_BROKER="10.2.110.20:9082" #Bank Calls ===================================================================== -SIMBRELLA_BASE_URL="https://bank-emulator.dev.simbrellang.net" +SIMBRELLA_BASE_URL="https://first-advance-middleware-develop.fbn-devops-dev-asenv.appserviceenvironment.net" SIMBRELLA_APP_ID="app1" SIMBRELLA_API_KEY="testtest-api-key-12345"