Write python code to Build a WebSocket chat API with message validation using Flask-SocketIO. accepts WebSocket connections; validates and sanitizes messages; broadcasts to room; stores message history. Structure the project as: app/, routes/chat.py, handlers/socket_handler.py. Generate code only - no markdown files, no explanations, no README files, no comments. Keep output concise and purpose-ready.