{
  "manifest_version": "1.0.0",
  "template": {
    "id": "a98bd2cc-b9ee-4dec-af76-7c3c94263d4b",
    "slug": "form-cap",
    "name": "Form Cap",
    "description": "Self-hosted contact form backend with CAPTCHA spam protection",
    "url": "https://railway.com/deploy/form-cap",
    "upstream": {
      "repo_url": "https://github.com/INAPP-Mobile/railway-form-template"
    }
  },
  "services": [
    {
      "name": "form-api",
      "source": {
        "repo": "https://github.com/INAPP-Mobile/railway-form-template"
      },
      "needs_volume": false,
      "http": true
    },
    {
      "name": "valkey",
      "source": {
        "image": "valkey/valkey:8-alpine"
      },
      "needs_volume": false,
      "http": false
    },
    {
      "name": "postgres",
      "source": {
        "repo": "https://github.com/INAPP-Mobile/railway-form-template"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql",
      "http": false
    },
    {
      "name": "cap",
      "source": {
        "image": "tiago2/cap:latest"
      },
      "needs_volume": false,
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "SMTP_PORT",
      "service": "form-api",
      "description": "SMTP server port. Default 587 (STARTTLS). Use 465 for implicit TLS.",
      "secret": false,
      "strategy": "default",
      "default": "587"
    },
    {
      "key": "FROM_EMAIL",
      "service": "form-api",
      "description": "From-address on outgoing notifications. Use a real address on a domain you control to avoid SPF/DKIM failures.",
      "secret": false,
      "strategy": "default",
      "default": "noreply@contact-form.app"
    },
    {
      "key": "RATE_LIMIT",
      "service": "form-api",
      "description": "Max submissions per IP per minute. Default 10. Lower for stricter anti-abuse, raise for trusted internal use.",
      "secret": false,
      "strategy": "default",
      "default": "10"
    },
    {
      "key": "CAPTCHA_MODE",
      "service": "form-api",
      "description": "CAPTCHA mode: 'auto' (use Cap if CAP_ENDPOINT is reachable, else none), 'cap' (force Cap), or 'none' (disabled).",
      "secret": false,
      "strategy": "default",
      "default": "auto"
    },
    {
      "key": "CAP_ENDPOINT",
      "service": "form-api",
      "description": "Public URL of the sibling 'cap' CAPTCHA service. Auto-wired to this template's Cap service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "DATABASE_URL",
      "service": "form-api",
      "description": "PostgreSQL connection string. Auto-wired to the sibling 'postgres' service in this template. No need to edit.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "ADMIN_PASSWORD",
      "service": "form-api",
      "description": "Password to access the admin dashboard at /admin. Auto-generated on deploy. Change it after first login.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "CAP_SECRET_KEY",
      "service": "form-api",
      "description": "Shared secret used to verify Cap challenge tokens (HMAC). Auto-generated; must match what Cap issues. Keep in sync with the Cap service if you rotate it.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "RATE_LIMIT_BACKEND",
      "service": "form-api",
      "description": "Rate-limit store: 'memory' (per-replica, fine for a single instance) or 'db' (shared via PostgreSQL; requires DATABASE_URL).",
      "secret": false,
      "strategy": "default",
      "default": "memory"
    },
    {
      "key": "SESSION_SECRET_KEY",
      "service": "form-api",
      "description": "Secret used to sign admin session cookies. Auto-generated on deploy. Change to invalidate all active admin sessions.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "VALKEY_ARGS",
      "service": "valkey",
      "description": "Valkey server startup arguments. Saves a snapshot every 60s if at least 1 key changed, and refuses eviction under memory pressure so Cap session data is not lost. Leave empty for Valkey defaults.",
      "secret": true,
      "strategy": "default",
      "default": "--save 60 1 --maxmemory-policy noeviction"
    },
    {
      "key": "PGDATA",
      "service": "postgres",
      "description": "Data directory. The parent /var/lib/postgresql is mounted as a volume so data survives restarts.",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data"
    },
    {
      "key": "POSTGRES_DB",
      "service": "postgres",
      "description": "Default database created on first boot. Referenced by the Form API's DATABASE_URL.",
      "secret": false,
      "strategy": "default",
      "default": "formdb"
    },
    {
      "key": "POSTGRES_USER",
      "service": "postgres",
      "description": "Superuser name. Referenced by the Form API's DATABASE_URL.",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "postgres",
      "description": "Superuser password. Auto-generated on deploy. Referenced by the Form API's DATABASE_URL — do not edit unless you also update DATABASE_URL there.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "ADMIN_KEY",
      "service": "cap",
      "description": "Cap dashboard login password (at least 32 chars recommended). Auto-generated on deploy.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "REDIS_URL",
      "service": "cap",
      "description": "Redis-compatible connection string for Cap session/challenge storage. Auto-wired to the sibling 'valkey' service in this template. No need to edit.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "CORS_ORIGIN",
      "service": "cap",
      "description": "Allowed origins for redeeming/generating challenges. Defaults to '*' (all origins). Restrict to your domain(s) for production, e.g. https://yourdomain.com.",
      "secret": false,
      "strategy": "default",
      "default": "*"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "form-cap"
      }
    },
    "cli": "railway deploy --template form-cap",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "a98bd2cc-b9ee-4dec-af76-7c3c94263d4b",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "2631d85c-242c-4afc-bf5b-0ed2ee6f7aaf": {
                  "icon": null,
                  "name": "form-api",
                  "deploy": {
                    "startCommand": "uvicorn app.main:app --host 0.0.0.0 --port $PORT --proxy-headers",
                    "healthcheckPath": "/health",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "https://github.com/INAPP-Mobile/railway-form-template",
                    "rootDirectory": "/"
                  },
                  "variables": {
                    "SMTP_HOST": {
                      "isOptional": true,
                      "description": "SMTP server hostname for sending notifications. Optional if SendGrid is configured.",
                      "defaultValue": ""
                    },
                    "SMTP_PASS": {
                      "isOptional": true,
                      "description": "SMTP auth password. Optional for anonymous relays.",
                      "defaultValue": ""
                    },
                    "SMTP_PORT": {
                      "description": "SMTP server port. Default 587 (STARTTLS). Use 465 for implicit TLS.",
                      "defaultValue": "587"
                    },
                    "SMTP_USER": {
                      "isOptional": true,
                      "description": "SMTP auth username. Optional for anonymous relays.",
                      "defaultValue": ""
                    },
                    "FROM_EMAIL": {
                      "description": "From-address on outgoing notifications. Use a real address on a domain you control to avoid SPF/DKIM failures.",
                      "defaultValue": "noreply@contact-form.app"
                    },
                    "RATE_LIMIT": {
                      "description": "Max submissions per IP per minute. Default 10. Lower for stricter anti-abuse, raise for trusted internal use.",
                      "defaultValue": "10"
                    },
                    "CAPTCHA_MODE": {
                      "isOptional": false,
                      "description": "CAPTCHA mode: 'auto' (use Cap if CAP_ENDPOINT is reachable, else none), 'cap' (force Cap), or 'none' (disabled).",
                      "defaultValue": "auto"
                    },
                    "CAP_ENDPOINT": {
                      "isOptional": false,
                      "description": "Public URL of the sibling 'cap' CAPTCHA service. Auto-wired to this template's Cap service.",
                      "defaultValue": "https://${{cap.RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "CAP_SITE_KEY": {
                      "isOptional": true,
                      "description": "Cap site key passed to the frontend widget. Leave empty unless you created a specific site key in the Cap dashboard.",
                      "defaultValue": ""
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "PostgreSQL connection string. Auto-wired to the sibling 'postgres' service in this template. No need to edit.",
                      "defaultValue": "postgresql://postgres:${{postgres.POSTGRES_PASSWORD}}@${{postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/${{postgres.POSTGRES_DB}}"
                    },
                    "ADMIN_PASSWORD": {
                      "isOptional": false,
                      "description": "Password to access the admin dashboard at /admin. Auto-generated on deploy. Change it after first login.",
                      "defaultValue": "{{ADMIN_PASSWORD}}"
                    },
                    "CAP_SECRET_KEY": {
                      "isOptional": false,
                      "description": "Shared secret used to verify Cap challenge tokens (HMAC). Auto-generated; must match what Cap issues. Keep in sync with the Cap service if you rotate it.",
                      "defaultValue": "{{CAP_SECRET_KEY}}"
                    },
                    "SENDGRID_API_KEY": {
                      "isOptional": true,
                      "description": "SendGrid API key for submission notifications. Leave empty to fall back to SMTP (see SMTP_HOST). Optional.",
                      "defaultValue": ""
                    },
                    "RATE_LIMIT_BACKEND": {
                      "description": "Rate-limit store: 'memory' (per-replica, fine for a single instance) or 'db' (shared via PostgreSQL; requires DATABASE_URL).",
                      "defaultValue": "memory"
                    },
                    "SESSION_SECRET_KEY": {
                      "description": "Secret used to sign admin session cookies. Auto-generated on deploy. Change to invalidate all active admin sessions.",
                      "defaultValue": "{{SESSION_SECRET_KEY}}"
                    },
                    "FORM_RECIPIENT_EMAIL": {
                      "isOptional": true,
                      "description": "Email address that receives form submissions. Set this to your address before going live — submissions are not delivered if it is empty.",
                      "defaultValue": ""
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  }
                },
                "4aa2cc1b-bbfd-4569-8b54-37980320b83b": {
                  "icon": null,
                  "name": "valkey",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "valkey/valkey:8-alpine"
                  },
                  "variables": {
                    "VALKEY_ARGS": {
                      "isOptional": false,
                      "description": "Valkey server startup arguments. Saves a snapshot every 60s if at least 1 key changed, and refuses eviction under memory pressure so Cap session data is not lost. Leave empty for Valkey defaults.",
                      "defaultValue": "--save 60 1 --maxmemory-policy noeviction"
                    }
                  }
                },
                "a64b1e55-af77-4f5b-9cf2-d61dff644113": {
                  "icon": null,
                  "name": "postgres",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "https://github.com/INAPP-Mobile/railway-form-template",
                    "rootDirectory": "/postgres"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Data directory. The parent /var/lib/postgresql is mounted as a volume so data survives restarts.",
                      "defaultValue": "/var/lib/postgresql/data"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created on first boot. Referenced by the Form API's DATABASE_URL.",
                      "defaultValue": "formdb"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "Superuser name. Referenced by the Form API's DATABASE_URL.",
                      "defaultValue": "postgres"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Superuser password. Auto-generated on deploy. Referenced by the Form API's DATABASE_URL — do not edit unless you also update DATABASE_URL there.",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    }
                  },
                  "volumeMounts": {
                    "a64b1e55-af77-4f5b-9cf2-d61dff644113": {
                      "mountPath": "/var/lib/postgresql"
                    }
                  }
                },
                "c34ddbb2-577e-47e4-b374-175e2a71a130": {
                  "icon": null,
                  "name": "cap",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "tiago2/cap:latest"
                  },
                  "variables": {
                    "ADMIN_KEY": {
                      "isOptional": false,
                      "description": "Cap dashboard login password (at least 32 chars recommended). Auto-generated on deploy.",
                      "defaultValue": "{{ADMIN_KEY}}"
                    },
                    "REDIS_URL": {
                      "isOptional": false,
                      "description": "Redis-compatible connection string for Cap session/challenge storage. Auto-wired to the sibling 'valkey' service in this template. No need to edit.",
                      "defaultValue": "redis://${{valkey.RAILWAY_PRIVATE_DOMAIN}}:6379"
                    },
                    "CORS_ORIGIN": {
                      "isOptional": false,
                      "description": "Allowed origins for redeeming/generating challenges. Defaults to '*' (all origins). Restrict to your domain(s) for production, e.g. https://yourdomain.com.",
                      "defaultValue": "*"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "form-api",
      "method": "GET",
      "path": "/health",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 4,
    "needs_volume": true
  },
  "generated_at": "2026-09-10T16:14:52.212Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-09-09T00:59:49.465Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_37fe9399cba1403e8e9a",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "healthcheck",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 91,
    "typical_build_seconds": 40,
    "typical_start_seconds": 12,
    "slowest_service": "form-api"
  }
}
