Skip to Content
ArchitectureModule Catalogue

Module catalogue

Every HTTP endpoint the backend serves and every worker entry, with the code that handles it: which middleware guards it, which Joi schema validates it, which service method does the work, which upstream client or repository that method calls, where the data lives, and which settings change the behaviour. Use it to answer “where does this path live and what does it touch?” before opening a route file. Terms are defined in the Glossary.

Architecture overview | Request lifecycle | Data ownership | Authentication | API reference

How a module is wired

  • Mount. src/routes/index.ts creates the /api router and mounts fifteen feature routers with router.use(x.routes(), x.allowedMethods()). /user mounts three sub-routers (user/assets.ts, user/social.ts, user/boss.ts); /webhooks mounts webhooks/boss.ts. The app mounts the /api router after the global middleware chain in src/app.ts (see Request lifecycle).
  • Handler. A handler builds a payload from ctx.request.query, the body (getBody), path parameters and token claims (ctx.state.user.sub, .email), validates it with one schema, resolves the service with ctx.state.container.resolve(Service) and assigns the result to ctx.body, or passes a @cached result to sendCached, which unwraps it and sets Cache-Control. Validation failures throw ApiError(message, 400).
  • Auth. Auth is middleware on the route, or on the whole router through router.use. The legend below names the tokens. Ownership checks sit in three places: route middleware or router.param guards, validator rules, and service methods.
  • Service. Services reach Repliers through the RepliersService facade (src/services/repliers.ts, one property per client class) or by injecting a client class such as RepliersClients directly. Local tables go through src/repository/* (Knex), and short-lived state through Keyv stores. See Data ownership.
  • Second handler. Routes that report engagement register a second handler that resolves middleware.eventsCollection with a selector. The first handler calls next() after setting the body, and the report is not awaited. See Events & Messaging.

Auth legend. strict: middleware.jwt (401 without a valid, unrevoked token). passthrough: middleware.jwt.passthrough (no token means guest; an invalid token gets 401). none: no JWT middleware on the route or router. roles: middleware.role([...]), 403 Insufficient privileges otherwise. FUB signature: middleware.boss.webhook.auth. Both JWT tokens check the jti against the Keyv blocklist store (middleware.jwt.config, isRevoked). The roles, ownership check and guest behaviour of every endpoint are in the endpoint access register.

Store legend. Repliers X is an upstream record type. Keyv ns is a cache namespace from @cached (src/lib/decorators/cached.ts) or a provider store; its TTL variable is in parentheses. PG table is a local PostgreSQL table. NATS is a JetStream publish on the stream NATS_WORKER_CONSUMER_STREAM. FUB is the Follow Up Boss API through BossService, which returns {} without calling out when BOSS_ENABLED=false.

Modules register

/api/auth

Source: src/routes/auth.ts; validators src/validate/auth.ts, src/validate/oauth.ts; services AuthService (src/services/auth.ts), OAuthService (src/services/oauth.ts). router.param("provider") validates the provider with oauthUrlSchema (400) before every {provider} route. No route on this router uses role middleware.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
GET /api/auth/{provider}/urlnoneoauthUrlSchema, providerUrlSchema (query)OAuthService.urlOIDC config oauth.<provider>, buildAuthorizationUrlnoneredirect_uri from the query, else the first configured one; 400 when neither. Only oauth.google is registered in src/providers/index.tsAuth
POST /api/auth/{provider}/cbnoneoauthUrlSchema, providerCallbackSchema (body), providerUrlSchema (query)OAuthService.callback, then AuthService.generateTokenProvider token exchange; RepliersClients.filter / create, RepliersAgents.filter; BossService.getUsers for an agent; AclRepository.getUserAclRepliers clients; PG acl (read)An email with no client and no agent creates a client and reports a registration eventAuthentication
POST /api/auth/loginnoneuserLoginSchemaAuthService.login, sendOtpRepliersClients.filter (email or phone, OR), RepliersClients.update (mailing opt-in), RepliersMessages.sendKeyv otp: code (AUTH_OTP_TTL_MS) and resend marker (AUTH_OTP_RESEND_TTL_MS)404 when no client matches; 403 with Retry-After inside the resend window; the code is in the body only with DEBUG_AUTH_OTP_EXPOSE_CODEAuth
POST /api/auth/otpnoneuserOtpSchemaAuthService.useOtpRepliersClients.get, AclRepository.getUserAclKeyv otp (read, then deleted)403 for an unknown or used code; sub = clientIdAuthentication
POST /api/auth/refreshstrictnoneAuthService.refreshBlocklistRepository.create, AclRepository.getUserAclKeyv blocklist (old jti)The new token gets the old token’s exp - iat spanAuthentication
POST /api/auth/logoutstrictnoneAuthService.logoutBlocklistRepository.createKeyv blocklistnoneAuthentication
POST /api/auth/signupnoneuserSignupSchema (body plus referer header)AuthService.signup, then loginRepliersClients.create (default agent), RepliersMessages.sendRepliers clients; Keyv otpRegistration event, not awaitedAuth
POST /api/auth/repliers-tokennoneauthRepliersTokenSchemaAuthService.useRepliersTokenRepliersMessages.get (by token), RepliersClients.getnone400 unless AUTH_EMAILTOKEN_ENABLED=true; 403 for an unknown tokenAuth
POST /api/auth/embednone; the service checks the FUB context signature (401)authEmbedSchemaAuthService.embedLoginisFromFollowUpBoss with BOSS_SYSTEM_KEY; AclRepository.getUserAclnoneIssues a token with role Agent and no sub, plus a clientSignature for the CRM personFollow Up Boss

/api/listings

Source: src/routes/listings.ts; validators src/validate/listings.ts; services ListingsService (src/services/listings.ts), FavoritesService (src/services/favorites.ts); client RepliersListings (src/services/repliers/listings.ts). Every route uses passthrough auth. RepliersListings.search always forces displayInternetEntireListing=Y, constrains standardStatus to settings.allowedListingsStandardStatuses, excludes restricted listings and applies the MLS-number prefix codec.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/listings/searchpassthroughlistingSearchSchema (query, body, app_state.user)ListingsService.search (@scrubbed("listings"))RepliersListings.search, POSTRepliers listingsIdentity fields added to fields and clusterFieldsListings, Scrubbing
GET /api/listings/searchpassthroughlistingSearchSchema (query, app_state.user)ListingsService.search (@scrubbed("listings"))RepliersListings.search, POST as wellRepliers listingsSame service call as the POST routeListings
GET /api/listings/countpassthroughlistingCountSchemaListingsService.countRepliersListings.search (fields=timestamps.repliersUpdatedOn)Keyv listings:count (CACHE_LISTINGS_COUNT_TTL)Returns count and lastUpdatedOnListings
POST /api/listings/countpassthroughlistingCountArraySchema (array body)ListingsService.countArray, count per itemRepliersListings.search per item, in parallelKeyv listings:count per itemNo Cache-Control headerListings
GET /api/listings/{mlsNumber}/similarpassthroughlistingSimilarSchemaListingsService.similar (@scrubbed("similar"))RepliersListings.similarnoneRestricted listings dropped (dropRestricted)Scrubbing
GET /api/listings/locationspassthroughlistingsLocationsSchema (class forced to residential and condo; dropCoordinates defaults to settings.locations.drop_coordinates)ListingsService.locationsRepliersListings.locationsKeyv listings:autosuggest:locations (CACHE_STATSWIDGET_TTL)Deprecated in favour of the /locations router (@deprecated JSDoc). Keeps only settings.locations.boardId and the allowed areas, merges condo areas into residentialSearch & Locations
POST /api/listings/nlppassthroughnlpSchemaListingsService.nlp, then search when statistics or aggregates is askedRepliersListings.nlp (nlpVersion from settings.nlp.version)noneThe NLP result is not decorated; the follow-up search is scrubbedListings
GET /api/listings/lastUpdatedOnpassthroughnoneListingsService.lastUpdatedOnNone: computed in the method, no upstream callKeyv listings:lastUpdatedOn (CACHE_LISTINGS_LAST_UPDATED_ON_TTL)Not in OSSListings
GET /api/listings/featured/{slug}passthroughlistingsFeaturedSchema (stripUnknown)FavoritesService.featuredListings (@scrubbed("listings"))RepliersFavorites.get for the client mapped to the slugKeyv favorites:featuredListings (CACHE_FEATURED_LISTINGS_TTL), skipped when lat or long is sent404 when the slug is not in SETTINGS_FEATURED_LISTINGSListings
GET /api/listings/historypassthroughlistingsHistorySchemaListingsService.history (@scrubbed("history"))RepliersListings.historynoneDrops entries without a numeric boardId, with displayInternetEntireListing=N, or restrictedScrubbing
GET /api/listings/{mlsNumber}passthroughlistingsSingleSchemaListingsService.single (@scrubbed())RepliersListings.singlenoneRestricted, displayInternetEntireListing=N or hidden status: error with APP_HIDE_UNAVAILABLE_LISTINGS_HTTP_CODE. View event (SelectViewPropertyParams) for signed-in callers except AgentListings, Events

/api/autosuggest

Source: src/routes/autosuggest.ts; validators src/validate/autosuggest.ts; service AutosuggestService (src/services/autosuggest.ts).

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
GET /api/autosuggestpassthroughautosuggestSchemaAutosuggestService.searchIn parallel: MapboxService.suggest, ListingsService.search (scrubbed), RepliersLocations.autocomplete; plus an MLS-number-only ListingsService.search when mlsNumberPrefix is set and the query looks like an MLS numberRepliers listings and locationsMapbox duplicates filtered by Jaro-Winkler distance; listing statuses from repliers.autosuggest settingsSearch & Locations, Geocoding
GET /api/autosuggest/locationsnonenone (all parameters come from settings.locations)ListingsService.locationsRepliersListings.locationsKeyv listings:autosuggest:locations (CACHE_STATSWIDGET_TTL)Deprecated (deprecated: true in its @openapi block)Search & Locations
GET /api/autosuggest/addressnoneautosuggestAddressSchemaAutosuggestService.addressMapboxService.suggest (types address), or GoogleService.autocomplete when REPLIERS_AUTOSUGGEST_PROVIDER=googlemapsnoneMapbox results filtered by max_distanceGeocoding

/api/favorites

Source: src/routes/favorites.ts; validators src/validate/favorites.ts; service FavoritesService (src/services/favorites.ts); client RepliersFavorites. clientId comes from the token’s sub.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/favoritesstrictfavoritesCreateSchemaFavoritesService.addRepliersFavorites.addRepliers favorites; clears the favorites:featuredListings keys of a mapped clientSave-property event (SelectSavePropertyParams)User & Favorites
GET /api/favoritesstrictfavoritesGetSchemaFavoritesService.getRepliersFavorites.getRepliers favoritesRestricted listings droppedUser & Favorites
DELETE /api/favorites/{favoriteId}strict; ownership in the service (400 when the id is not in the caller’s list)favoritesDeleteSchemaFavoritesService.deleteRepliersFavorites.get, then deleteRepliers favorites; clears the featured cache of a mapped clientOwnership read from the unfiltered listData ownership

/api/contact

Source: src/routes/contact.ts; validators src/validate/contact.ts; service ContactService (src/services/contact.ts). All routes use passthrough auth; clientId is maybeClientId(sub), or the REPLIERS_UNAUTHENTICATED_CLIENT_ID client for guests. The contactus, schedule, requestinfo and subscribe/newsletter routes report an event for guests too (allowIncognito: true).

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/contact/contactuspassthroughcontactSchema, replaceable per deployment (see Export variants)ContactService.contactUsSmtpService.send when SMTP_ENABLED=true and REPLIERS_AGENT_EMAIL is set, else RepliersMessages.send; RepliersClients.get for a signed-in caller’s agentnoneBody OK; event SelectContactUsParamsContact, Stats & Tours, Email
POST /api/contact/schedulepassthroughscheduleSchemaContactService.scheduleAs for contactusnoneBody OK; event SelectScheduleParamsContact, Stats & Tours
POST /api/contact/schedule/estimatepassthroughscheduleEstimateSchemaContactService.scheduleEstimateRepliersEstimate.get, RepliersMessages.send (never SMTP), RepliersClients.get, RepliersAgents.get; EventsCollectionService.noteCreate and eventsCreate from inside the servicenone404 for an unknown estimate; body OKEvents
POST /api/contact/requestinfopassthroughrequestInfoSchema, replaceable per deploymentContactService.requestInfoAs for contactusnoneBody OK; event SelectRequestInfoParamsContact, Stats & Tours
POST /api/contact/subscribe/newsletterpassthroughsubscribeNewsletterSchemaNone: the route only validatesFUB through the event middlewareFUBBody OK; event SelectSubscribeNewsletterParamsFollow Up Boss

/api/searches

Source: src/routes/searches.ts; validators src/validate/searches.ts; service SearchesService (src/services/searches.ts); client RepliersSearches.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/searchesstrictsearchesCreateSchema (clientId = sub)SearchesService.createRepliersSearches.createRepliers searchesSave-search event (SelectSaveSearchParams)User & Favorites
PATCH /api/searches/{searchId}strictsearchesUpdateSchemaSearchesService.updateRepliersSearches.updateRepliers searchesnoneData ownership
GET /api/searchesstrictsearchsFilterSchemaSearchesService.getAllRepliersSearches.filter (clientId, default agent)Repliers searchesnoneUser & Favorites
DELETE /api/searches/{searchId}strict; ownership in the service (400)searchesDeleteSchemaSearchesService.deleteRepliersSearches.filter, then deleteRepliers searchesnoneData ownership
GET /api/searches/{searchId}passthroughsearchesGetSchemaSearchesService.getOneRepliersSearches.getRepliers searchesclient and agentId removed from the responseUser & Favorites

/api/user

Source: src/routes/user.ts and its sub-routers src/routes/user/assets.ts, user/social.ts, user/boss.ts; validators src/validate/user.ts, src/validate/user/*.ts; services UserService (src/services/user.ts), AssetsService (src/services/user/assets.ts), SocialService (src/services/user/social.ts), BossService (src/services/boss.ts). Assets and social rows are keyed by the token’s email.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
PATCH /api/userstrictuserUpdateSchema (clientId = sub)UserService.updateRepliersClients.updateRepliers clientsEvent SelectUnsubscribedParams, signed-in onlyUser & Favorites
GET /api/user/mestrictnoneUserService.infoRepliersClients.getRepliers clientsAdds communities split from tagsUser & Favorites
GET /api/user/agentpassthroughnoneUserService.agentRepliersClients.get, then RepliersAgents.get; for a guest, the REPLIERS_AGENT_ID agentRepliers agentsReturns email, phone, fname, lname, avatar, picked with _.pickUser & Favorites
POST /api/user/assets/{type}strictuserAssetsCreateSchemaAssetsService.createAssetsRepository.createAssetPG assets201; 409 for an existing idPersistence
GET /api/user/assets/{type}strictuserAssetsGetSchemaAssetsService.getAssetsRepository.getAssetsPG assetsnonePersistence
POST /api/user/assets/{type}/removestrictuserAssetsRemoveSchemaAssetsService.removeAssetsRepository.removeAssetPG assetsnonePersistence
GET /api/user/social/{provider}/urlstrictuserSocialUrlSchemaSocialService.getUrlPinterestSocialProvider.getUrl (the only SocialProvider)nonenoneUser & Favorites
GET /api/user/social/{provider}/cbstrictuserSocialCallbackSchema (code from the query)SocialService.callbackProvider token exchange; SocialRepository.createTokensPG socialnonePersistence
GET /api/user/social/{provider}/refreshstrictuserSocialRefreshSchemaSocialService.refreshSocialRepository.getUserTokens, provider refresh, SocialRepository.updateAccessTokenPG social400 without stored tokensPersistence
GET /api/user/social/{provider}strictuserSocialGetTokensSchemaSocialService.getTokensSocialRepository.getUserTokensPG socialThe parameter is optional (path /); without it, the caller’s tokens for every providerUser & Favorites
DELETE /api/user/social/{provider}strictuserSocialUnlinkSchemaSocialService.unlinkAccountSocialRepository.deleteTokensPG socialnoneUser & Favorites
POST /api/user/boss/tagstrictuserBossTagSchemaThe route calls UserService.info, BossService.getPeople, BossService.peopleUpdateRepliersClients.get; FUB person by the client’s externalIdFUB people404 without externalId or person; new tags merged with the existing ones; 201Follow Up Boss

/api/estimate

Source: src/routes/estimate.ts; validators src/validate/estimate.ts; service EstimateService (src/services/estimate.ts); clients RepliersEstimate, RepliersListings. assertOwnership in the route file calls EstimateService.checkOwnership with role User: sub must equal the estimate’s clientId (403).

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/estimatepassthroughestimateAddSchema (clientId = maybeClientId(sub))EstimateService.addRepliersEstimate.addRepliers estimatesWith a clientId: data, sendEmailNow, sendEmailMonthly sent upstream (defaults from repliers.estimatesNotificationSettings). Without: data withheld upstream and applied locally. Event SelectEstimateParams and note SelectEstimateNoteParams, guests includedEstimates
PATCH /api/estimate/{estimateId}strict, assertOwnershipestimatePatchSchemaEstimateService.patchRepliersEstimate.get (check), RepliersEstimate.patchRepliers estimatesnoneEstimates
GET /api/estimatepassthroughestimateGetSchema (estimateId up to SETTINGS_MAX_ESTIMATE_ID, or a 26-character ulid; the defaults preset sets max_estimate_id to 0, so there a positive numeric estimateId gets 400, see Estimates)EstimateService.getRepliersEstimate.getRepliers estimatesclientId removed before the upstream call; 404 when none; view event (SelectViewEstimateParams), signed-in onlyEstimates
GET /api/estimate/mystrictestimatesByClientIdGetSchemaEstimateService.getByClientIdRepliersEstimate.get (clientId)Repliers estimatesOwner adjustments applied to eachEstimates
DELETE /api/estimate/{estimateId}strict, assertOwnershipdeleteEstimateSchemaEstimateService.deleteRepliersEstimate.get (check), RepliersEstimate.deleteRepliers estimates404 when the upstream returns nothingEstimates
GET /api/estimate/property_detailspassthroughestimatePropertyDetailsSchemaEstimateService.propertyDetailsRepliersListings.search (not ListingsService); a second RepliersListings on REPLIERS_API_KEY_EXTRA when set; RepliersEstimate.get for a signed-in callerRepliers listingsPrevious estimate data merged at similarity 0.9 or more; settings.extended_property_details fills an empty resultEstimates

/api/stats

Source: src/routes/stats.ts; validators src/validate/stats.ts; service StatsService (src/services/stats.ts); client RepliersListings.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
GET /api/stats/widgetspassthroughstatsWidgetsSchemaStatsService.widgetsSix RepliersListings.search calls in parallelKeyv widgets (CACHE_STATSWIDGET_TTL)noneContact, Stats & Tours
GET /api/stats/neighborhoodsrankingpassthroughstatsNeighborhoodsrankingSchemaStatsService.neighborhoodsrankingGuest: a static stub, no upstream call. Signed in: neighborhoodsrankingAuthorised, fetchStats, RepliersListings.searchKeyv nr and stats (CACHE_NEIGHBORHOODSRANKING_TTL)Not in OSSContact, Stats & Tours
GET /api/stats/communitiesnonestatsCommunitiesSchemaStatsService.getCommunitiesIn-process data.communities (src/providers/data/communities.ts)none; the route sets a 24-hour Cache-Control204 for an unknown districtId. The table’s content is Not in OSSContact, Stats & Tours

/api/vtour

Source: src/routes/vtour.ts; validators src/validate/vtour.ts; service VtourService (src/services/vtour.ts), resolved once when the module loads. router.param("slug") validates the slug (vtourSlugSchema, 400) and loads the tour with VtourService.getOne (404). It runs before the route’s JWT and role middleware (see Gotchas).

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/vtourstrict; roles Admin, RootvtourCreateSchema (owner_id = sub)VtourService.createVtourRepository.createPG vtour409 when the slug existsContact, Stats & Tours
DELETE /api/vtour/{slug}slug guard, then strict; roles Admin, Root; owner rule in the validator (400)vtourRemoveSchema (owner_id must equal sub)VtourService.removeVtourRepository.getOne, removePG vtournonePersistence
PUT /api/vtour/{slug}slug guard, then strict; roles Admin, Root; owner rule in the validator (400)vtourUpdateSchemaVtourService.updateVtourRepository.getOne, updatePG vtournonePersistence
GET /api/vtour/{slug}slug guard, then strict; any rolevtourSlugSchemaVtourService.getOne (in the slug guard)VtourRepository.getOnePG vtourReturns the row the guard loadedContact, Stats & Tours

/api/agent

Source: src/routes/agent.ts; validators src/validate/agent.ts; services AgentService (src/services/agent.ts), EstimateService. router.use(middleware.jwt, middleware.role([Agent, Admin])) guards every route. Two router.param guards follow it:

  • clientId: with a query s, AgentService.checkSignature compares it with calcSignature(clientId, AUTH_AGENTS_SIGNATURE_SALT) (403 on mismatch); a match replaces ctx.state.user.sub with the client’s own agentId and skips the ownership check. Without s, AgentService.checkClient requires the client’s agentId to equal sub (403).
  • estimateId: loads the estimate (EstimateService.get); 403 when it has no clientId; then the same signature rule, else EstimateService.checkOwnership with role Agent.
EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/agent/clientstrict; roles Agent, AdminagentsCreateClientSchema (agentId = sub, status: true)AgentService.createClientRepliersClients.createRepliers clientsEvent SelectAgentClientRegistrationParamsAgent & Admin
GET /api/agent/clientstrict; roles Agent, AdminagentGetClientsSchemaAgentService.getClientsRepliersClients.filter (agentId = sub)Repliers clientsnoneAgent & Admin
GET /api/agent/client/{clientId}strict; roles Agent, Admin; clientId guardagentGetSingleClientsSchema (s removed)AgentService.getClientsRepliersClients.filterRepliers clientsnoneAgent & Admin
PATCH /api/agent/client/{clientId}strict; roles Agent, Admin; clientId guardagentUpdateClientSchemaAgentService.updateClientRepliersClients.updateRepliers clientsnoneAgent & Admin
POST /api/agent/estimate/{clientId}strict; roles Agent, Admin; clientId guardagentsCreateEstimateSchemaAgentService.createEstimateRepliersEstimate.addRepliers estimatesEvent SelectAgentEstimateParams, note SelectEstimateNoteParamsEstimates
GET /api/agent/estimate/{clientId}strict; roles Agent, Admin; clientId guardagentsGetEstimateSchemaAgentService.getEstimateRepliersEstimate.getRepliers estimatesnoneAgent & Admin
POST /api/agent/estimate/{estimateId}/sendstrict; roles Agent, Admin; estimateId guardagentsSendEstimateSchemaAgentService.sendEstimateRepliersEstimate.patch (sendEmailNow: true)Repliers estimatesAfter the body is set, a second handler adds a FUB note (BossService.getPeople by externalId, else email; noteCreate); its errors are caughtFollow Up Boss
PATCH /api/agent/estimate/{estimateId}strict; roles Agent, Admin; estimateId guardagentsUpdateEstimateSchemaAgentService.updateEstimateRepliersEstimate.patchRepliers estimatesagentId omitted before the callAgent & Admin
DELETE /api/agent/estimate/{estimateId}strict; roles Agent, Admin; estimateId guardagentsDeleteEstimateSchemaEstimateService.deleteRepliersEstimate.deleteRepliers estimatesStatus 200; the route sets no bodyAgent & Admin
POST /api/agent/messages/{clientId}strict; roles Agent, Admin; clientId guardagentsCreateMessageSchemaAgentService.createMessageRepliersMessages.send (sender: "agent")Repliers messagesnoneEmail
GET /api/agent/messages/{clientId}strict; roles Agent, Admin; clientId guardagentsGetMessagesSchemaAgentService.getMessagesRepliersMessages.getRepliers messagesnoneAgent & Admin
GET /api/agent/boss/peoplestrict; roles Agent, AdminagentGetBossPeopleSchema (assignedUserId from the claim external.fub_id)AgentService.getBossPeopleBossService.getPeopleFUB peoplenoneFollow Up Boss
POST /api/agent/boss/peoplestrict; roles Agent, AdminagentGetBossPeopleSchema (query)AgentService.syncBossPeopleBossService.getPeople; SyncRepository.startSync, PeopleSyncRepository.createPeople in one transaction; SyncService.publishUpsert per rowPG sync, people_sync; NATS people.upsertReturns synced; the worker does the client writesFollow Up Boss

/api/admin

Source: src/routes/admin.ts; validators src/validate/admin.ts; service AdminService (src/services/admin.ts). router.use(middleware.jwt, middleware.role([Admin, Root])) guards every route.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
GET /api/admin/agentsstrict; roles Admin, RootadminGetAgentsSchemaAdminService.getAgentsBossService.getUsers, RepliersAgents.filter (status: true)FUB users; Repliers agentsEach FUB user is listed with the Repliers agents that match by email or phoneAgent & Admin
POST /api/admin/agentsstrict; roles Admin, RootadminCreateAgentBatchSchema (array body)AdminService.createAgentsBatchRepliersAgents.create per item, one after anotherRepliers agentsOne result or error string per item, in input order; an item without phone or email gets Phone or email is missing and is not sentAgent & Admin
PATCH /api/admin/agents/{agentId}strict; roles Admin, RootadminUpdateAgentSchemaAdminService.updateAgentRepliersAgents.updateRepliers agentsPhone normalized; data.lastSyncOn setAgent & Admin

/api/webhooks

Source: src/routes/webhooks/index.ts, src/routes/webhooks/boss.ts; validator src/validate/webhooks.ts; service BossWebhooksService (src/services/boss/webhook.ts).

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/webhooks/boss/peopleFUB signature: fub-signature over the raw body with BOSS_SYSTEM_KEY (401)bossWebhooksEventSchemaBossWebhooksService.handlePeopleEventsBossService.getPeople for created and updated people, in batches of 30; WebhooksRepository.createPG webhooks; NATS people.create, people.update, people.deleteAnswers 204 with no body for every event; unknown names are only loggedWebhooks, Follow Up Boss

/api/locations

Source: src/routes/locations.ts; validators src/validate/locations.ts; service LocationsService (src/services/locations.ts); client RepliersLocations.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
GET /api/locationspassthroughlocationsGetSchemaLocationsService.getRepliersLocations.getKeyv locations:get (CACHE_LOCATIONS_TTL)noneSearch & Locations
GET /api/locations/autocompletepassthroughlocationsAutocompleteSchemaLocationsService.autocompleteRepliersLocations.autocompletenonenoneSearch & Locations

/api/buildings

Source: src/routes/buildings.ts; validators src/validate/buildings.ts; service BuildingsService (src/services/buildings.ts); client RepliersBuildings. No route on this router has JWT middleware.

EndpointAuth / rolesValidatorServiceUpstream client / repositoryStoreConditionsDeep dive
POST /api/buildingsnonebuildingsSchema (query and body)BuildingsService.search(value, true)RepliersBuildings.search, POSTKeyv buildings:search (CACHE_BUILDINGS_SEARCH_TTL)noneSearch & Locations
GET /api/buildingsnonebuildingsSchema (query)BuildingsService.search(value, false)RepliersBuildings.search, GETKeyv buildings:search (CACHE_BUILDINGS_SEARCH_TTL)noneSearch & Locations
GET /api/buildings/{addressKey}nonebuildingsSingleSchemaBuildingsService.singleRepliersBuildings.singleKeyv buildings:single (CACHE_BUILDINGS_SINGLE_TTL)addressKey passed through. The route assigns the @cached wrapper to the body without sendCached, so the body is { result, expires }Search & Locations

Worker entries

Source: src/worker.ts, src/streams/index.ts, src/streams/boss/people.ts (BossPeopleWorker). The worker is a separate process. It consumes the stream NATS_WORKER_CONSUMER_STREAM (default boss-people, subjects <stream>.people.*) with the durable consumer NATS_WORKER_CONSUMER_NAME, and only when NATS_ENABLED=true.

Entry (subject)ProducerHandlerServiceUpstream client / repositoryStoreDeep dive
<stream>.people.upsertSyncService.publishUpsert (agent people sync route)BossPeopleWorker.handleUpsertSyncService.processUpsertRepliersClients.filter / create / update; BossService.peopleUpdate (AVM link); PeopleSyncRepository.getById / update; SyncRepository.updateLastProcessedAtRepliers clients; PG people_sync, syncFollow Up Boss
<stream>.people.create, <stream>.people.updateBossWebhooksService.handlePeopleCreated / handlePeopleUpdatedBossPeopleWorker.handleWebhookCreate / handleWebhookUpdateBossWebhooksService.processPeopleUpsertRepliersAgents.filter (by FUB user id), RepliersClients.filter / create / update; BossService.peopleUpdate; WebhooksRepository.updateRepliers clients; PG webhooksFollow Up Boss
<stream>.people.deleteBossWebhooksService.handlePeopleDeletedBossPeopleWorker.handleWebhookDeleteBossWebhooksService.processPeopleDeleteRepliersClients.filter (externalId), RepliersClients.delete; WebhooksRepository.updateRepliers clients; PG webhooksData ownership

Service-call map

Which services call which other services, and which route handlers call more than one. Each service’s own upstream clients and stores are in the table after the diagram.

FavoritesService does not call ListingsService: it shares the scrubbed decorator (src/services/scrubber/listings.ts) and dropRestricted (src/services/listings/listingHelpers.ts) with it, and the listings router calls it for the featured route. AutosuggestService calls ListingsService.search, so autosuggest listings are scrubbed. EstimateService calls RepliersListings directly.

ServiceRepliers clientsRepositories and storesOther dependencies
ListingsServiceRepliersService.listingsKeyv listings:count, listings:autosuggest:locations, listings:lastUpdatedOnnone
FavoritesServiceRepliersService.favoritesKeyv favorites:featuredListings (read, write, invalidate)none
AutosuggestServiceRepliersLocationsnoneListingsService, MapboxService, GoogleService
LocationsServiceRepliersService.locationsKeyv locations:getnone
BuildingsServiceRepliersService.buildingsKeyv buildings:search, buildings:singlenone
StatsServiceRepliersListingsKeyv widgets, stats, nr; data.communitiesnone
EstimateServiceRepliersListings (two instances, one switched to REPLIERS_API_KEY_EXTRA), RepliersEstimatenoneUserService
UserServiceRepliersService.clients, .agentsnonenone
SearchesServiceRepliersSearchesnonenone
ContactServiceRepliersService.messages, .estimate, .clients, .agentsnoneEventsCollectionService, SmtpService, two selectors
AgentServiceRepliersClients, RepliersEstimate, RepliersMessagesSyncRepository, PeopleSyncRepositoryBossService, SyncService
AdminServiceRepliersAgentsnoneBossService
AuthServiceRepliersClients, RepliersMessagesAclRepository, BlocklistRepository, Keyv otpEventsCollectionService, Codegen
OAuthServiceRepliersClients, RepliersAgentsnoneAuthService, EventsCollectionService, BossService, OIDC config oauth.<provider>
SyncServiceRepliersClientsSyncRepository, PeopleSyncRepository; NATSBossService
BossWebhooksServiceRepliersClients, RepliersAgentsWebhooksRepository; NATSBossService
EventsCollectionServicenonenoneBossService, UserService
AssetsService, SocialService, VtourServicenoneAssetsRepository, SocialRepository, VtourRepositoryPinterestSocialProvider (social)
BossService, MapboxService, GoogleService, SmtpServicenonenoneTheir own HTTP or SMTP client, built in the constructor

Export variants

Not in OSS

The code below sits in @oss-remove regions or @export-only regions and files (markers in scripts/internal/oss-copy.ts). It is in this repository and in the exports for the deployments that use it, and absent from the open-source export.

CodeMarkerEffect in the OSS export
The lastUpdatedOn route in src/routes/listings.ts, ListingsService.lastUpdatedOn, its response type in src/services/repliers/listings.ts and cache.listingsLastUpdatedOn in src/config.ts@oss-removeThe route does not exist
The neighborhoodsranking route and its schema import in src/routes/stats.ts, StatsService.neighborhoodsrankingAuthorised / neighborhoodsranking and the guest stub import in src/services/stats.ts@oss-removeThe route does not exist
The table body in src/services/stats/communities.ts@oss-removeThe communities route stays; communities is an empty object
The validator override module in src/validate/overrides/, its case in overrides.ts and the DTO union members in src/validate/contact.ts@export-onlyoverrides(config.settings.validationVersion) returns {}, so the contact-us and request-info routes always use the shared schemas

Gotchas

  1. The GET search route goes upstream as a POST. ListingsService.search and ListingsService.count pass usePost = true to RepliersListings.search. Source: src/services/listings.ts (ListingsService.search, count).
  2. The buildings routes run without JWT middleware. No middleware.jwt or middleware.jwt.passthrough is resolved in the file, so ctx.state.user is never set there. Source: src/routes/buildings.ts, src/services/buildings.ts (BuildingsService).
  3. The single-building body keeps the cache wrapper. The search routes pass the @cached result to sendCached; the {addressKey} route assigns it to ctx.body directly. Source: src/routes/buildings.ts, sendCached in src/lib/decorators/cached.ts.
  4. The vtour slug guard runs before authentication. @koa/router puts router.param middleware ahead of the route’s own middleware, so the slug is validated and looked up in PostgreSQL before middleware.jwt and middleware.role run. In /agent and /admin the auth sits in router.use, which runs before the param guards. Source: src/routes/vtour.ts (router.param("slug")), src/routes/agent.ts (router.use), Layer._insertParamMiddleware in node_modules/@koa/router.
  5. A valid agent signature swaps sub. With a matching s, the clientId and estimateId guards set ctx.state.user.sub to the client’s own agent and skip the ownership check; every later handler then reads that sub. Source: src/routes/agent.ts (router.param("clientId"), router.param("estimateId")), src/services/agent.ts (AgentService.checkSignature).
  6. Role lists differ between routers. /agent admits Agent and Admin; /admin and the vtour write routes admit Admin and Root; GET on a vtour slug admits any role. Source: src/routes/agent.ts, src/routes/admin.ts, src/routes/vtour.ts (roleMiddleware).
  7. Ownership is checked in three layers, with different statuses. Route middleware or param guards answer 403 (assertOwnership in src/routes/estimate.ts, the guards in src/routes/agent.ts). Validator rules answer 400 (vtourRemoveSchema, vtourUpdateSchema in src/validate/vtour.ts). Services answer 400 (FavoritesService.delete in src/services/favorites.ts, SearchesService.delete in src/services/searches.ts).
  8. Three services are resolved once, at module load. AssetsService, SocialService and VtourService are resolved from the root container when the route file is imported, so one instance serves every request; src/routes/user/boss.ts resolves BossService from the root container on each request. Every other route uses ctx.state.container.resolve. Source: src/routes/user/assets.ts, src/routes/user/social.ts, src/routes/vtour.ts, src/routes/user/boss.ts.
  9. Both locations endpoints share one cache namespace. The listings and autosuggest locations routes both call ListingsService.locations, cached as listings:autosuggest:locations with config.cache.statswidget.ttl_ms; the two build different parameters, so their keys differ. Source: src/services/listings.ts (ListingsService.locations), src/routes/autosuggest.ts.
  10. Engagement reports depend on BOSS_ENABLED. With it set to false, middleware.eventsCollection returns an empty middleware, so the newsletter route does nothing beyond validation. Source: src/providers/middleware/eventsCollection.ts, src/routes/contact.ts.
  11. Some contact validators can be swapped per deployment. contactSchema and requestInfoSchema are taken from overrides(config.settings.validationVersion) when it returns one (SETTINGS_VALIDATION_VERSION). Source: src/validate/contact.ts, src/validate/overrides/overrides.ts (overrides).
  12. Route order matters for /listings. The static paths (history, locations, lastUpdatedOn, featured/{slug}) are registered before the {mlsNumber} route, which would otherwise match them. Source: src/routes/listings.ts (comment above the history route).

Verified against portal-backend 997ae3e, 2026-10-20.

Last updated on