Architecture & Multi-Tenancy | TTF Docs
Skip to main content
documentation

Architecture & Multi-Tenancy

How TTF unifies identity, database isolation, real-time sockets, and Cloudflare edge frontends across 15+ apps.

High-Level Topology

Time To Future runs a hub-and-spoke SaaS architecture:

  • Edge Web Frontends: React 19 + Vite apps (plus glintly-ui) deployed globally on Cloudflare Workers Assets with SSR prerendering for public/SEO surfaces.
  • Native Mobile Apps: Expo / React Native apps for TTF HRMS Mobile and TTF Mail Mobile consuming the same REST APIs.
  • Unified Master Backend: Node.js / Express 5 (master-backend) exposing modular service routers under /api/*, Socket.IO for real-time DG Messenger events, and central SSO (/api/sso/*).

Multi-Tenant Data Isolation

Every enterprise resource in the shared database carries an indexed companyId discriminator enforced at the query and middleware layer:

  1. Authenticated JWTs bind the caller to their userId, companyId, and role.
  2. Controllers scope reads and writes by req.user.companyId — cross-tenant queries are impossible even if a caller alters a document ID in a request URL.
  3. Dedicated single-tenant deployments are available for Enterprise Cloud customers.

Shared Identity vs. Isolated App Accounts

  • Core Suite (HRMS, Client Deck, Task Deck, Mail, Messenger): Share the central User model and Sign in with TTF OAuth2 + PKCE (trust: 'first_party').
  • Developer Console (console.timetofuture.com): Uses an isolated Developer account model so external developers can manage third-party SsoClient apps without ever accessing TTF company data.
  • Formx (formx.timetofuture.com): Supports dedicated Formx accounts under /api/forms/auth alongside origin-open public submission endpoints (/api/forms/public/:token/submit).