/aws-cloud-apps

A simple, responsive web application to take notes, built with JavaScript, designed as starting point to build complex web applications. Hosted on AWS.

Primary LanguageJavaScript

aws-cloud-apps · GitHub license CircleCI Status PRs Welcome

A simple, responsive web application to take notes, built with JavaScript, designed as starting point to build complex web applications. Each application in the system can be run independently with Docker or npm. Unit, integration and end-to-end (e2e) tests are available. Development, release, integration and e2e test environments can be simulated with Docker Compose.

This project is a modernized version of cloud-apps, hosted on AWS. The upgrade introduced new technology to the stack, including React + Next, GraphQL, Automated database tests & migrations, and Playwright end to end tests.

Table of contents

Quickstart

Recommended - Run environments with Docker Compose

Docker is required.

Run Development environment

docker-compose -f dev.yaml up

Run Release environment

docker-compose -f release.yaml up

Run Integration tests environment

docker-compose -f integration-tests.yaml up --exit-code-from integration

Run End to end tests environment

docker-compose -f e2e-tests.yaml up --exit-code-from e2e

Run Data migrations environment

docker-compose -f migrations.yaml up

Run Data tests environment

docker-compose -f data-tests.yaml up --exit-code-from data_tests

Run environments with NPM and Docker Compose

Node.js v20.9.0 or higher and Docker are required.

Run Development environment

npm run dev

Run Release environment

npm run start

Run Integration tests environment

npm run integration-tests

Run End to end tests environment

npm run e2e-tests

Run Data migrations environment

npm run migrations

Run Data tests environment

npm run data-tests

Run applications individually with NPM or Docker

Find detailed instructions on how to run each application within the Application docs.

Usage instructions

A new note can be created in a few simple steps:

1. Add note

Add note

2. Create and save note

Create note

3. New note created

Note created

Core concepts

As a modernized version of cloud-apps, this project introduces new concepts that should facilitate development for complex use cases, including:

  1. Hosted on AWS
  2. Enterprise-grade blueprint for CI/CD with CircleCI
  3. End to end tests with Playwright
  4. Automated database migrations & tests
  5. Lightweight dependencies for fast build and test times
  6. GraphQL to simplify RESTful endpoints

In addition to the new core concepts, this project shares the same core concepts as cloud-apps, including:

  1. Container orchestration for scale
  2. Automated test pyramid
  3. Blueprint for automated tests with CircleCI
  4. Full stack system built with JavaScript
  5. Starting point for more complicated use cases

Hosted on AWS

The project's Client, API and Database are hosted on AWS. Leveraging CircleCI, the Client and API Docker images are built & deployed to AWS' Elastic Container Registry(ECR), then hosted with Elastic Container Service (ECS) and Fargate. The database is hosted on AWS' Relational Database Service(RDS).

The diagram below outlines how network connections are managed between resources in AWS:

AWS network

A cloud-like network can be simulated with Docker Compose. The diagram below outlines Docker Compose network connections:

System overview

Enterprise-grade blueprint for CI/CD with CircleCI

Unit tests for the Client, API and Database are run on every pull request to Github, using CircleCI. Once the unit tests have passed, integration tests are run, validating API and Database updates. After integration tests pass, e2e tests are run, validating that the Client, API and Database work as expected with the new updates. Once all tests have passed, the pull request can be merged to the main branch, which kicks off deployments.

Deployments begin by simultaneously running the jobs to build & deploy application Docker images and Database migrations. Once Docker images have been deployed to ECR, CircleCI updates ECS with the new Docker images, performing rolling deployments for the new application versions.

Following the fail-fast automated testing approach, the system provides a starting point (or blueprint / boilerplate) as-is for more complex automated testing requirements. The diagram below outlines how code updates are validated then deployed with Github and CircleCI:

CI/CD with Github and CircleCI

End to end tests with Playwright

Playwright is a popular end to end testing framework, allowing developers to write tests in JavaScript, Python, Java, or .NET. Helpful tools like the UI mode make it easy to debug web applications in real time.

Playwright UI mode

This project provides a starting point for Playwright end to end tests with JavaScript, leveraging page object models. Basic smoke and health tests are provided. To learn more, feel free to read the end to end tests docs.

Playwright UI mode

Playwright simplifies the required infrastructure to run e2e tests, since the library provides out-of-the-box browsers and connects to browsers internally without the need of a seperate hub.

The diagram below outlines the simplified network created by Docker Compose, for e2e tests, including application connections, ports, routes and tools:

e2e system

Automated database migrations & unit tests

Automated database migrations are available to facilitate database integrity and updates with automation.

Database migrations

To accompany programmatic database schema and structure updates, database updates are validated with unit tests using the Jest and pg npm libraries. Tests are provided for health checks, migrations and common queries.

Database tests

Lightweight dependencies for fast build and test times

Build times are improved through NPM's development only installations , production only installations, CircleCI caching and Docker. Build & run times for each test application is less than a minute, with the exception of end to end tests, which install and run the entire system.

Lightweight dependencies

GraphQL to simplify RESTful endpoints

GraphQL simplifies the code required manage RESTful API endpoints and responses. Apollo Server provides helpful tools to debug, and simplify maintenance of GraphQL APIs.

Apollo server sandbox

Application docs

Client
API
Database
Integration tests
End to end tests

Tools and frameworks

Node.js
Docker
CircleCI
AWS
React
Next.js
GraphQL
Apollo Server
PostgreSQL
Jest
Supertest
Playwright

How to contribute

Commits

Our commits follow the Angular commit styleguide. Each commit should be carefully thought out and only contain files affected within the scope of the commit message.

Branching

A branch's name should reference a story and the type of work being committed.

Pull Requests

Each pull request must pass a review from another contributor and all automated tests.

Issues

Feel free to open an issue ticket, please leave a screenshot and a detailed instructions on how to replicate the issue.

License

This repository is protected under the MIT License.