**CONTEXT**:  

I am currently developing the front-end/ client of a simple browser game using HTML5 Canvas/JavaScript. In the future, I would like to add a multi-player dimension to it, most likely using node.js/mongoDB. At this point, however, I have no experience whatsoever with the required back-end technologies.

**DESIRED OUTCOME**:  

The game involves some simple interactions (e.g. collect a key; once you've collected it, you can open the door, etc.). In the multi-player mode, the outcomes of said interactions carried out by any player are supposed to affect the game state for all players (e.g. if any player has opened the door, it stays open for all players). This will likely require setting up a database.

**QUESTION:**   

At what point do I need to start writing the code in a way which involves referencing a database?   

Does it make any sense at all to first develop the "game logic" in JavaScript only (as if it was only meant to be played as a single player) and only afterwards proceed to rewriting the code referencing a database?

Apologies if my question sounds idiotic. Newbie here!