As Cliff Rowley mentioned, you question is far too vague but I'll try to provide some input as far as I can help.
You can use Codemirror (https://github.com/codemirror/CodeMirror) for defining the editor since it's one of the most popular in-browser code editor which is used by Codepen.
For realtime apps, you can make use Socket.io (http://socket.io/).
For storing data, you can use realtime services like PubNub (http://www.pubnub.com/) or Firebase (http://firebase.com/).
If you want to resolve the concurrency, you can have a look at Google docs and try to emulate how they solve that problem.
Hope this helps :)