{
  "manifest_version": "1.0.0",
  "template": {
    "id": "819965c3-80a0-4359-8072-1d14dc23b944",
    "slug": "affine-railway",
    "name": "Affine",
    "description": "Notion alternative. Docs, whiteboard, kanban, databases & real-time sync",
    "url": "https://railway.com/deploy/affine-railway",
    "upstream": {
      "image": "ghcr.io/toeverything/affine:0.27.3"
    }
  },
  "services": [
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "affine",
      "source": {
        "image": "ghcr.io/toeverything/affine:0.27.3"
      },
      "needs_volume": true,
      "volume_mount_path": "/root/.affine",
      "http": true
    },
    {
      "name": "Redis",
      "source": {
        "image": "redis:8.2.1"
      },
      "needs_volume": true,
      "volume_mount_path": "/data",
      "http": false
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Data directory, a subdirectory of the volume mount",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Private hostname, reachable only inside the project",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Standard PostgreSQL port",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "libpq alias of the superuser name",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "libpq alias of the default database",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "libpq alias of the superuser password",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Default database created on first boot",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "Private connection string, use this from other services",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "Superuser created on first boot",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "Validity window of the generated self-signed TLS certificate",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Generated superuser password",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "Postgres",
      "description": "Public connection string over the TCP proxy, for external tools",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Grace period for in-flight connections on redeploy",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "PORT",
      "service": "affine",
      "description": "Health check target port",
      "secret": false,
      "strategy": "default",
      "default": "3010"
    },
    {
      "key": "NODE_ENV",
      "service": "affine",
      "description": "Node runtime mode",
      "secret": false,
      "strategy": "default",
      "default": "production"
    },
    {
      "key": "NO_COLOR",
      "service": "affine",
      "description": "Plain-text log output",
      "secret": false,
      "strategy": "default",
      "default": "1"
    },
    {
      "key": "AFFINE_ENV",
      "service": "affine",
      "description": "AFFiNE namespace",
      "secret": false,
      "strategy": "default",
      "default": "production"
    },
    {
      "key": "DATABASE_URL",
      "service": "affine",
      "description": "PostgreSQL connection string",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "NODE_OPTIONS",
      "service": "affine",
      "description": "Node heap ceiling",
      "secret": false,
      "strategy": "default",
      "default": "--max-old-space-size=3072"
    },
    {
      "key": "DEPLOYMENT_TYPE",
      "service": "affine",
      "description": "Enables setup wizard and admin",
      "secret": false,
      "strategy": "default",
      "default": "selfhosted"
    },
    {
      "key": "REDIS_SERVER_HOST",
      "service": "affine",
      "description": "Redis private hostname",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_SERVER_PORT",
      "service": "affine",
      "description": "Redis port",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "AFFINE_CONFIG_JSON",
      "service": "affine",
      "description": "Config overrides written at boot",
      "secret": false,
      "strategy": "default",
      "default": "{\"redis\":{\"ioredis\":{\"family\":0}},\"auth\":{\"allowSignup\":false}}"
    },
    {
      "key": "AFFINE_SERVER_HOST",
      "service": "affine",
      "description": "Public hostname",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "AFFINE_SERVER_PORT",
      "service": "affine",
      "description": "Server listening port",
      "secret": false,
      "strategy": "default",
      "default": "3010"
    },
    {
      "key": "AFFINE_SERVER_HTTPS",
      "service": "affine",
      "description": "Marks site HTTPS, secures cookies",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "REDIS_SERVER_DATABASE",
      "service": "affine",
      "description": "Redis database index",
      "secret": false,
      "strategy": "default",
      "default": "0"
    },
    {
      "key": "REDIS_SERVER_PASSWORD",
      "service": "affine",
      "description": "Redis password",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_SERVER_USERNAME",
      "service": "affine",
      "description": "Redis username",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "AFFINE_INDEXER_ENABLED",
      "service": "affine",
      "description": "Server-side search indexing off",
      "secret": false,
      "strategy": "default",
      "default": "false"
    },
    {
      "key": "AFFINE_SERVER_EXTERNAL_URL",
      "service": "affine",
      "description": "Public base URL for links",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "REDISHOST",
      "service": "Redis",
      "description": "Private hostname, reachable only inside the project",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "REDISPORT",
      "service": "Redis",
      "description": "Standard Redis port",
      "secret": false,
      "strategy": "default",
      "default": "6379"
    },
    {
      "key": "REDISUSER",
      "service": "Redis",
      "description": "Default ACL user created on first boot",
      "secret": false,
      "strategy": "default",
      "default": "default"
    },
    {
      "key": "REDIS_URL",
      "service": "Redis",
      "description": "Private connection string, use this from other services",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDISPASSWORD",
      "service": "Redis",
      "description": "Convenience alias of the generated password",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "Redis",
      "description": "Generated password for the default user",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "REDIS_PUBLIC_URL",
      "service": "Redis",
      "description": "Public connection string over the TCP proxy, for external tools",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "affine-railway"
      }
    },
    "cli": "railway deploy --template affine-railway",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "819965c3-80a0-4359-8072-1d14dc23b944",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "03e8e663-85f8-41d9-ae01-11c941adf4e2": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Data directory, a subdirectory of the volume mount",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Private hostname, reachable only inside the project",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Standard PostgreSQL port",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "libpq alias of the superuser name",
                      "defaultValue": "${{POSTGRES_USER}}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "libpq alias of the default database",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "libpq alias of the superuser password",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created on first boot",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Private connection string, use this from other services",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "Superuser created on first boot",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": false,
                      "description": "Validity window of the generated self-signed TLS certificate",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Generated superuser password",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "description": "Public connection string over the TCP proxy, for external tools",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Grace period for in-flight connections on redeploy",
                      "defaultValue": "60"
                    }
                  },
                  "volumeMounts": {
                    "03e8e663-85f8-41d9-ae01-11c941adf4e2": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  }
                },
                "40501c45-bfbf-4914-9778-396608d895d8": {
                  "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/affine-light.svg",
                  "name": "affine",
                  "deploy": {
                    "startCommand": "/bin/sh -c 'set -e; mkdir -p /root/.affine/config /root/.affine/storage; printf %s \"$AFFINE_CONFIG_JSON\" > /root/.affine/config/config.json; echo \"boot: uid=$(id -u) config=$(cat /root/.affine/config/config.json)\"; node ./scripts/self-host-predeploy.js; exec docker-entrypoint.sh node ./dist/main.js'",
                    "healthcheckPath": "/info",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/toeverything/affine:0.27.3"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "Health check target port",
                      "defaultValue": "3010"
                    },
                    "NODE_ENV": {
                      "isOptional": false,
                      "description": "Node runtime mode",
                      "defaultValue": "production"
                    },
                    "NO_COLOR": {
                      "isOptional": false,
                      "description": "Plain-text log output",
                      "defaultValue": "1"
                    },
                    "AFFINE_ENV": {
                      "isOptional": false,
                      "description": "AFFiNE namespace",
                      "defaultValue": "production"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "PostgreSQL connection string",
                      "defaultValue": "${{Postgres.DATABASE_URL}}"
                    },
                    "NODE_OPTIONS": {
                      "isOptional": false,
                      "description": "Node heap ceiling",
                      "defaultValue": "--max-old-space-size=3072"
                    },
                    "DEPLOYMENT_TYPE": {
                      "isOptional": false,
                      "description": "Enables setup wizard and admin",
                      "defaultValue": "selfhosted"
                    },
                    "REDIS_SERVER_HOST": {
                      "isOptional": false,
                      "description": "Redis private hostname",
                      "defaultValue": "${{Redis.REDISHOST}}"
                    },
                    "REDIS_SERVER_PORT": {
                      "isOptional": false,
                      "description": "Redis port",
                      "defaultValue": "${{Redis.REDISPORT}}"
                    },
                    "AFFINE_CONFIG_JSON": {
                      "isOptional": false,
                      "description": "Config overrides written at boot",
                      "defaultValue": "{\"redis\":{\"ioredis\":{\"family\":0}},\"auth\":{\"allowSignup\":false}}"
                    },
                    "AFFINE_SERVER_HOST": {
                      "isOptional": false,
                      "description": "Public hostname",
                      "defaultValue": "${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "AFFINE_SERVER_PORT": {
                      "isOptional": false,
                      "description": "Server listening port",
                      "defaultValue": "3010"
                    },
                    "AFFINE_SERVER_HTTPS": {
                      "isOptional": false,
                      "description": "Marks site HTTPS, secures cookies",
                      "defaultValue": "true"
                    },
                    "REDIS_SERVER_DATABASE": {
                      "isOptional": false,
                      "description": "Redis database index",
                      "defaultValue": "0"
                    },
                    "REDIS_SERVER_PASSWORD": {
                      "isOptional": false,
                      "description": "Redis password",
                      "defaultValue": "${{Redis.REDISPASSWORD}}"
                    },
                    "REDIS_SERVER_USERNAME": {
                      "isOptional": false,
                      "description": "Redis username",
                      "defaultValue": "${{Redis.REDISUSER}}"
                    },
                    "AFFINE_INDEXER_ENABLED": {
                      "isOptional": false,
                      "description": "Server-side search indexing off",
                      "defaultValue": "false"
                    },
                    "AFFINE_SERVER_EXTERNAL_URL": {
                      "isOptional": false,
                      "description": "Public base URL for links",
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  },
                  "volumeMounts": {
                    "40501c45-bfbf-4914-9778-396608d895d8": {
                      "mountPath": "/root/.affine"
                    }
                  }
                },
                "6b9244ba-e078-45bc-84fc-77734876823a": {
                  "icon": "https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg",
                  "name": "Redis",
                  "deploy": {
                    "startCommand": "/bin/sh -c \"rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH\"",
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "redis:8.2.1"
                  },
                  "variables": {
                    "REDISHOST": {
                      "isOptional": false,
                      "description": "Private hostname, reachable only inside the project",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "REDISPORT": {
                      "isOptional": false,
                      "description": "Standard Redis port",
                      "defaultValue": "6379"
                    },
                    "REDISUSER": {
                      "isOptional": false,
                      "description": "Default ACL user created on first boot",
                      "defaultValue": "default"
                    },
                    "REDIS_URL": {
                      "isOptional": false,
                      "description": "Private connection string, use this from other services",
                      "defaultValue": "redis://${{REDISUSER}}:${{REDIS_PASSWORD}}@${{REDISHOST}}:${{REDISPORT}}"
                    },
                    "REDISPASSWORD": {
                      "isOptional": false,
                      "description": "Convenience alias of the generated password",
                      "defaultValue": "${{REDIS_PASSWORD}}"
                    },
                    "REDIS_PASSWORD": {
                      "isOptional": false,
                      "description": "Generated password for the default user",
                      "defaultValue": "{{REDIS_PASSWORD}}"
                    },
                    "REDIS_PUBLIC_URL": {
                      "description": "Public connection string over the TCP proxy, for external tools",
                      "defaultValue": "redis://default:${{REDIS_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}"
                    }
                  },
                  "volumeMounts": {
                    "6b9244ba-e078-45bc-84fc-77734876823a": {
                      "mountPath": "/data"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "affine",
      "method": "GET",
      "path": "/info",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 3,
    "needs_volume": true
  },
  "generated_at": "2026-09-10T10:14:45.332Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-09-04T14:11:27.320Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_639a652930294cb8bb0e",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "healthcheck",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 82,
    "typical_build_seconds": 0,
    "typical_start_seconds": 20,
    "slowest_service": "affine"
  }
}
