Skip to content

Site Architecture

Zack Stickles edited this page Feb 24, 2021 · 64 revisions

How does this thing work?

Table of Contents

πŸ₯ž Stack

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.

🎸 JAMstack

JAM stands for Javascript, APIs & Markup. A core part of the site architecture is Gatsby which is uses 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.

πŸ›  Tools

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

πŸ”Œ Gatsby plugins

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.

🎨 Gatsby theme

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.

🌐 Hosting and deployment

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:

  1. Build the site by running yarn build:production.
  2. If the build succeeds, deploy the new version.
  3. 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.

πŸ–₯ Local development

To run the project locally, you will need the following dependencies:

  • Node 12.x
  • Yarn

To get the project running locally, follow these steps:

  1. Clone the repository.
  2. Install the dependencies by running yarn.
  3. 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.

πŸ—‚ Directory structure

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/
  | images/
  | layouts/
  | manual-edits/
  | nav/
  | pages/
  | templates/
  | utils/
static/
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

πŸ€– Github actions

Content coming soon.

Clone this wiki locally