This is our current project structure for the project called "medics-interface-engine"
This project mainly acts as an intermediatery applications which will be communicating between two different softwares
We have an hims software called medics, we have different clients and they want to integrate the clinical or finaincial or inventory related data to their respective software acconts like netsuite, tally, etcc.
Now one client came with a requirement for the integration with the Oracle Fusion integration for their financial and inventory transactions

we have already integrations with netsuite, zoho, etc..

The problem we are facing with is scalability
Currently our hims application will support a certain no of transactions
if same transaction wanted to be interfaced by multiple interfaces then currently we dont have an option to do that.
Currently every model is hardcoded with the filed level information of the integration it required.
which is not correct.
Now we got this scenario.
So, we want to re architect this medics-interface-engine application.
We are planning to have multiple mongodb databses.
One for the original transaction and another for the respective integration.
For example we are interfacing Invoice Transaction to Netsuite and Oracle Fusion, we will have three data bases one is the original database and other two are Netsuite and Oracle Fusion
In the respective integration dabase we will have a collection for the respective transactions eg., (Invoice), there we will save the transformed data according to that particular integration.

So this is the design we came up with

Lets see for one sample transactions Invoice
Invoice Model will not change, it remains the base
We will be having a base invoice engine which will be pulling the records from medics.
then once the transaction is pulled the respective triggers will start their job.
Like based on some configuration lets say we have a oracle trigger, as soon as an entry came to base invoice then this oracle trigger will pick that one and check through some configurations whether this invoice or transactions required to process to oracle. if so then do the pre processing, validation, transformation etc.. using the existing interfaces or we need to create if required new and then save that in the invoice collection of the oracle fusion database and send to the oracle for the processing.
and the status should be updated back to the document in the oracle db also we need to update the base transaction in the main databse with some filed saying that this transaction is processed by oracle ,status is success or failure with some reference id


Existing folder structure:

├── README.txt
├── adapters
│   ├── README.txt
│   ├── hl7Adapter
│   │   ├── hl7Adapter.js
│   │   └── mirth
│   │       └── mirth-client.js
│   ├── index.js
│   ├── netsuite 
│   │   ├── OAuth_README.txt
│   │   ├── engines
│   │   │   ├── customer-deposit
│   │   │   │   ├── customer-deposit-engine.js
│   │   │   │   ├── customer-deposit-interface.js
│   │   │   │   ├── customer-deposit-transformer.js
│   │   │   │   └── customer-deposit-utils.js
│   │   │   ├── index.js
│   │   │   ├── invoice
│   │   │   │   ├── invoice-engine.js
│   │   │   │   ├── invoice-interface.js
│   │   │   │   ├── invoice-transformer.js
│   │   │   │   ├── item-fulfillment-interface.js
│   │   │   │   ├── item-fulfillment-transformer.js
│   │   │   │   ├── sales-order-interface.js
│   │   │   │   └── sales-order-transformer.js
│   │   │   ├── utils
│   │   │   │   ├── constants.js
│   │   │   │   ├── custom-field-handler-utils.ts
│   │   │   │   ├── custom-field-handler.js
│   │   │   │   ├── custom-transaction-factory-interface.ts
│   │   │   │   ├── custom-transform-map-factory-interface.ts
│   │   │   │   ├── id-mapper-document-types.js
│   │   │   │   ├── netsuite-transaction-factory.js
│   │   │   │   └── netsuite-transform-map-factory.js
│   │   │   └── vendor-return
│   │   │       ├── vendor-return-engine.js
│   │   │       ├── vendor-return-interface.js
│   │   │       └── vendor-return-transformer.js
│   │   ├── netsuite-OAuth.js
│   │   ├── netsuite-client.js
│   │   ├── netsuite-connection-test.js
│   │   └── policy-constants.js
│   └── zoho
│       ├── token.json
│       └── zoho-client.js
├── config.json
├── core
│   ├── models
│   │   ├── Advance.js
│   │   ├── Allergy.js
│   │   ├── Appointment.js
│   │   ├── Bill.js
│   │   ├── ChargeGroup.js
│   │   ├── IdMap.js
│   │   └── index.js
│   ├── routes.js
│   ├── services
│   │   ├── advance-service.js
│   │   ├── allergy-service.js
│   │   ├── appointment-service.js
│   │   ├── bill-service.js
│   │   ├── chief-complaint-service.js
│   │   ├── converted-lead-service.js
│   └── utils
│       ├── data-transformer.js
│       
├── engines
│   ├── appointment
│   │   └── appointment-engine.js

├── mdx.js
├── medics-engine.js
├── medics-interface-engine.config.js
├── package.json
├── projects
│   ├── nabidh
│   │   ├── discharge-summary
│   │   │   ├── discharge-summary-engine.js
│   │   │   ├── discharge-summary-interface.js
│   │   │   └── discharge-summary-transformer.js
│   │   ├── utils
│   │   │   ├── id-mapper-document-types.js
│   │   │   ├── transform-map-factory.js
│   │   │   └── utils.js
│   │   └── visit
│   │       ├── visit-engine.js
│   │       ├── visit-interface.js
│   │       └── visit-transformer.js
│   ├── nova
│   │   ├── appointment
│   │   │   ├── appointment-engine.js
│   │   │   ├── appointment-interface.js
│   │   │   └── appointment-transformer-zoho.js
│   │   └── engines
│   │       ├── nova-crm-config.js
│   │       └── nova-crm-interface-engine.js
│   └── seh
│       ├── docs
│       │   └── NetSuite Integration Go-Live Steps-v0.xlsx
│       └── engines
│           ├── seh-custom-handler.ts
│           ├── seh-financial.js
│           ├── seh-interface-config.js
│           ├── seh-interface-crm.js
│           ├── seh-inventory.js
│           ├── seh-main-bills.js
│           └── seh-retail-bills.js
├── routes.js
├── start-nabidh-mdx-engines.sh
├── start_medics_engine.sh
├── tsconfig.json
└── utils
    └── utils.js