Project Layout

Architect projects have a .arc, arc.yaml or arc.json manifest file in the root. This captures the infrastructure requirements beside the code it will run in your revision control. Architect favors convention over configuration and projects have the following significant folder structure:

/
|- public ......... static assets (js, css, svg, images, etc)
|- src 
|  |- shared ...... code shared by ALL Lambda functions
|  |- views ....... code shared by HTTP GET Lambda functions
|  |- http ........ HTTP Lambda functions
|  |- events ...... Event Lambda functions
|  |- queues ...... Queue Lambda functions
|  |- scheduled ... Scheduled Lambda functions
|  |- tables ...... Table Trigger Lambda functions
|  '- ws .......... Web Socket Lambda functions
'- .arc 

All folders are OPTIONAL. Architect ignores any other folders.


Configuration Reference

The .arc manifest can be broadly split into three sections:

System config

These sections are for global system level env configuration. The most important being the @app namespace which is used to prefix all generated resources.

  • @app [Required] The application namespace
  • @domain Assign a domain name to your app (ACM, API Gateway, and Route 53)
  • @aws AWS config

Lambda Function config

These sections deal with Lambda functions and their event sources. By convention Architect promotes one event source per function.

  • @http HTTP routes (API Gateway)
  • @events Event pub/sub (SNS)
  • @queues queues and handlers for them (SQS)
  • @scheduled Invoke functions specified times (CloudWatch Events)
  • @ws Web Socket functions (API Gateway)

Persistence config

These sections deal with config of various persistence resources.

  • @static Buckets for hosting static assets (S3)
  • @tables Database tables and trigger functions (DynamoDB)
  • @indexes Table global secondary indexes (DynamoDB)

👉🏽 .arc comments out anything after hash symbol #.

Example

Provision a project with the following .arc file:

# this is going to be great!
@app
testapp

@events
hello

@http
get /
get /posts # the posts go here

Running npx create creates the following code:

/
|-src
| |-events
| | '-hello/
| '-http
|   |-get-index/
|   '-get-posts/
'-.arc

The generated code was also immediately deployed to the built-in staging environment. Subsequent edits to the local code are deployed by running npx deploy.

Happy with staging? Ship a release to production by running npx deploy production.

Time to celebrate! ✨

Next: What next?