This document tries to outline all the conventions/tools/services used to make Atlas work.
- React
- Typescript
- GraphQL (+ Relay-style pagination) with Apollo Client
- Prettier, ESLint, Stylelint - for enforcing common code style
- Emotion - for all the styling
- Zustand - for simple local state management
Please note that this repo is based on Yarn Workspaces and because of that, to install new dependency from root, you need to use the following pattern: yarn workspace [package_name] add [dependency_name]
. You also have the option to install dependencies directly from package directory using yarn add [package_name]
.github/
- GitHub stuff - currently PR checks actionsci/
- continuous integration stuffnginx/
- nginx config directorybuild-docker-atlas.sh
- build script for atlas app Dockerbuild-docker-meta-server.sh
- build script for meta server Dockerdocker-compose.yml
- docker compose for meta server Dockers
docs/
- Atlas-related documentation - technical & communitypackages/
- workspace appsatlas/
- main app.storybook/
- Storybook configurationpublic/
- static assets used to build the appscripts/
- some helper scripts for commonsrc/
- the source codeapi/
- everything related to integrations with external servicesassets/
- assets to be used from within the source code - images/animations/etc.components/
- components used by Atlasconfig/
- everything related to config - route URLs, env variables, etc.hooks/
- hooks for reusable functionalitiesjoystream-lib/
- code for interacting with the Joystream blockchainproviders/
- contexts, stores and logic for different featuresstyles/
- theme for styling the app - design tokens, global stylestypes/
- global Typescript related codeutils/
- common utilities - e.g. for formatting dates etc.views/
- all the top-level views displayed by the routermain.tsx
- app entry-pointApp.tsx
- React entry-point
atlas-meta-server
- meta tags pre-rendering serveratlas-proxy-worker
- Cloudflare Worker to enable Atlas social previews on Cloudflare edge networkatlas-geolocation-worker
- Cloudflare Worker to enable picking closes distribution operatorsatlas-avatar-service
- users avatars upload service
We currently use GitHub actions and Vercel for all our DevOps needs. On every PR we run GitHub actions to ensure the code follows the linting rules. Also, for every PR, Vercel previews are generated so that it's easy to explore the updated app.
The deployed version of Atlas (at https://play.joystream.org) is also hosted by Vercel. This one gets redeployed on every push/merge to master.
Atlas is versioned using Semantic Versioning. The version is stored in package.json
in the packages/atlas
package. There is also a CHANGELOG.md
file in the root of the repo that contains all the changes between versions. Every PR that contains non-trivial change should add entry to the CHANGELOG.md
file in the Unreleased
section, explaining what was changed.
Whenever we merge to master
, we should create a new release. This is done by:
- Creating a
release: X.Y.Z
(whereX.Y.Z
is the version number) commit that bumps version inpackages/atlas/package.json
and replaces theUnreleased
section inCHANGELOG.md
with appropriate version number. - Creating a Git tag in the format
vX.Y.Z
. - Pushing the commit and the tag to
master
. - Creating a new GitHub release with the same version number as the tag, and supplying it with the
CHANGELOG.md
entries.
Because social media crawling bots can't handle SPA apps, we decided to pre-render HTML meta tags for social media previews purposes. Whenever a request from a social media crawler (detected via User-Agent
header), we redirect it to the atlas-meta-server
which returns pre-rendered HTML, in any other case regular application is served.
There are 2 methods of handling the incoming traffic and redirecting:
- For self-hosted version of Atlas - docker-compose setup located in
ci/
directory. This will run docker-compose with NGINX that redirects any incoming traffic. Social crawlers' requests get sent toatlas-meta-server
instance, and otherwise static files are served. - For jsgenesis-run Atlas production instance - Cloudflare Worker setup located in
packages/atlas-proxy-worker
. This method uses Cloudflare Workers that runs redirection logic on Cloudflare edge network, allowing redundancy and very fast response times. If the request is a regular one, it gets redirected to Vercel deployment.
To build and run atlas-meta-server
for production:
yarn docker:meta-server
docker run -e GRAPHQL_URL=https://orion.joystream.org/graphql -p 80:80 -d joystream/atlas-meta-server
To run full self-hosted setup:
yarn docker:atlas
yarn docker:meta-server
cd ci
docker-compose up -d
As explained in the architecture doc, distribution providers are used to fetch assets from the Joystream storage network. To pick the closest providers and ensure the best latency, Atlas uses a Cloudflare Workers that acts as a serverless function, returning the user's location (latitude + longitude), based on their IP address. This location is later used to find the closest distributors. Code for this worker can be found in packages/atlas-geolocation-worker
.
For full technical overview of Atlas architecture, see architecture.md.
All styles for components/views used in Atlas should use design tokens defined by the designers. You can find the raw tokens inside the atlas-resources repo. The tokens define things like colors, typography, borders, etc. There is a script called tokens
(yarn tokens
) that will fetch the latest tokens from the resources repo and build them into usable CSS variables. Then in any place in the code you can import the cVar
function from @/styles
and use any of the tokens. Example:
import { cVar } from '@/styles'
const Component = styled.div`
background-color: ${cVar('colorBackground')}; // this will translate into var(--color-background)
`
Atlas uses a bunch of different SVG files for icons and illustrations. All of those are pre-processed via a yarn svgs:illustrations
/ yarn svgs:icons-generate
script that generates React components out of SVGs using svgr. Then we import those components inside our code.
All icons used in the app are created by the Atlas design team and come from Figma. To make the workflow easier, we have created a script that fetches all the icons directly from Figma and saves them in the repo. This way we can make always keep Figma and the app up to date. The script can be found in scripts/figma-import
and can be run with yarn svgs:icons-import
.