Editing Offline Map with my Own API

Good afternoon

I need help or some suggestions regarding a specific task.
I need to work in an offline file because I have sensitive data that cannot be uploaded to the OpenStreetMap database (such as streets of private companies).
My initial idea was the following: make an API where, when receiving a lat and lng vector, I identify which segment is closest to it, and insert it into the way to be considered an intersection and be able to perform routing to obtain distance /duration of that route.
However, currently I have a small problem, when working with “light” files, my API worked normally, but when trying to work with large .osm files (files of, for example, 5-10gb), Node returns an error due to the fact that the file be very big.
I tried to implement a stream solution (reading the file in parts) and I’m having some difficulties.
Would you have any suggestions on the best way to do what I want?

It’s possible to setup the main OSM stack and use normal OSM tools but point them to your own private OSM system. It’s possible to import the data and edit it locally. I’ve done it in the past for specific projects.

Note that the data license requires sharing back anything that is current.

My question would be more about the existence of an API where I can insert new coordinates into an .OSM file, as I am currently doing “my own”, where for example I perform calculations to identify the next segment to insert the new node in the existing road to create an intersection and make it possible to route from point X to Y

Image below: