Sample Project

A complete example using all nine component types, variable substitution, and all supported component relationships. This is the reference configuration used throughout the documentation.

Architecture Overview

  • frontend (website) — serves the SPA from a CDN-backed bucket it provisions automatically; accessible at www.testapplication.com
  • main-api (api-gateway) — routes HTTP requests to functions, validates JWTs; accessible at api.testapplication.com
  • app-functions (functions) — group containing api-handler and event-processor; code loaded from deploy-artifacts storage
  • app-db (database) — stores application data
  • deploy-artifacts (storage) — holds the deployable JAR artifacts
  • asset-store (storage) — stores user-uploaded files
  • user-auth (authentication) — manages user sign-up, sign-in, MFA
  • transactional-email (email) — sends verification and notification emails
  • notification-sms (sms) — sends OTP codes and alerts
  • domain-events (event-bus) — decouples event publishing from processing

Full Configuration

{

  "name": "Test Application",

  "description": "A sample project demonstrating all component types",

  "application": "com.sample.testapplication",

  "provider": "aws",

  "variables": {

    "env": "prod",

    "region_primary": "eu-west-2"

  },

  "regions": [

    {

      "region": "global",

      "items": [

        {

          "type": "authentication",

          "name": "user-auth",

          "loginProviders": ["email"],

          "mfa": "optional",

          "passwordPolicy": { "minLength": 10, "requireSymbols": true },

          "references": ["transactional-email", "notification-sms"]

        },

        {

          "type": "email",

          "name": "transactional-email",

          "fromAddress": "noreply@testapplication.com",

          "fromName": "Test Application"

        },

        {

          "type": "sms",

          "name": "notification-sms",

          "senderId": "TestApp",

          "messageType": "TRANSACTIONAL"

        }

      ]

    },

    {

      "region": "${region_primary}",

      "items": [

        {

          "type": "storage",

          "name": "deploy-artifacts",

          "versioning": true,

          "uploads": [

            {

              "artifact": "com.sample:api-handler:1.0.0",

              "destination": "releases/api-handler/",

              "unpack": false

            },

            {

              "artifact": "com.sample:event-processor:1.0.0",

              "destination": "releases/event-processor/",

              "unpack": false

            }

          ]

        },

        {

          "type": "storage",

          "name": "asset-store",

          "versioning": false,

          "lifecycleDays": 365

        },

        {

          "type": "database",

          "name": "app-db",

          "partitionKey": "userId",

          "billingMode": "PAY_PER_REQUEST",

          "pointInTimeRecovery": true

        },

        {

          "type": "functions",

          "name": "app-functions",

          "codeStorage": "deploy-artifacts",

          "codePath": "releases/app-functions/app-functions-1.0.0.jar",

          "functions": [

            {

              "name": "api-handler",

              "handler": "com.sample.ApiHandler::handleRequest",

              "runtime": "java21",

              "memoryMb": 1024,

              "timeoutSeconds": 30,

              "environment": { "ENV": "${env}" },

              "references": ["app-db", "asset-store", "transactional-email", "notification-sms", "domain-events"]

            },

            {

              "name": "event-processor",

              "handler": "com.sample.EventProcessor::handleRequest",

              "runtime": "java21",

              "memoryMb": 512,

              "timeoutSeconds": 60,

              "references": ["app-db", "domain-events"]

            }

          ]

        },

        {

          "type": "api-gateway",

          "name": "main-api",

          "domain": "api.testapplication.com",

          "throttlingRateLimit": 1000,

          "routes": [

            { "method": "ANY", "path": "/api/{proxy+}", "function": "api-handler", "auth": "user-auth" }

          ]

        },

        {

          "type": "website",

          "name": "frontend",

          "domain": "www.testapplication.com",

          "indexDocument": "index.html",

          "errorDocument": "index.html",

          "httpsOnly": true,

          "references": ["main-api"]

        },

        {

          "type": "event-bus",

          "name": "domain-events",

          "subscriptions": [

            { "eventType": "order.created", "function": "event-processor", "batchSize": 10, "retryAttempts": 3 }

          ]

        }

      ]

    }

  ]

}

Deploying the Sample

# 1. Configure credentials (AWS example)

export AWS_ACCESS_KEY_ID=...

export AWS_SECRET_ACCESS_KEY=...

export AWS_DEFAULT_REGION=eu-west-2

 

# 2. Validate

mvn serverless:validate

 

# 3. Preview changes

mvn serverless:plan

 

# 4. Deploy

mvn serverless:deploy

 

# 5. Verify health

mvn serverless:verify