I have a single web server that runs several web applications and websites. For simplicity, we will only say that I have applications A, B, C and websites D and E. They all use a shared database and some tables are used in more than one application / site.
I am at a point where I am considering restructuring much of this code, but I am trying to find a pattern that allows me to keep as much code as possible in one place and I am looking for a Pattern to do it.
Almost all applications are MVC (some inherited are not, but independently). Some applications A and B may have the same model (linked to the same table) but implemented differently with different and similar methods.
I had the idea of simply creating a common API that all the applications / websites would use, so that the API could serve as my type "model" and the applications / websites will be executed through the API.
The disadvantage I see in doing that is that I need security groups in my MVC application to control things there, and security group things in my API, which seem cumbersome. I have also thought about using an API for things, but in my MVC applications, make the models are abstractions of the components used for the API.
At the moment I have similar functions / methods in different applications, which is a headache, of course, but I'm trying to improve it. Are there common models for when an application uses its own API and security is shared between the two?