Skip to Content
Introduction

Backend Docs

The portal backend (portal-backend) is the API server behind the white-label real estate portal. It is a proxy in front of the Repliers MLS API — the frontend never calls Repliers directly — plus a small amount of state of its own and the integrations around it. This page shows what it is made of, which page answers which question, and where each cross-cutting register lives.

What it does:

  • Proxies and shapes MLS data — listings search, counts, similar listings, locations, autosuggest. Requests to Repliers are throttled and time-limited; a failed call is not retried (retry layers). Listing data is scrubbed for board rules before it is returned (Scrubbing).
  • Keeps little data of its own — clients, favorites, saved searches and estimates are Repliers records, read and written through the Repliers API. PostgreSQL holds only roles (acl), uploaded assets, social tokens, virtual tours and the CRM sync and webhook logs; one-time codes, revoked tokens and result caches are in Keyv stores (Data ownership).
  • Handles authentication — JWT sessions, OTP / email-token login, OAuth providers, agent authentication (Authentication).
  • Reports engagement — contact forms, listing views, saves and estimate events go to the CRM integration (Follow Up Boss) after the response (Events & Messaging).
  • Sends messages — OTP codes and inquiry notifications through the Repliers Messages API or a static SMTP account (Email).

Component map

A compact version of the full component map, which carries the per-edge evidence. Solid arrows are dependencies no setting switches off; dashed arrows are dependencies a setting turns off or selects (required and optional dependencies).

Process model

One codebase, two long-running processes and a release command, all in the Procfile: web (src/index.ts, every /api route) and worker (src/worker.ts, the NATS consumer, needed only with NATS_ENABLED=true). What each one starts, holds and stops is on Processes and Process lifecycle.

Four values have no default and stop the process when missing: the Repliers key, the Mapbox token and the two JWT key paths; other checks depend on settings (startup prerequisites). PostgreSQL is not contacted at startup, the Keyv stores run in memory without Redis, and NATS falls back to a dummy client; what each missing service turns off is in the feature dependencies register.

Stack at a glance

Koa 3 + @koa/router · TypeScript (ESM, Node 24) · tsyringe DI · Joi validation · knex + PostgreSQL · Keyv/Redis caching · pino logging · NATS JetStream · mocha tests.

Reading map

QuestionPage
How do I run it, and what do the first requests look like?Setup, First requests, Database & Services
Which variable or preset sets a value, and which one wins?Configuration Model, Environment Variables, Configuration resolution
What is the backend made of, and what does dependency injection hand out?Architecture Overview
Which route reaches which service, upstream client and store?Module catalogue
What happens to one request, from middleware to the error body?Request lifecycle
How are paths, bodies, query arrays, pagination and errors handled?API Conventions
What does a listings endpoint accept, send upstream and return?Listings, Search & count, Detail, similar & history, NLP, featured, locations
How does the search box answer?Autosuggest, Locations & Buildings, Geocoding
What can a signed-in user store and change?User & Favorites, Saved searches
How is an estimate built, owned and sent?Estimates, Estimate pipeline
What can agents and admins do?Agent & Admin, Agent clients, estimates & messages
Contact forms, statistics, virtual tours, webhooks?Contact, Stats & Tours, Webhooks
How does login work, and who may call an endpoint?Authentication, Auth endpoints
What does a guest see compared with a signed-in user?Scrubbing & Restrictions, Restricted listings
What does the proxy add to a Repliers call, and with which key?Repliers Proxy, Repliers API, MLS-number prefix
Which client IP does Repliers see, and how is an SSG build told apart?Client IP forwarding
Who owns a record, and how does one identifier map to another?Data ownership, Glossary
What is stored locally, and what is cached?Persistence, Caching
What reaches the CRM, and how does the FUB sync run?Events & Messaging, Follow Up Boss
How is mail delivered?Email
What happens when a dependency fails, and what has already happened?Failure & degradation
What does each process do at startup and on a signal?Process lifecycle
How does a whole workflow run, with a worked trace?Workflows W1–W10
How do I deploy, test and add a deployment?Deployment, CI/CD, Testing, Instances, Adding an instance
What ships in the open-source export?Export variants
Something is wrong: where do I look?Troubleshooting
How do I add an endpoint or an engagement report?Adding an endpoint, Adding an event selector
What is verified, and what is not?Coverage

Suggested route for a new reader: this page → Architecture Overview → Request lifecycle → Workflows → the domain page you need.

Cross-cutting registers

Each register has one home; other pages link to it.

TopicRegister
Routes → validators → services → upstream clients and storesModules register, service-call map
Middleware, roles, ownership check and guest behaviour per endpointEndpoint access
Every internal caller of the listings searchListing callers
What each endpoint masks or drops for a guest and a userVisibility register, restricted-listing exits
Where each setting comes from and when it is appliedEffective configuration
What each feature needs, and what happens without itFeature dependencies
Identifiers, conversions, owners, missing matchesIdentity and ownership
Local tables, readers, writers, cleanupLocal persistence
Cache namespaces, keys, TTLs, invalidationCache state
Routes that report to the CRM, awaited or detachedEngagement reporting
NATS subjects, payloads, jobs, acknowledgementsWorker handoffs
Backend method → Repliers endpoint, key, cachingRepliers endpoints
Caller contexts, key and throttle choiceContexts register
Failure per stage: propagation, result, completed side effectsFailure outcomes, retry layers
Error bodies and status codesError variants, status catalogue
Code absent from the open-source exportExport variants
Evidence and its limitsEvidence coverage

How this site is organized

  • Getting Started — run the backend locally, configure it, make the first requests.
  • Tutorials — add an endpoint, an event selector, a deployment.
  • Architecture — processes, request lifecycle, configuration, the Repliers proxy, scrubbing, data ownership, persistence, caching, auth, events, failures, workflows.
  • API Reference — the /api surface by domain and its conventions; the exact contracts are the @openapi annotations, served as a Swagger UI when APP_USESWAGGER=true.
  • Integrations — Repliers, Follow Up Boss, geocoding, email.
  • Operations — deployment, CI/CD, per-instance configuration, testing, troubleshooting, the OSS export.
  • Glossary and Coverage.

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

Last updated on