Home

Awesome

Please note - development of sourcstack is currently on hold while I work on a real-world project based on it - https://wastebase.org. I plan to update sourcestack based on the developments made in this project.

sourcestack: a highly adaptable template for full-stack serverless Typescript web apps

sourcestack is a "batteries included" full-stack serverless Typescript web app template, ready to be deployed into your AWS account and adapted to your needs.

sourcestack surfaces all infrastructure as source code, in contrast to frameworks such as AWS Amplify that push infrastructure down into libraries and code generation tools. This gives you total control over your application and ensures that you won't be trapped by the assumptions made by a framework. See Design philosophy for more on this approach.

Demo app

The template is based on a simple todo list app - you can try it out at sourcestack-demo.com

Main features

Technology choices

This version of the template makes certain technology choices:

AspectImplementation
ArchitectureClient-side rendering, REST API, Serverless, NoSQL
UITypescript, Mithril with JSX, TailwindCSS, Parcel (code example)
APITypescript, Express, RESTyped, Parcel (code example)
Test toolsJest, Supertest, Taiko
Infrastructure as codeTypescript, Amazon CDK (code example)
InfrastructureAWS, Route 53, Cloudfront, API Gateway, Lambda, Cognito, SES
DatabaseDynamoDB

If you want to use something else, sourcestack is designed to be forked. Ideas for forks

Just fork this repository and create your own template or app. If you'd like to share it with others, please raise an issue and we'll link to it here.

Architecture

Architecture Diagram

See Code notes for more.

Limitations

The project is at an early stage - we're looking for help and feedback. See Roadmap

Get started: Configure environment

Run the following command to allow the AWS Node.js SDK to read config files:

You might want to put this command into your bash_profile file or similar, so that the environment is always correctly set up.

Deploy the app to your AWS account

The instructions below assume that you have:

WARNING - this will create resources in your AWS account. Charges should be minimal for test workloads, but please be sure that you understand the pricing as per https://aws.amazon.com/pricing.

Run the following commands:

Each "environment" is a self-contained instance of your application and infrastructure, with its own CloudFormation stack (called sourcestack-demo-dev in this case). You might have different environments representing different test stages or feature branches, such as dev, staging, big-ui-refactor, production.

The deploy script will take a while to complete as CDK creates resources for the first time.

The script outputs App running at https://xxxxxxx.cloudfront.net. Later you can add your own domain name.

Get the app running locally

The following will get the UI and API code running locally, using DynamoDB tables and Cognito user pools in AWS (a fully local mode using DynamoDB local and stubbed Cognito is on the roadmap).

Once the app has started, go to https://localhost:1234

Make a UI change

Make an API change

Make an infrastructure change

Note that npm run deploy can be used to build and deploy the complete app (ui, api and infratructure). The deploy-ui, deploy-api and deploy-infra commands provide a faster route to deploy if only a part of the application has changed.

Debug the API locally

Here's how to do this in VS Code:

View API logs on AWS

Change the application name

Create a new environment

Destroy an environment

Add a custom domain name

Use SNS for sending email

By default, your Cognito User Pool sends account verification and password reset emails directly. This has some limitations:

You can configure your User Pool to send emails from SES, meaning that emails will come from your domain with far higher daily sending limits. See Use SNS for sending email

Further reading