-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Site Architecture
- Table of Contents
At a high level, docs.newrelic.com is built with React and MDX. It uses Gatsby as a static site generator and is hosted on AWS Amplify.
JAM stands for Javascript, APIs & Markup. A core part of the site architecture is Gatsby which is used as a static-site generator. Pages are built by combining Markup (MDX) and Javascript (React) and hosted as static HTML files.
There is no back-end or CMS powering the site.
| Tool | Description |
|---|---|
| Gatsby | Static site generator |
newrelic/gatsby-theme-newrelic |
Shared New Relic components and site configuration (see below) |
| MDX | Markdown + React components for authoring content |
| React | Custom components & view layer |
| GraphQL | Querying content within the site |
| Emotion | CSS in JS (styles) |
| Github Actions | Task automation (see below) |
| AWS Amplify | Hosting & deployments (see below) |
| Yarn | Package management & task runner |
In addition to the technologies listed above, we use a number of Gatsby plugins. In addition to established third-party plugins, we've also created a few custom plugins to handle specific tasks. For a complete list of plugins, check out our package.json file.
newrelic/gatsby-theme-newrelic
New Relic has developed a Gatsby theme which includes components and configuration shared across several website. The Open Source and Developer site both make use of this theme. For more information on how to use the components and configuration, refer to the README.
The site is currently hosted on AWS Amplify (and is connected to the repository via a webhook). To deploy a new version of the site, simply merge into main (our mainline branch). Amplify will:
- Build the site by running
yarn build:production. - If the build succeeds, deploy the new version.
- If the build fails, do keep the previous version deployed.
Additionally, whenever a pull request is created, a "preview" environment will be spun up. A link for this environment can be found in the "checks" tab for the pull request.
For more information about our CD settings, check out the amplify.yml file. For information about other CI processes, see Github actions below.
To run the project locally, you will need the following dependencies:
- Node 12.x
- Yarn
To get the project running locally, follow these steps:
- Clone the repository.
- Install the dependencies by running
yarn. - Start the development server by running
yarn start.
The first time you start the server on a machine, it will take a while to run. Subsequent runs should be faster (Gatsby caching).
For more information, see CONTRIBUTING.md.
Here is a list of the commonly-used directories (see below for a description of each):
.github/workflows/
codemods/
gatsby/
plugins/
rehype-plugins/
scripts/actions/
src/
| @newrelic/gatsby-theme-newrelic/
| announcements/
| components/
| content/
| docs/
| whats-new/
| data-dictionary/events/
| data/
| hooks/
| i18n/
| content/
| nav/
| translations/
| layouts/
| manual-edits/
| nav/
| pages/
| templates/
| utils/
| Path | Description |
|---|---|
.github/workflows/ |
Configuration for our Github actions (see below) |
codemods/ |
Files & utilities used when migrating from the previous site |
gatsby/ |
Gatsby lifecycle functions |
plugins/ |
Custom Gatsby plugins |
rehype-plugins/ |
Plugins used by rehype (HTML AST parser) |
scripts/actions/ |
Node scripts used by Github actions |
src/@newrelic/gatsby-theme-newrelic/ |
Shadowing (replacing) parts of our theme |
src/announcements/ |
MDX files that power our Announcement Banner |
src/components/ |
Docs site-specific React components |
src/content/docs/ |
Main site content (MDX) |
src/content/whats-new/ |
Whats new posts (grouped by date) |
src/data-dictionary/events/ |
Content that powers the Attribute Dictionary |
src/data/ |
Misc. site configuration and state management |
src/i18n/content/ |
Site content in languages other than English |
src/i18n/nav/ |
JSON files for navigation in other languages |
src/i18n/translations |
JSON files for individual translation strings |
src/layouts/ |
React components that control the overall site layout |
src/manual-edits/ |
Content that was adjusted manually during pre-migration development |
src/nav/ |
YAML files for configuring the site navigation |
src/pages/ |
Unique top-level pages (e.g. the 404 page) |
src/templates/ |
React components that control page-specific layout |
src/utils/ |
Constants and common helper utilities |
We use Github actions to perform a number of CI-related tasks. The workflow files are defined via YAML in .github/workflows. Many of them rely on scripts that can be found in scripts/actions/.
NOTE: The translated-related jobs are documented further in an internal document.
| Workflow file | Trigger |
|---|---|
build-cache.yml |
New code pushed to develop
|
Since Amplify does not always accurately communicate the success of PR builds (aws-amplify/amplify-console#550), we run our own build of the site. This will be run when a new pull request is made and is required to pass before new code can be merged into develop.
| Workflow file | Trigger |
|---|---|
build-with-swiftype-content.yml |
Not currently running |
This will run at regular intervals and gather "related resources" for each page using Swiftype. This is done by running a script (yarn run build:related-content), checking in some additional files, and pushing the new content to main. We have a similar action for the developer website that runs every day.
| Workflow file | Trigger |
|---|---|
get-slugs-to-translate.yml |
A pull request, with MDX files, is merged into main
|
This action looks at any PR that contains MDX files. If any of the MDX files have translate in frontmatter, it will save the path to the file in a "to be translated" queue. This queue is sent to our translation vendor via another action (see below).
All of the translation-related workflows use AWS DynamoDB to store state between job runs.
| Workflow file | Trigger |
|---|---|
send-content-to-translate.yml |
Not currently running |
This will run at regular intervals and send everything in the "to be translated" queue to our translation vendor. This allows us to batch translation requests rather than sending a new request for every edit.
All of the translation-related workflows use AWS DynamoDB to store state between job runs.
| Workflow file | Trigger |
|---|---|
check-translations-and-deserialize.yml |
Not currently running |
This will run at regular intervals and check if there are any pages that have been successfully translated by our vendor. If any translation jobs are complete, this will pull down the new content, de-serialize it, and create a new pull request with the translated content.
All of the translation-related workflows use AWS DynamoDB to store state between job runs.
| Workflow file | Trigger |
|---|---|
release.yml |
A pull request is merged into main
|
Creates a New Relic deployment marker using newrelic/deployment-marker-action.
| Workflow file | Trigger |
|---|---|
sync-data-dictionary.yml |
Daily (12am) |
Syncs the attribute definition data from the repository to the data dictionary service.
| Workflow file | Trigger |
|---|---|
validate-pr.yml |
Pull request created into develop or main
|
Builds the site, runs a test suite, and lints the code. This is run on every pull request and is used as an automated way to check if a pull request is "passing".
Below is a high level explanation of the docs site translation workflow. If you need further details on this flow, and work for New Relic, please contact the Developer Enablement team.
- π A PR is opened with a MDX file that contains a translate flag
- π The PR is merged into the main branch
\
- π€ A Github action is run to save the file to a queue
- π€ Once per week, a Github action runs to send the files to our translation vendor
- π€ Once per day, a Github action checks the status of open translation jobs
- π€ If a job is complete, a Github action makes a PR with the new content /
- π The PR is reviewed and merged into main
\
- π€ The new translated content is automatically deployed
The Docs site has JSON and XML data endpoints that can be used however you see fit. These endpoints serve up docs content in a standard easy to use format.
All Agents have an XML endpoint that can be used for RSS readers to fetch release notes data.
These endpoints can be used to fetch all release notes for an agent type.
All security bulletin content is available in an RSS feed.
This endpoint can be used to fetch all security bulletins.
All What's New content in src/content/whats-new is available in an RSS feed.
https://docs.newrelic.com/whats-new/feed.xml
What's new announcements highlight new product features in the New Relic One Platform.
https://docs.newrelic.com/api/nr1/content/nr1-announcements.json
This endpoint can be used to fetch the entire NR1 announcement.
https://docs.newrelic.com/api/nr1/content/nr1-announcements/ids.json
This endpoint can be used to fetch just the ID of the NR1 announcement.