Skip to content

Code layout

amw/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.ts                    entry point: defaults NODE_ENV, starts AmwServer
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ AmwServer.ts           Express app, routes, middleware, Redis, lifecycle
β”‚   β”‚   β”œβ”€β”€ AmwApi.ts              /product, /products and widget asset handlers
β”‚   β”‚   β”œβ”€β”€ Paapi.ts               Amazon Creators API client and product mapping
β”‚   β”‚   β”œβ”€β”€ AmazonError.ts         classification of Amazon failures (502/503/504)
β”‚   β”‚   β”œβ”€β”€ Resilience.ts          request coalescing, not-found cache, circuit breaker
β”‚   β”‚   β”œβ”€β”€ Schemas.ts             zod validation of the query parameters
β”‚   β”‚   β”œβ”€β”€ CacheControl.ts        per-route Cache-Control helpers
β”‚   β”‚   β”œβ”€β”€ Stats.ts               usage statistics in Redis, /click beacon
β”‚   β”‚   β”œβ”€β”€ AdminApi.ts            admin portal API, login and static files
β”‚   β”‚   β”œβ”€β”€ Insights.ts            AI insights on the statistics (Claude API)
β”‚   β”‚   β”œβ”€β”€ Settings.ts            typed configuration, read and validated once
β”‚   β”‚   └── OpenApi.ts             OpenAPI 3.1 document (Swagger UI)
β”‚   β”œβ”€β”€ utils/logger.ts            loggers and request logging (pino)
β”‚   β”œβ”€β”€ utils/metrics.ts           Prometheus metrics (prom-client)
β”‚   └── widgets/                   browser widget (plain JavaScript) and its stylesheet
β”œβ”€β”€ admin/                         admin portal (Vue 3 + Vite + Chart.js, own package.json)
β”‚   β”œβ”€β”€ src/components/            views, activity bar, charts and tables
β”‚   β”œβ”€β”€ src/navigation.ts          hash routes (#/overview, #/pages…)
β”‚   β”œβ”€β”€ src/theme.ts               light / dark theme
β”‚   └── tests/                     component tests (Vitest)
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ *.test.ts                  unit tests (Jest)
β”‚   β”œβ”€β”€ helpers/                   config / SDK test doubles, in-memory Redis
β”‚   └── e2e/
β”‚       β”œβ”€β”€ *.e2e.test.ts          API end-to-end tests
β”‚       β”œβ”€β”€ browser/*.spec.ts      Playwright tests
β”‚       β”œβ”€β”€ config/e2e.yml         configuration used by the e2e server
β”‚       └── support/               mock Amazon API, server launcher
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ sample.yml                 template for config/production.yml
β”‚   β”œβ”€β”€ docker.yml                 defaults of the Docker image
β”‚   β”œβ”€β”€ development.yml            defaults of npm run dev and the dev container
β”‚   └── custom-environment-variables.yml   environment variable mapping
β”œβ”€β”€ docker/
β”‚   β”œβ”€β”€ Dockerfile                 production image (multi-stage, non-root)
β”‚   β”œβ”€β”€ Dockerfile.dev             development image
β”‚   β”œβ”€β”€ docker-compose.yml         production stack (AMW + Redis)
β”‚   β”œβ”€β”€ docker-compose.dev.yml     development stack (hot reload + Redis)
β”‚   β”œβ”€β”€ config/redis/redis.conf    Redis settings of the production stack
β”‚   └── scripts/                   build.sh, validate.sh
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ build-widgets.js           minifies the widget into dist/widgets/
β”‚   β”œβ”€β”€ build-admin.js             builds the admin portal into dist/admin/
β”‚   β”œβ”€β”€ dev-mock.ts                npm run dev:mock: AMW against a mock Amazon API
β”‚   β”œβ”€β”€ docs-screenshots.ts        captures the documentation screenshots
β”‚   └── test-docker.sh             Docker smoke test used by CI
β”œβ”€β”€ docs/                          this documentation (MkDocs Material)
β”œβ”€β”€ resources/                     logo and screenshot shipped in the npm package
β”œβ”€β”€ .devcontainer/                 VS Code Dev Containers setup
β”œβ”€β”€ .github/                       workflows, issue forms, PR template, Dependabot
β”œβ”€β”€ .env.example                   environment variable template (copy to .env)
β”œβ”€β”€ start.sh                       entry point: local, dev, docker and stop modes
β”œβ”€β”€ AGENTS.md                      contribution rules for humans and AI agents
β”œβ”€β”€ SECURITY.md                    security policy
└── mkdocs.yml                     documentation site configuration

Build output

npm run build writes dist/:

Path Produced by
dist/main.js, dist/server/, dist/utils/ tsc (CommonJS, with source maps)
dist/widgets/widget.js, widget.css scripts/build-widgets.js (terser), served by /widget.js and /widget.css
dist/widgets/widget.<hash>.js\|css, manifest.json scripts/build-widgets.js: content-hashed copies, cached as immutable
dist/admin/ scripts/build-admin.js (Vite), served at <path>/admin/ when Admin.enabled

The npm package ships dist/, config/sample.yml, config/docker.yml, config/custom-environment-variables.yml, resources/, README.md and LICENSE. The Docker image ships dist/, the production node_modules, config/docker.yml, config/custom-environment-variables.yml and resources/.

Where to change what

Change Files
New endpoint or middleware src/server/AmwServer.ts, src/server/OpenApi.ts, tests/server.test.ts, HTTP API
Product fields from Amazon src/server/Paapi.ts (defaultResources, buildProduct), tests/paapi.test.ts
Card look or behaviour src/widgets/widget.js, src/widgets/widget.css, tests/widget.dom.test.ts, then npm run docs:screenshots
Admin portal view admin/src/components/, admin/src/navigation.ts, admin/tests/, Administration portal
Statistics or insights src/server/Stats.ts, src/server/AdminApi.ts, src/server/Insights.ts, tests/stats.test.ts, tests/admin-api.test.ts, tests/insights.test.ts
New configuration key config/*.yml, config/custom-environment-variables.yml, .env.example, Configuration