Merge design_ui_v2 into design_ui so the new design system can be previewed without dropping later product work.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 16:46:00 +03:30
co-authored by Cursor
87 changed files with 6722 additions and 5040 deletions
+41
View File
@@ -0,0 +1,41 @@
# Preview — copy to /var/www/crm2/apps/api/.env
# Start from production crm .env, then change only the keys below.
NODE_ENV=production
PORT=3032
CORS_ORIGIN=https://crm2.montzar.ir
JWT_SECRET=change-me-long-random-production-secret
JWT_EXPIRES_IN=7d
# Separate database — do not point this at mento_crm
DATABASE_URL="postgresql://mento:CHANGE_ME@127.0.0.1:15432/mento_crm2?schema=public"
UPLOAD_DIR=/var/www/crm2/uploads
PORTAL_SHOW_OTP=false
AUTH_RETURN_OTP=false
AUTH_EMAIL_OTP_ENABLED=false
# Copy SMS / AI / STT / encryption keys from /var/www/crm/apps/api/.env
SMS_PROVIDER=trez
SMS_USERNAME=
SMS_PASSWORD=
SMS_SENDER=
SMS_BASE_URL=http://smspanel.Trez.ir
SMS_SEND_PATH=/SendMessageWithCode.ashx
SMS_OTP_TEMPLATE=کد ورود پرتال منتکت: {code}
AI_ENABLED=true
AI_PROVIDER=openai
AI_BASE_URL=https://api.gapgpt.app/v1
AI_API_KEY=change-me
AI_MODEL=gpt-4o-mini
AI_TIMEOUT_MS=45000
# Share the existing STT sidecar (do not start a second one)
STT_ENABLED=true
STT_URL=http://127.0.0.1:3040
STT_INTERNAL_TOKEN=change-me-stt-internal-token
STT_TIMEOUT_MS=60000
INTEGRATIONS_ENCRYPTION_KEY=change-me-64-hex-chars-use-openssl-rand-hex-32
+104
View File
@@ -0,0 +1,104 @@
# پیش‌نمایش دیزاین — `crm2.montzar.ir`
نسخهٔ دوم کنار پروداکشن. **به `/var/www/crm`، `mento-crm-api`، پورت `3030` و دیتابیس `mento_crm` دست نزنید.**
| | پروداکشن | پیش‌نمایش |
|---|---|---|
| دامنه | `crm.montzar.ir` | `crm2.montzar.ir` |
| مسیر | `/var/www/crm` | `/var/www/crm2` |
| برنچ | `main` | `design_ui` |
| پورت API | `3030` | `3032` |
| PM2 | `mento-crm-api` | `mento-crm2-api` |
| دیتابیس | `mento_crm` | `mento_crm2` |
| STT | `mento-stt` روی `3040` | همان را share کنید |
بروزرسانی پروداکشن همچنان فقط بلوک قفل‌شده در `deploy/DEPLOY.md` است.
---
## قبل از سرور
1. DNS: رکورد `A` برای `crm2.montzar.ir` همان IP پروداکشن (`185.50.38.53`) — مثل `crm.montzar.ir`.
2. اول `design_ui` را push کنید، بعد کلون/پول روی سرور.
---
## بار اول روی سرور
```bash
ssh -p 3031 montime@185.50.38.53
sudo mkdir -p /var/www/crm2
sudo chown montime:montime /var/www/crm2
git clone --branch design_ui http://get.feep.ir/Mahdi/CRM_Montzar.git /var/www/crm2
# دیتابیس جدا (خالی امن‌تر است؛ برای دادهٔ شبیه پروداکشن dump بگیرید)
# CREATE DATABASE mento_crm2 OWNER mento;
# اختیاری:
# pg_dump -p 15432 -d mento_crm | psql -p 15432 -d mento_crm2
cp /var/www/crm/apps/api/.env /var/www/crm2/apps/api/.env
nano /var/www/crm2/apps/api/.env
```
در `.env` فقط این‌ها را عوض کنید:
```text
PORT=3032
CORS_ORIGIN=https://crm2.montzar.ir
DATABASE_URL="postgresql://USER:PASS@127.0.0.1:15432/mento_crm2?schema=public"
UPLOAD_DIR=/var/www/crm2/uploads
```
`STT_URL` را روی `http://127.0.0.1:3040` بگذارید. `mento-stt` را دوباره start نکنید.
وابستگی‌ها (کپی از پروداکشن تا `npm ci` لازم نباشد):
```bash
cp -a /var/www/crm/node_modules /var/www/crm2/
rm -rf /var/www/crm2/node_modules/@mento/shared
ln -s ../../packages/shared /var/www/crm2/node_modules/@mento/shared
chmod +x /var/www/crm2/node_modules/.bin/*
find /var/www/crm2/node_modules -path '*esbuild*' -name 'esbuild' -type f -exec chmod +x {} \;
```
بیلد و migrate **فقط روی crm2**:
```bash
cd /var/www/crm2
npm run build -w @mento/shared
cd apps/api && npx prisma migrate deploy && npx prisma generate && cd ../..
npm run build -w @mento/api
npm run build -w @mento/web
mkdir -p uploads
pm2 start /var/www/crm2/deploy/ecosystem-crm2.config.cjs
pm2 save
curl -sI http://127.0.0.1:3032/api/health
sudo cp /var/www/crm2/deploy/nginx-crm2.montzar.ir.conf /etc/nginx/sites-available/crm2.montzar.ir
sudo ln -sf /etc/nginx/sites-available/crm2.montzar.ir /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
```
vhost را HTTP :80 نگه دارید (پروکسی جلویی SSL را تمام می‌کند). Certbot روی این باکس نزنید.
---
## آپدیت بعدی پیش‌نمایش (بعد از push روی `design_ui`)
```bash
ssh -p 3031 montime@185.50.38.53
cd /var/www/crm2
git fetch origin
git checkout design_ui
git pull origin design_ui
npm run build -w @mento/shared
cd apps/api && npx prisma migrate deploy && npx prisma generate && cd ../..
npm run build -w @mento/api
npm run build -w @mento/web
pm2 restart mento-crm2-api
```
`pm2 restart mento-crm-api` نکنید. `cd /var/www/crm` نکنید.
+26
View File
@@ -0,0 +1,26 @@
/**
* PM2 — Mento CRM preview (crm2.montzar.ir)
* Port 3032. Does not start STT; reuse mento-stt on 3040.
*
* pm2 start /var/www/crm2/deploy/ecosystem-crm2.config.cjs
* pm2 save
*
* Never restart mento-crm-api from this file.
*/
module.exports = {
apps: [
{
name: "mento-crm2-api",
cwd: "/var/www/crm2/apps/api",
script: "dist/src/main.js",
instances: 1,
exec_mode: "fork",
env: {
NODE_ENV: "production",
PORT: "3032",
},
max_memory_restart: "600M",
time: true,
},
],
};
+35
View File
@@ -0,0 +1,35 @@
# Preview instance — crm2.montzar.ir
# Place under /etc/nginx/sites-available/crm2.montzar.ir
# HTTP only (same as crm): front proxy terminates SSL.
#
# Do not replace crm.montzar.ir / adm / ktg / montime vhosts.
upstream mento_crm2_api {
server 127.0.0.1:3032;
keepalive 8;
}
server {
listen 80;
listen [::]:80;
server_name crm2.montzar.ir;
client_max_body_size 50M;
root /var/www/crm2/apps/web/dist;
index index.html;
location /api/ {
proxy_pass http://mento_crm2_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 120s;
}
location / {
try_files $uri $uri/ /index.html;
}
}