Skip to content

Outreach Service

@nx/outreach thu thập yêu cầu từ form liên hệ và đăng ký newsletter từ marketing site công khai. Khi submit, nó broadcast một WebSocket event real-time tới các room quan sát của admin. Đây là một leaf service không có Kafka và chỉ phụ thuộc nội bộ vào @nx/core.

1. Tham chiếu nhanh

Thuộc tínhGiá trị
Package@nx/outreach
CodeSVC-00110-OUTREACH ⚠️ trùng với @nx/licensing (SVC-00110); không đăng ký trong core ServiceCodes
LoạiMicroservice
RuntimeBun
Base ClassVerifierApplication
Vị trípackages/outreach
Base Path/v1/api/outreach
Dev Port31110
Container Port3000 (external 31110)
Snowflake ID10
DB Schemaoutreach (2 bảng: Inquiry, Subscriber)
Binding Namespace@nx/outreach
Owneroutreach-team

2. Mục đích & Phạm vi

Bao gồmKhông bao gồm
Thu thập yêu cầu contact / sales / demo / partnerGửi email / SMTP (không có mail component)
Subscribe / unsubscribe newsletter (idempotent)Publish Kafka event (không có)
Thống kê subscriber cho admin dashboardTự động hóa CRM pipeline (thủ công qua trường CRUD)
Thông báo WebSocket real-time khi có yêu cầu mớiScope merchant đa-tenant (bảng global)

3. Tech Stack

Bên ngoài:

Thư việnMục đích
@venizia/ignisIoC container, DI, BaseService, ControllerFactory, VerifierApplication
@venizia/ignis-helpersWebSocketEmitter, HTTP, env helpers
honoFramework HTTP server (qua IGNIS)
@hono/zod-openapiSchema route → OpenAPI spec
@scalar/hono-api-referenceViewer tương tác /doc
drizzle-ormTruy cập DB qua PostgresCoreDataSource
pgPostgreSQL driver

Nội bộ:

PackageMục đích
@nx/coreTất cả schema/repository (Inquiry, Subscriber), VerifierApplication, BaseSocketEventService, Redis factory, migration loader, repository permission/role/policy

@nx/core là phụ thuộc nội bộ duy nhất. Không có client service anh em.

4. Cấu trúc Project

packages/outreach/
├── src/
│   ├── application.ts          # Application extends VerifierApplication
│   ├── index.ts                # Entry → bootstrapApplication()
│   ├── migrate.ts              # Migration entry → bootstrapMigration()
│   ├── common/                 # RestPaths, constants, keys
│   ├── components/
│   │   └── websocket/          # ApplicationWebSocketComponent + OutreachSocketEventService
│   ├── controllers/
│   │   ├── inquiry/            # InquiryController (+ /submit)
│   │   ├── subscriber/         # SubscriberController (+ subscribe/unsubscribe/statistics)
│   │   └── permissions.ts      # OutreachPermissions (CRUD perms cho cả hai entity)
│   ├── datasources/            # PostgresCoreDataSource binding
│   ├── errors/                 # SubscriberErrors, WorkerErrors
│   ├── migrations/processes/   # 0001 seed-permissions, 0002 seed-role-permissions
│   ├── repositories/           # SubscriberRepository (custom getStatistics) + re-exports
│   └── services/               # SubscriberService
├── package.json
└── tsconfig.json

5. Architecture

Chi tiết: xem Architecture.

6. Snapshot Domain

Không có khóa ngoại giữa các entity — cả hai là bảng thu thập độc lập. ERD đầy đủ + bảng theo từng entity: xem Domain Model.

7. Tổng quan bề mặt

REST controllers (tham chiếu đầy đủ render trực tiếp từ /v1/api/outreach/doc/openapi.json):

ControllerBase pathEndpoints
InquiryController/inquiries7 (CRUD + /submit)
SubscriberController/subscribers9 (CRUD + /subscribe, /unsubscribe, /statistics)

Async topics (tham chiếu đầy đủ trong API Events):

HướngSố lượng
Inbound (Kafka)0 (không có)
Outbound (Kafka)0 (không có)
WebSocket out1 (INQUIRY_SUBMITTED)
BullMQ jobs in0
BullMQ jobs out0

8. Components

ComponentFileMục đích
ApplicationWebSocketComponentsrc/components/websocket/component.tsBuild WebSocketEmitter backed bởi Redis (single/cluster), bind nó, đăng ký OutreachSocketEventService

9. Services

ServiceFileMô tả ngắn
SubscriberServicesrc/services/subscriber.service.tsSubscribe idempotent, unsubscribe theo token, tổng hợp thống kê
OutreachSocketEventServicesrc/components/websocket/socket-event.service.tsBroadcast INQUIRY_SUBMITTED tới room quan sát (bind bởi component, không trong configureServices)

10. Repositories

RepositoryBảngNguồnMethod tùy chỉnh
InquiryRepositoryoutreach.Inquiry@nx/core (re-export)
SubscriberRepositoryoutreach.Subscriberextends core repogetStatistics() — rollup một-query (total / monthlyNew / by-status)

11. Entry Points

FileMục đích
src/index.tsService entry → bootstrapApplication()
src/migrate.tsMigration entry → bootstrapMigration()
src/application.tsLớp Application extends VerifierApplication

12. Configuration

Env vars + feature flags + dữ liệu seed: xem Configuration.

13. Operations

Deployment + observability + security + runbook: xem Operations.

14. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.