Replace ecm with own implementation

I wonder if it is possible to replace ecm by an own implementation for managing documents. Actually I would like to save all documents into a real document management system which can be accessed through a REST-API. At first glance I couldn’t identify any abstraction for accessing documents, but I may be wrong. What would be the best way to integrate a DMS?

Uwe