Skip to main content

Architecture

Architecture

User flow

  1. User (browser) logs in via OAuth and hits the Next.js app (Vercel).
  2. The web app calls backend services via the TS SDK; requests are JWT-authenticated.
  3. Requests pass through an API Gateway to Core API.
  4. Services read from Cloud SQL (base data store) and, when needed, from Client Data Stores through managed connectors or jobs.
  5. Scheduled Jobs (Cloud Scheduler → Cloud Run Jobs / Airflow) precompute aggregates for fast dashboards.

Key properties

  • Page-shaped endpoints (view-models) to render screens in one trip.
  • DB-first: migrations are the data source of truth.
  • Contracts: OpenAPI emitted from FastAPI; SDKs generated for TS/Python.

Components

Frontend (Next.js + Vercel)

  • Next.js (App Router) for pages, server components, API calls through @instalily/ts-sdk.
  • Auth middleware verifies session, attaches tenant & tracing headers.
  • Design system (@instalily/ui) provides dashboard primitives.

API Gateway (GCP)

  • Single public base URL; routes to Core/Chat via /v1/{service}/….
  • Handles JWT verification, rate limits, and cross-cutting headers.

Core API (Cloud Run)

  • FastAPI service for dashboards, customers, notes, touchpoints, and email generation.
  • View-model routes (e.g., /v1/core/dashboard/summary) compose queries and cached aggregates.
  • DB migrations (Alembic) + SQLAlchemy for models.

Data Stores

  • Base Data Store: Cloud SQL (Postgres).
  • Client Data Stores: connectors to Azure/AWS/BigQuery/Snowflake; synced via jobs.

Jobs / Data Backend

  • Cloud Scheduler → Cloud Run Jobs (or Airflow) to ingest, transform, and materialize metrics into tables or Redis.