How to design a backend API for a chat application using Node.js, Express.js, and MongoDB? [closed]

I am new to backend development and recently started learning Node.js. I’m working on a chat application and plan to use Node.js with Express.js and MongoDB as the backend. Since I’m still learning, I want to understand how to structure the backend API for managing users, messages, and real-time interactions.

Some specific points I need guidance on:

  1. How should I structure the endpoints for sending and receiving messages between users?
  2. What is the best way to handle user authentication and session management?
  3. What would be a good database schema for storing users, chat rooms, and messages in
    MongoDB?

Any advice or examples would be greatly appreciated!