Files
tripz-llc/backend
HamzaandClaude Opus 4.8 f3383c3cf8 feat(security): field encryption AES-256-GCM + random IV (at-rest)
- common/crypto/crypto.util.ts: encrypt/decrypt (GCM, random 96-bit IV), format v1:base64(iv|tag|ct)
- EncryptedTransformer applied to users.name + drivers.vehicle_plate (auto, no service change)
- blindIndex (HMAC) helper for future searchable-field encryption (phone)
- tolerant decrypt for legacy plaintext → no migration needed (varchar holds base64)
- ENCRYPTION_KEY env + boot warning if unset; docs/16-encryption.md
- fixes Siro's documented CBC+fixed-IV flaw

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 19:24:27 +03:00
..

Tripz Backend — NestJS (Docker فقط)

لا تثبيت محلي على الماك. الكود يُكتب محلياً، والبناء والتشغيل والهجرات كلها داخل Docker على السيرفر.

التشغيل على السيرفر

cd backend
cp .env.example .env          # ثم عدّل كلمات المرور والأسرار
docker compose up -d --build  # يبني ويشغّل: postgres/postgis, redis, martin, api, worker

الهجرات (داخل حاوية الـ api)

docker compose exec api npm run migration:run

الهجرات تعمل على النسخة المترجمة dist/config/data-source.js (صورة الإنتاج بلا ts-node). لو ما رفعت آخر نسخة بعد، شغّل مباشرة: docker compose exec api node_modules/.bin/typeorm migration:run -d dist/config/data-source.js

فحص سريع

curl http://<server>:4010/api/health           # {"status":"ok",...}
# توثيق Swagger: http://<server>:4010/api/docs

العزل على السيرفر المشترك (راجع docs/14)

  • Postgres: قاعدة tripz، بادئة جداول tripz_ (مثال: tripz_tenants).
  • Redis: DB رقم 3 غير الافتراضي + بادئة مفاتيح tripz:.
  • منافذ مضيف غير قياسية (API 4010، Postgres 55432) لتفادي التصادم.
  • أسماء حاويات/شبكة/فوليوم ببادئة tripz-.

البنية الحالية (P0)

src/
├── main.ts                 # bootstrap API (+ Swagger)
├── worker.ts               # نقطة دخول BullMQ (هيكل)
├── app.module.ts           # ConfigModule + TypeORM(entityPrefix) + Throttler + TenantMiddleware
├── config/                 # configuration.ts + data-source.ts (هجرات)
├── common/
│   ├── tenant/             # context (AsyncLocalStorage) + middleware + @Tenant()
│   └── usage/              # UsageInterceptor (أساس الفوترة)
├── database/
│   ├── entities/           # tenant.entity.ts
│   └── migrations/         # InitTenants
└── modules/
    ├── health/             # GET /api/health
    └── tenants/            # GET /api/tenant/config/:slug ، admin/tenants

التالي (P1)

users · auth(OTP) · drivers · trips(★ آلة حالة) · matching(Redis GEO) · tariff · realtime(Socket.IO) · maps(وكيل انطلق).