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
- API Gateway receives HTTP requests and invokes the Lambda.
src/index.tsis the Lambda handler entry point.- Setup (
src/moxie/lib/Setup.ts) builds request context and attaches Moxie. - Moxie (
src/moxie/lib/Moxie.ts) parses method, path, body, querystrings, and headers; resolves identity (site, environment, URLs, flags); loads settings. - Router (
src/moxie/libraries/modules/router.js) matches the path to a route, merges config, and loads the endpoint (index.js) or framework fallback. - 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.
Related docs
- Router & routes — how files are resolved from a route definition.
- Frameworks & patterns — JSON API, template, mobile frameworks.
- Local development —
yarn dev, environments, optional tunneling.