# Chat Application (backend scaffold)

This workspace contains the backend scaffold for a real-time chat application.

Quick start:

1. copy `api/.env.example` to `api/.env` and fill values
2. cd `api` and install dependencies

```bash
cd api
npm install
npm run start
```

The server will create the configured database (if missing) and apply migrations.

Deployment notes:

- Use `pm2 start pm2.config.js` inside `/api` to run the server in cluster mode.
- Build the client with `cd client && npm install && npm run build`, then serve `client/dist` via Nginx.
- Use the provided Nginx example at `deploy/nginx_chat_example.conf` and enable SSL with Certbot.

For scaling sockets across multiple nodes, enable Redis adapter in Socket.IO and set up a Redis server. See `services/socket.js` comments.
