45 lines
1.1 KiB
Markdown
45 lines
1.1 KiB
Markdown
# FitAI Realtime Service
|
|
|
|
Socket.IO service for gym room and trainer-client chat.
|
|
|
|
## Setup
|
|
|
|
1. Copy env template:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
2. Fill required values in `.env` (`CLERK_SECRET_KEY` at minimum).
|
|
|
|
3. Build dependencies from monorepo root (if needed) and run:
|
|
|
|
```bash
|
|
npm --prefix packages/database run build
|
|
npm --prefix apps/realtime run dev
|
|
```
|
|
|
|
For production:
|
|
|
|
```bash
|
|
npm --prefix apps/realtime run build
|
|
npm --prefix apps/realtime run start
|
|
```
|
|
|
|
## Required environment variables
|
|
|
|
- `CLERK_SECRET_KEY`: verifies client session token in socket handshake.
|
|
- `REALTIME_CORS_ORIGIN`: comma-separated client origins.
|
|
|
|
## Recommended environment variables
|
|
|
|
- `REDIS_URL`: enables Socket.IO Redis adapter and distributed rate limiting.
|
|
- `FITAI_DATABASE_PATH` or `DATABASE_PATH`: explicit DB path.
|
|
- `REALTIME_PORT`: server port (default `3001`).
|
|
- `REALTIME_SOCKET_PATH`: Socket.IO path (default `/socket.io`).
|
|
|
|
## Notes
|
|
|
|
- If `REDIS_URL` is missing, service still works with single-instance in-memory rate limits.
|
|
- Database path resolution falls back to shared `apps/admin/data/fitai.db` when available.
|