moxie/architecture

Architecture

fn-moxie-api is the Fox News Moxie stack: a single AWS Lambda (Webpack bundle) behind API Gateway, serving Fox News, Fox Business, Fox Weather, Outkick, and related properties. This page summarizes how a request moves through the system and where code lives in the repository.

Request flow

  1. API Gateway receives HTTP requests and invokes the Lambda.
  2. src/index.ts is the Lambda handler entry point.
  3. Setup (src/moxie/lib/Setup.ts) builds request context and attaches Moxie.
  4. Moxie (src/moxie/lib/Moxie.ts) parses method, path, body, querystrings, and headers; resolves identity (site, environment, URLs, flags); loads settings.
  5. Router (src/moxie/libraries/modules/router.js) matches the path to a route, merges config, and loads the endpoint (index.js) or framework fallback.
  6. The handler returns a response (JSON, JSON:API, XML, etc.) according to specification and caching headers.
API Gateway → Lambda (index.ts) → Setup → Moxie → Router

                         endpoint index.js (preferred)
                                      or
                         framework handler (fallback)

                                   Response

Path shape: {site}/{path}

Every URL is interpreted as site prefix + path:

Prefix Site Notes
fn Fox News Largest mobile + CMS surface
fb Fox Business
fw Fox Weather Spark layouts, mobile.spark.tab
ok Outkick
fs Fox Sports

Example: fn/articles/123 → site foxnews, path articles/123.

Routes are declared under src/settings/routes/ (per-site files and shared.js). Handlers live under src/apis/{site|shared}/....

Repository layout (high level)

Area Role
src/moxie/ Core framework: Moxie, Setup, Router, Storage, clients, helpers
src/apis/ Endpoint implementations by brand + shared/
src/frameworks/ jsonapi, template, mobile.tab, mobile.spark.tab, mobile.ott, staticish
src/settings/ Routes, env URLs, sites, caching policies, response specs
build/ Webpack, local dev server, scripts (dev.js, moxie.js)
tf/ Terraform: Lambda, API Gateway, S3, IAM, CloudWatch
.github/workflows/ Build + deploy to dev / stage / prod
tests/ Jest
static/ S3-synced static assets; dev maps /static/ and /s3/

External dependencies (runtime)

Moxie talks to Spark (CMS), Brightcove, Delta (API3 video), Aurora (homepage service), S3, and generic HTTP via shared clients — not “zero backend dependencies,” but the deployed Lambda artifact is a single bundle with no node_modules on the host.