Getting Started | Architecture | Development | Trello | Resources
An event-driven serverless microservices financial investment application built with Next.js and Tailwind CSS on Amazon Web Services
This quick start guide describes how to get the application running. An AWS account
is required to deploy the infrastructure required for this project.
-
Clone the project
$ git clone https://github.com/eric-bach/pecuniary.git
-
Install dependencies for CDK
$ cd ./infrastructure $ npm install
-
Install dependencies for the rest of the application using the recursive-install script
$ cd ./infrastructure $ npm cinstall-all
-
Copy the
./infrastructure/.env.example
file to./infrastructure/.env
and fill in the parameter values (if the app has not been deployed to AWS yet, the ARN will be empty for now):DLQ_NOTIFICATIONS - email address to send failed event message notifications to.
-
Copy the
./frontend/.env.example
file to./frontend/.env
and fill in the parameter values from the CDK stack outputs in step 2:NEXT_PUBLIC_USER_POOL_ID= NEXT_PUBLIC_USER_POOL_CLIENT_ID= NEXT_PUBLIC_APPSYNC_API_ENDPOINT= NEXT_PUBLIC_APPSYNC_REGION=
- Follow the steps in Deployment with CDK CLI
-
Start the frontend:
$ cd frontend $ npm run dev
The Pecuniary application consists of the CDK backend and React frontend, each of which has an independent method of deploying. The backend is deployed via CDK where the frontend is deployed via SST.
-
Bootstrap CDK (one-time only)
$ cdk bootstrap aws://{ACCOUNT_ID}/{REGION} --profile {PROFILE_NAME}}
-
Ensure AWS credentials are up to date. If using AWS SSO, authorize a set of temporary credentials
aws sso login --profile PROFILE_NAME
-
Deploy the backend and frontend
$ npm run deploy dev PROFILE_NAME
-
Create an AWS role that can be assumed by GitHub Actions
$ npm run deploy-cicd prod PROFILE_NAME
-
Add the following GitHub Secrets to the repository
Common
CDK_DEFAULT_REGION - AWS default region for all resources to be created
Dev environment
CLOUDFRONT_DOMAIN_DEV - AWS CloudFront Distribution domain name COGNITO_USERPOOL_ID_DEV - Cognito User Pool Id COGNITO_WEB_CLIENT_ID_DEV - Cognito User Pool Client Id APPSYNC_ENDPOINT_DEV - AWS AppSync GraphQL endpoint URL CYPRESS_USERNAME - A valid Cognito username for Cypress integration testing CYPRESS_PASSWORD - The Cognito password for Cypress integration testing
Production environment
AWS_SERVICE_ROLE_PROD - AWS ARN of the GitHub Actions Role to Assume (from step 1) CERTIFICATE_ARN - ARN to ACM certificate for CloudFront Distribution HOSTED_ZONE_ID - Route53 Hosted Zone ID HOSTED_ZONE_NAME - Route53 Hosted Zone Name DLQ_NOTIFICATIONS - email address to send DLQ messages to CLOUDFRONT_DOMAIN_PROD - AWS CloudFront Distribution domain name COGNITO_USERPOOL_ID_PROD - Cognito User Pool Id COGNITO_WEB_CLIENT_ID_PROD - Cognito User Pool Client Id APPSYNC_ENDPOINT_PROD - AWS AppSync GraphQL endpoint URL
To be added
To be added
Test the frontend using cypress
$ npm run cypress:open
or headless,
$ npm run cypress:run
Ensure to configure the GitHub Secrets to include:
```
CYPRESS_USERNAME - A valid Cognito username for Cypress integration testing
CYPRESS_PASSWORD - The Cognito password for Cypress integration testing
```
For more detailed information about the event-driven nature of the Pecuniary application and it's architecture, please see the Architecture.md
Links to additional documentation specific to the Application
- Saved GraphQL queries/mutations for GraphiQl
- How to add a new GraphQL API/Command Handler
- How to call an authenticated AppSync GraphQL API with Apollo Client
Various links to additional articles/tutorials used to build this application.
- How to build an authenticated GraphQL AppSync API with CDK
- How to perform a GraphQL Query with Apollo using React hooks
- How to perform a GraphQL Mutation with Apollo using React hooks
- How to add a protected route to React
- How to authenticate with Cognito using React hooks
- How to add a user to a Cognito User Group
This project is licensed under the terms of the MIT license.