I'm developing a web application that will simulate personal finance for a family. In a simplified way it will simulate cash flow, checking account, investments on a financial market, inflation, insurance etc.
I've already developed some basic PHP classes from the scratch to perform the functionality demonstration for other members of our team. Now I'm about to start with the development of UI and real data scheme for the simulation.
I've chosen a Yii framework which seem pretty amazing to me! Yet I've no experience with PHP frameworks so far (I just did some coding in Visual C# in the past). After reading Yii tutorials and guides I think I have a basic idea about Yii concepts. I'm just not sure where to put the classes with the main simulation logic. Most of the simulation objects are not stored in the database yet from the MVC point of view they should belong to model. To not to begin the development at the wrong end I'd like to ask you for some hints.
Let me give you a brief overview of some of the basic classes/interfaces that are part of the simulation:
- class Simulation - Loads and stores all components of the simulation.
- class PeriodicalActivityController - Keeps record of all objects that do something on a monthly basis and calls onNextMonth() method of these objects.
- interface IPeriodicallyActive - Interface for objects with onNextMonth() method.
- interface IValuable - Interface for objects that could be valued in dollars by getValue() method.
- class Family implements IPeriodicallyActive - Definition of income, expenses, etc.
- class Portfolio implements IValuable - Holds financial products (securities, insurance, etc.), specifies checking account etc.
- class Security implements IValuable, IPeriodicallyActive - Securities defined by Quantity and Price, could be purchased or sold, pays dividend or interest.
- class Maket implements IPeriodicallyActive - Holds market prices for securities.
- class PortfolioManagement implements IPeriodicallyActive - Class that executes purchase/sell orders according to the specified allocation. It also runs automatic investments.
There is more but these should be sufficient to give you an idea about the design of the simulation. There will two major ways of how the Simulation is used:
1) The first one is that user sets the portfolio allocation (percentage of stocks/bonds/cash) and clicks on "Next Month/Year" and the Simulation takes this instruction and moves to the next month or repeats itself as many times as the user doesn't make any change to the portfolio allocation.
2) The other one is the automatic run in which the portfolio allocation is adjusted by the automatic strategy. This should serve as a benchmark to which the user's strategy is compared.
Basic inputs and outputs of each round will be stored to DB (and loaded from it) however the rest of the Simulation classes are quite independent.
Would you have any suggestions how to fit these simulation classes into the Yii framework? Or just let me know, please, if you know about any similar open source Yii app that I could get inspired from.