refactor chat_server.rb and dependencies