service

CNA Nexus

Franchise network back-office (franchises, economic groups, partners, contracts and amendments, document storage, AI document analysis, pendencies). Produces and consumes on the Franchise, Contract and AI topics; also publishes InviteUser and PendencyResolved. PartnerUpdated on the Partner topic is a target contract not emitted yet.

Service

Overview

cna-nexus manages the franchise network for the franchisor: franchises and their economic groups and partners, contracts and amendments with their documents, AI-assisted document analysis, and pendencies. On the Kafka bus it is both producer and consumer. It publishes franchise and economic group changes for CNA OneCNA OneServicev1.0.0Franchise operating system (franchises and employees, pricing, products and learning books, school operations). Publishe...PublishesGrantApplicationAccess, EmployeeCreated +6SubscribesInviteUser, FranchiseCreated +9Ownercna-platformMapRepoView docs to mirror, invites users into the platform, and uses the Contract and AI topics as an internal work queue between its API and its consumer processes.

Producers are called through manager.afterCommit() so that a message is only published when the surrounding database transaction commits.

Partner UpdatedPartner UpdatedEventv1.0.0The personal data of a franchise partner changed in CNA Nexus - name, legal name, e-mail, phone or birth date. Snapshot ...Ownercna-platformSchemaMapView docs on Partner (Kafka topic)Partner (Kafka topic)Channelv1.0.0Kafka topic for the Partner aggregate - a person in their capacity as partner of one or more franchise units. Carries Pa...Ownercna-platformView docs is listed as sent but is a target: no class exists and updatePerson emits nothing yet (see the event page).

Messages

Messages for this service

Sends messages (15)

Quickly find the message you need by searching for the name, type, or summary.
NameVersionTypeSummaryChannels
Invite User
v1.0.0commandInvites a person into the CNA platform. Published by cna-nexus and cna-placement when a user is created or re-invited; handled by cna-one, which creates the person and employee and then requests application access from cna-auth.
-
Contract Activation Requested
v1.0.0eventA user saved a contract for activation. cna-nexus's activation consumer turns it ACTIVE and creates or updates the franchise unit it governs.
-
Amendment Apply Requested
v1.0.0eventA user finished reviewing a contract amendment and asked for its changes to be applied. cna-nexus's amendment consumer executes the changes on the contract and the franchise.
-
Document Analysis Requested
v1.0.0eventA contract or amendment document was uploaded and an AI analysis row created for it. cna-nexus's analysis worker extracts the structured data and leaves the contract or amendment in DRAFT for review.
-
Pendency Resolved
v1.0.0eventThe responsible user resolved a pendency as done or declined. Carries only the id; consumers are expected to re-read the pendency. No consumer today.
-
Franchise Created
v1.2.0eventA franchise unit was created in CNA Nexus by activating an opening contract. Full snapshot of the unit; cna-one mirrors it, its address and its partners as employees.
-
Franchise Updated
v1.2.0eventA franchise unit changed in CNA Nexus - edited in one of the franchise screens, re-activated from a contract, or amended. Full snapshot. Nobody consumes it today; cna-one has no class for it and drops it.
-
Franchise Address Created
v1.0.0eventA franchise unit received its address in CNA Nexus. The address block of the franchise snapshot plus the franchise id. Published by cna-nexus, consumed by cna-one to mirror the address.
-
Franchise Address Updated
v1.0.0eventThe address of a franchise unit changed in CNA Nexus. The address block of the franchise snapshot plus the franchise id. Published by cna-nexus, consumed by cna-one to mirror the change.
-
Economic Group Created
v1.0.0eventAn economic group was created in CNA Nexus. cna-one mirrors it by id so that franchises can reference it.
-
Economic Group Updated
v1.0.0eventAn economic group changed in CNA Nexus - renamed, toggled active or soft-deleted (there is no delete event). cna-one mirrors the new state by id.
-
Franchise Partner Added
v1.1.0eventA person became a partner of a franchise unit, with their roles. One message per partner. Consumed by cna-nexus itself to invalidate the economic group statistics cache.
-
Franchise Partner Removed
v1.1.0eventA person stopped being a partner of a franchise unit. One message per partner. Consumed by cna-nexus itself to invalidate the economic group statistics cache, which cannot see hard-deleted rows otherwise.
-
Franchise Partner Updated
v1.1.0eventThe roles of a franchise partner changed - roles are the only mutable field. Carries the roles before and after. Consumed by cna-nexus itself to invalidate the economic group statistics cache.
-
Partner Updated
v1.0.0eventThe personal data of a franchise partner changed in CNA Nexus - name, legal name, e-mail, phone or birth date. Snapshot of the person, keyed by the person id. To be published by cna-nexus and consumed by cna-one; neither side has the class yet.
-

Receives messages (6)

Quickly find the message you need by searching for the name, type, or summary.
NameVersionTypeSummaryChannels
Contract Activation Requested
v1.0.0eventA user saved a contract for activation. cna-nexus's activation consumer turns it ACTIVE and creates or updates the franchise unit it governs.
-
Amendment Apply Requested
v1.0.0eventA user finished reviewing a contract amendment and asked for its changes to be applied. cna-nexus's amendment consumer executes the changes on the contract and the franchise.
-
Document Analysis Requested
v1.0.0eventA contract or amendment document was uploaded and an AI analysis row created for it. cna-nexus's analysis worker extracts the structured data and leaves the contract or amendment in DRAFT for review.
-
Franchise Partner Added
v1.1.0eventA person became a partner of a franchise unit, with their roles. One message per partner. Consumed by cna-nexus itself to invalidate the economic group statistics cache.
-
Franchise Partner Removed
v1.1.0eventA person stopped being a partner of a franchise unit. One message per partner. Consumed by cna-nexus itself to invalidate the economic group statistics cache, which cannot see hard-deleted rows otherwise.
-
Franchise Partner Updated
v1.1.0eventThe roles of a franchise partner changed - roles are the only mutable field. Carries the roles before and after. Consumed by cna-nexus itself to invalidate the economic group statistics cache.
-

Kafka consumers

Consumers run as separate processes, one script per domain: api/scripts/events/aiConsume.ts, contractConsume.ts and franchiseConsume.ts.

Consumer groupTopicsHandler
ai-document-analysisAIapi/app/domains/ai/events/consumers/documentAnalysisConsumer.ts
contract-activationContractapi/app/domains/contract/contract/events/consumers/contractActivationConsumer.ts
contract-amendment-applyContractapi/app/domains/contract/amendment/events/consumers/amendmentApplyConsumer.ts
economic-group-partner-touchFranchiseapi/app/domains/franchise/economicGroup/events/consumers/touchEconomicGroupOnFranchisePartnerChange.ts

Custom properties

PropertyValue
Runtimex-runtimeExpress 5 + GraphQL Yoga + TypeORM/Postgres + kafkajs
Events Pathx-events-pathapi/app/events/<owner>/<aggregateRoot>/<EventName>.ts