{"id":13674831,"url":"https://github.com/erezrokah/serverless-monorepo-app","last_synced_at":"2025-04-09T18:18:47.806Z","repository":{"id":34671458,"uuid":"140697438","full_name":"erezrokah/serverless-monorepo-app","owner":"erezrokah","description":"Serverless Monorepo App","archived":false,"fork":false,"pushed_at":"2025-03-31T19:23:47.000Z","size":9049,"stargazers_count":204,"open_issues_count":23,"forks_count":28,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T18:18:41.393Z","etag":null,"topics":["circleci","frontend","monorepo","sendgrid","serverless","services"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erezrokah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-12T10:18:47.000Z","updated_at":"2025-03-31T02:53:15.000Z","dependencies_parsed_at":"2023-12-25T01:42:51.508Z","dependency_job_id":"27801973-6d48-4d10-a277-91da7f7222a0","html_url":"https://github.com/erezrokah/serverless-monorepo-app","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezrokah%2Fserverless-monorepo-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezrokah%2Fserverless-monorepo-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezrokah%2Fserverless-monorepo-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezrokah%2Fserverless-monorepo-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erezrokah","download_url":"https://codeload.github.com/erezrokah/serverless-monorepo-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circleci","frontend","monorepo","sendgrid","serverless","services"],"created_at":"2024-08-02T11:01:03.623Z","updated_at":"2025-04-09T18:18:47.785Z","avatar_url":"https://github.com/erezrokah.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Serverless Monorepo App\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CircleCI](https://circleci.com/gh/erezrokah/serverless-monorepo-app.svg?style=svg)](https://circleci.com/gh/erezrokah/serverless-monorepo-app)\n\nThis application is structured as a monorepo which means all the different packages sits under the same GitHub repository.\n\nIt makes it easier to have CI/CD and automate dependency management.\n\nFor example, under `frontend` sits the React application which consumes the services under `services`.\n\nSince the endpoint urls for the services change between environments (dev/qa/prod) we need to setup the frontend app correctly.\n\nSince all of our code sits in the same repository, we can update the frontend app environment based on the services deployment with ease.\n\nThis application uses `Auth0` for authentication, `Sendgrid` for sending emails, `CircleCI` for deployment and `AWS` as a cloud provider.\n\n## Resources Used\n\n- \u003chttps://serverless.com/blog/anatomy-of-a-serverless-app/\u003e\n- \u003chttps://serverless.com/blog/ci-cd-workflow-serverless-apps-with-circleci/\u003e\n- \u003chttps://serverless.com/framework/docs/providers/aws/guide/testing/\u003e\n- \u003chttps://github.com/serverless/examples/tree/master/aws-node-single-page-app-via-cloudfront\u003e\n- \u003chttps://github.com/serverless/examples/tree/master/aws-node-auth0-custom-authorizers-api\u003e\n- \u003chttps://serverless-stack.com/chapters/deploy-again.html\u003e\n- \u003chttps://github.com/serverless-heaven/serverless-webpack\u003e\n- \u003chttps://github.com/sbstjn/serverless-stack-output\u003e\n- \u003chttps://github.com/wmonk/create-react-app-typescript\u003e\n\n## Prerequisites\n\n[Nodejs](https://nodejs.org/en/) (at least version 8)\n\n[Yarn](https://yarnpkg.com/lang/en/)\n\nAmazon AWS account and `awscli` installed and configured: \u003chttps://aws.amazon.com/getting-started/\u003e\n\nCircleCI [account](https://circleci.com/signup/)\n\nServerless [CLI](https://serverless.com/framework/docs/getting-started/)\n\n[Auth0 account](https://auth0.com/)\n\n[Sendgrid account](https://sendgrid.com/) for the email service\n\n## Repository structure\n\nThis repository uses [lerna](https://lerna.js.org/) and yarn workspaces to handle dependencies.\n\nThe React frontend app sits under `frontend/`.\n\nThe Serverless services sit under `services/`.\n\nShared services code is under `services/common/` (e.g. both `api-service` and `email-service` use the same authentication handler).\n\nTypescript is used across the repository.\n\n## Setup\n\nInstall Dependencies\n\n```bash\nyarn install\n```\n\nCI/CD is setup for 3 different environments: `dev` (for local development), `qa` (for integration tests) and `prod` (production).\n\n### Setup Environments\n\nThis part can be a bit tedious, but you only have to do it once.\n\n#### Sendgrid\n\n[Open Sendgrid settings](https://app.sendgrid.com/settings/api_keys)\n\nFor sending emails you'll need a Sendgrid API key for each environment you'll want to have (3 keys if you want `dev`,`qa` and `prod`).\n\nLogin into your Sendgrid account and create an API key (with email sending permissions) for each environment (you can name them `Serverless App Dev`, `Serverless App QA`, etc.).\n\nMake sure to copy the API keys somewhere as you'll only see them once.\n\n#### Auth0\n\n[Open Auth0 management dashboard](https://manage.auth0.com)\n\nThe way to create different environments in Auth0 is to use something called **Tenants**.\n\nYou should create a tenant for each environment you'd like to use (you do it by clicking the icon for your account and choosing **Create tenant**).\n\nA common setup is to have tenants named `mydomain-dev` for development, `mydomain-qa` for QA and `mydomain` for production.\n\nAfter creating the relevant tenants you'll need to create an application (you can name it `Serverless Test App` or something similar).\n\nYou'll need your application's `Domain`, `Client ID`, `Audience` and the public key of the signing certificate.\n\n`Domain` and `Client ID` are under `applications-\u003e${YOUR_APP_NAME}-\u003esettings`.\n\n`Audience` is usually `https://YOUR_DOMAIN/userinfo` and to get the certificate you'll need to scroll down, go to `Show Advanced Settings-\u003eCertificates-\u003eDOWNLOAD CERTIFICATE`.\n\nYou should save the certificate in `PEM` format.\n\n#### Setup Dev Environments Files\n\nRun the following command to create the `dev` config files (make sure to update `your_certificate.pem`)\n\n```bash\ncp frontend/.env.example.local frontend/.env.local\ncp services/common/environment/config.example.json services/common/environment/config.dev.json\ncp services/email-service/config.example.json services/email-service/config.dev.json\nmv your_certificate.pem services/common/environment/public_key.dev.pem\n```\n\nUpdate `frontend/.env.local`, `services/common/environment/config.dev.json` and `services/email-service/config.dev.json` with the relevant values.\n\n#### Setup CircleCI\n\nYou'll need to add your project in CircleCI. In order to do it you'll probably need to fork this repository.\n\nAfter you've done that you should add your AWS credentials under `Settings-\u003eAWS Permissions` (you should create a separate IAM User for that)\n\nThe last part left is to setup `qa` and `prod` environment variables for your project.\n\nUnder `Settings-\u003eEnvironment Variables` add the following items (update the values):\n\n```bash\nPROD_AUTH0_AUDIENCE\nPROD_AUTH0_CLIENT_ID\nPROD_AUTH0_DOMAIM\nPROD_AUTH0_PUBLIC_KEY # This value should be base64 encoded, run `base64 ${LOCATION_TO_PEM_FILE}` to get the value\nPROD_REGION # You can use `us-east-1` at the moment\nPROD_SENDGRID_API_KEY\nQA_AUTH0_AUDIENCE\nQA_AUTH0_CLIENT_ID\nQA_AUTH0_DOMAIM\nQA_AUTH0_PUBLIC_KEY # This value should be base64 encoded, run `base64 ${LOCATION_TO_PEM_FILE}` to get the value\nQA_REGION # You can use `us-east-1` at the moment\nQA_SENDGRID_API_KEY\n```\n\n## Deployment\n\nDevelopment environment\n\n```bash\nyarn deploy:dev # deploys services and updates frontend configuration\nyarn build:frontend # builds frontend application\nyarn publish:frontend:dev # deploys frontend application\n```\n\nQA environment will be deployed automatically on each commit to master\n\nProduction environment will be deployed automatically on each version tag push, for example the following will trigger a production deployment:\n\n```bash\ngit tag \"v0.0.1\"\ngit push --tags\n```\n\n## Post Deployment Setup\n\nAfter deploying there is one last step to get Auth0 to work.\n\n[Open Auth0 management dashboard](https://manage.auth0.com) and go to `applications-\u003e${YOUR_APP_NAME}-\u003esettings`.\n\nUpdate `Allowed Callback URLs` with:\n\n```bash\nhttp://localhost:3000/callback,http://localhost:5000/callback,https://YOUR_CLOUDFRONT_DOMAIN/callback\n```\n\nUpdate `Allowed Web Origins` with:\n\n```bash\nhttp://localhost:3000,http://localhost:5000,https://YOUR_CLOUDFRONT_DOMAIN\n```\n\nYou can get the domain value from here: \u003chttps://console.aws.amazon.com/cloudfront/home\u003e\n\n## Run Tests\n\n```bash\nyarn test\n```\n\n```bash\nyarn coverage\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferezrokah%2Fserverless-monorepo-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferezrokah%2Fserverless-monorepo-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferezrokah%2Fserverless-monorepo-app/lists"}