I started making an engine for HTML5 games. Soon, I got interested in another project, basically, an evolution simulation. The simulation would be ran on the server, but the actual rendering would take place on the client side. I realized that I could use most of my classes and code from the game engine on the server side, too.
Now, I'm not sure what should I do. I have the option of creating a "monolithic engine", which would have both the specific functionality and universal functionality for both sides. Or, I could create a separate "game engine", and use it to render the simulation and make games, and a separate "simulation engine" that has simulation specific functionality.
The monoluthic approach has the problem of keeping the code in codebase too big and unrelated, while the separate approach has the problem of having same classes in both code bases.
How can I handle this situation?
If it changes anything, I'm coding in Javascript.
Sounds like you need to isolate what you feel is the common functionality between the two usages and extract those pieces into its own library, I'll call it "engine core". Then you'd basically have 3 things: "game engine", "simulation engine" and "engine core". Game engine and simulation engine would both reference engine core, so whenever you make an update to a piece of engine core, both game engine and simulation engine will receive the updates. How this is implemented exactly would depend on the language you're using, but the idea would be the same.