We have multiple web applications which use the same calculations in them. These calculations take some parameters, but also use figures from a database that the user doesn't see.
In each project, we have duplicate code for the calculations and also duplicate data and tables in all of the databases. What I'd like to have is a centralized place where all the calculations and data lives, then each project can consume it.
This would be split into two projects, one for the data access and one for the calculations logic.
I thought about having a class library that we could build into a package that each project could consume like a NuGet package. I haven't done this before, so I'm not sure if having multiple projects or a database connection makes this the wrong approach? The other concern is that I'd only want to expose interfaces, how do people resolve their dependencies in packages so that the implementation is not exposed?
Or does it sound like it would be more ideal to build a web API for each project to consume?
I greatly appreciate any explanations for what the best approach is and the reasons for that.