Accedo Assemble Web
For a detailed overview of Assemble across platforms please visit Assemble Confluence Page
What is Assemble
The solution is the combination of all the software and services required to deliver an OTT video service. The solution
- is an end-to-end blueprint for video service providers in Media & Entertainment.
- has been designed to support service providers looking to outsource the technology and the operation of their existing or planned OTT video service.
- includes all people, processes and tools involved in the operation and evolution of the service.
Getting Started
Project Setup
Prerequisites
Assemble Web uses pnpm as dependency manager, if you want to use another alternative, please go to package.json file and update the packageManager value.
For more information, please visit official node section about packageManager.
We use nvm to select proper node version.
Install dependencies and run app
Before installing dependencies, you will need to have a valid npm config for the @accedo scoped packages. Follow the instruction in https://accedobroadband.jira.com/wiki/spaces/BW/pages/168100346/How+to+Access+the+Accedo+Build+Web+npm+Modules#Setup-Accedo-Artifactory-with-scoped-packages to configure your npm using the required scoped packages.
Note: A SESSION_KEY environment variable is required in order to handle the session, so before anything, run:
openssl rand -hex 64
and paste it as SESSION_KEY=<your-generated-key> into your .env.local file
# First, install nvm, the node version used in this project is defined in the .nvmrc file.
nvm use
corepack enable pnpm
pnpm i
# Run the development server
pnpm dev
dev server watch
Sometimes .next folder with cached build chunks, and missing dependencies can cause issues when changing branch. .next folder is automatically removed when dev server is started, but pnpm dev needs to be restarted manually. use pnpm dev:watch to start dev server and automatically install dependencies and restart dev server when branch changes.
Debug the application
Building locally
- New relic secret values are injected when building on github. These are required for the build to complete. When building locally the same values need to be available, or set environment variable
ENABLE_NEW_RELIC=false. - If build fails on github but works locally, one issue can be filename casing - build environment on github is case sensitive, but local environment may not be. git will also not always recognize file name changes when only the casing is changed, so file name changes may not have been committed as expected.
Using Assemble Web as a template for your repo
If you are using Assemble Web as a template to create your own updated version of Assemble Web, there are some things you need to take into account:
- Please read our Assemble Control Setup instructions and ensure that those are followed
- Create your set of repository variables and secrets
- [Optional] Create an
.envfile for any custom environment variable. Please, review Our environments variable type definition to understand which one are needed.
Variables:
APP_DOMAIN_DEV_ASSEMBLE: Non-Production application base domain (dev.bp.accedo.tv). Please Sync with the DevOps team for the associated deploymentsAPP_DOMAIN_PROD_ASSEMBLE: Production application base domain (prod.bp.accedo.tv). Please Sync with the DevOps team for the associated deploymentsCI_APPNAME_ASSEMBLE: Next Application appname to be used in the deployment process and hostDOC_APPNAME_ASSEMBLE: Doc Application appname to be used in the deployment process and hostSTORYBOOK_APPNAME_ASSEMBLE: Storybook Application appname to be used in the deployment process and hostAWS_CLUSTERNAME_DEV_ASSEMBLE: Non-Production Cluster name for the deployment. Please Sync with the DevOps to understand the value you should use here.AWS_CLUSTERNAME_PROD_ASSEMBLE: Production Cluster name for the deployment. Please Sync with the DevOps to understand the value you should use here.AWS_REGION: AWS region to be used by default on the deployments. Please Sync with the DevOps to understand the value you should use here.TESTRAIL_PROJECTID: TestRail Project IDTESTRAIL_SUITEID: TestRail Suite IDTESTRAIL_TITLE: TestRail Run base titleTESTRAIL_URL: TestRail Base URLNEW_RELIC_APP_NAME_DEV: New Relic Application name. Please ask your Architect/PM for a project specific value.NEW_RELIC_APP_NAME_PROD: New Relic Prod Account Application name. Please ask your Architect/PM for a project specific value.
Note: We also use DEMO1_APPNAME_ASSEMBLE and DEMO2_APPNAME_ASSEMBLE for our internal demo purposes, but you won't need those.
Secrets:
AWSARN_DEV_ASSEMBLE: Non-Production AWS Amazon Resource Name to be used in the deployments. Please Sync with the DevOps to understand the value you should use here.AWSARN_PROD_ASSEMBLE: Production AWS Amazon Resource Name to be used in the deployments. Please Sync with the DevOps to understand the value you should use here.FIGMA_TOKEN: Figma API Token to be used to be able to fetch the Design Tokens from your the Figma files associated with the project. Please avoid using personal token and use a "corporate" one instead.NEW_RELIC_LICENSE_KEY_DEV: New Relic license key. Please ask your Architect/PM for a project specific value.NEW_RELIC_LICENSE_KEY_PROD: New Relic Prod account license key. Please ask your Architect/PM for a project specific value.NPM_RESOLVER: npm token to be used to fetch the@accedoand similar private dependencies from the npm registry. Please avoid using personal token and use a "corporate" one instead.SLACK_WEBHOOK: Slack Application webhook token. Please Sync with the DevOps/IT to understand the value you should use here.SONAR_TOKEN: SonarCloud access token to allow the CI to report to Sonar. Please Sync with the DevOps/IT to understand the value you should use here.TESTRAIL_KEY: TestRail User apiKeyTESTRAIL_PROJECT: TestRail Project NameTESTRAIL_USER: TestRail user emailE2E_EMAIL: Application username to be used on the e2e testsE2E_PASSWORD: Application password to be used on the e2e tests
NPM Scripts
Project App Structure
Assemble Web is a Next.js based application, so some conventions are based on the conventions defined in the framework itself, we recommend you to read at least App Routing Conventions
Component Structure
All the Web Reels/Core Components uses it's own repository: assemble-web-core.
Inside this repo, we are following a Component structure based on two concepts:
- Complexity-based: reusable components that can be used across any page/template, with a separation in two:
- simple: stateless, very reusable components
- complex: Usually composed from other simple components and can have state
- Feature-based: every complex component, that is not going to be reusable, but just part of an specific feature (EPG, Auth, Player, ...)
Besides that, we need to take into account that Pages/views and partially, any possible route-based template will be created under the app folder following the App Routing Conventions from Next.js
The reason to keep this structure and not a pure Atom-based model is to avoid having all the components under the components folder, making very hard to traverse and look for the proper component, but limit it with the feature-based list of components and then simplify the 3-4 other layers (pages/views should be always under the app folder due to Next.js) into 2 at least initially to have a clear separation for the atomic, non-composed ones (and also stateless) from the others.
General Structure
📂 docs ───────> project documentation
📂 public ───────> web static assets
📂 scripts ───────> general scripts used locally
📂 src ───────> source dir
├─ 📂 app ───────> next.js routes
│ └─ 📂 [[...routeSegments]] ───────> Single dynamic route page (more on the next section)
│ └─ 📄 layout ───────> default page layout
│ ...
├─ 📂 components ───────> Complexity-based Components folder
│ └─ 📂 simple ───────> Simple Components (Not composed and without state or non-migrated/In progress/on a Figma branch Reels components)
│ └─ 📂 base ───────> Reels Components (Component from the Component library based on PD&A Reels) non-migrated/In progress/on a Figma branch
│ └─ 📂 complex ───────> Complex Components (composed from simple components or with state)
├─ 📂 config ───────> Application configuration
├─ 📂 context ───────> App global React contexts
├─ 📂 dataModels ───────> Any app data model
├─ 📂 dataTypes ───────> Data types generated from api documentation
├─ 📂 dev-utils ───────> Utilities used for development purposes
├─ 📂 features ───────> Feature-based Components folder
│ └─ 📂 ... ───────> A per feature folder, it will include all the needed code outside of the Data Fetching related one
├─ 📂 hooks ───────> App hooks, use for common shared utilities fns and Service access
├─ 📂 stores ───────> Global state management using Zustand, for shared application state
├─ 📂 providers ───────> App Providers (as per the Assemble Service Architecture)
├─ 📂 services ───────> App Services (as per the Assemble Service Architecture)
├─ 📂 types ───────> Typescript type utilities and global types
├─ 📂 utils ───────> Global utils
├─ 📂 views ───────> Application dynamic views (mapped from [[...routeSegments]]) and mapper
📄 .env ───────> environment variables
📄 next-env.d.ts ───────> next.js type defs
📄 next.config.js ───────> next.js config
📄 package.json ───────> project readme