# aynaash/nextdeploy architecture

> Architecture diagram of the GitHub repository aynaash/nextdeploy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aynaash/nextdeploy
- Repository: https://github.com/aynaash/nextdeploy

## Overview

NextDeploy is a self-hosted Next.js deployment engine: users configure a target, analyze and validate a build, ship it to their own infrastructure, then verify or roll back releases. Its principal workflow spans CLI commands, build intelligence, target-specific deployment, and runtime operations. The README supports the documented workflow and major capabilities; sampled source confirms selected CLI, daemon, serverless, and request-context responsibilities. Some subsystems are represented by exact directory paths because their implementation was not sampled, so undocumented internal links are omitted.

Main entry points: [`cli/main.go`](https://github.com/aynaash/nextdeploy/blob/main/cli/main.go) (NextDeploy CLI), [`daemon/cmd/nextdeployd/main.go`](https://github.com/aynaash/nextdeploy/blob/main/daemon/cmd/nextdeployd/main.go) (Deployment daemon), [`cli/internal/serverless`](https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless) (AWS and Cloudflare), [`cli/cmd/ship.go`](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/ship.go) (Release shipping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["NextDeploy CLI<br/>[main.go]"]
  node_init["Project setup<br/>[init.go]"]
  node_plan["Deployment plan<br/>[plan.go]"]
  node_ship["Release shipping<br/>[ship.go]"]
  node_config["Target configuration<br/>[server_resolve.go]"]
end

subgraph group_analysis["Build intelligence"]
  node_build["Build analysis<br/>[build.go]"]
  node_buildmeta["Build metadata<br/>[build.go]"]
  node_nextcore["Next.js inspection"]
end

subgraph group_targets["Deployment targets"]
  node_vps["VPS deployment<br/>[server.go]"]
  node_cloud["AWS and Cloudflare"]
  node_cloudflare["Cloudflare resources"]
  node_aws["AWS resources"]
  node_packager["Serverless packaging"]
  node_worker_runtime["Worker runtime<br/>[context.mjs]"]
end

subgraph group_runtime["Runtime operations"]
  node_daemon["Deployment daemon<br/>[main.go]"]
  node_process["Service lifecycle<br/>[process_manager.go]"]
  node_routing["Traffic and HTTPS<br/>[caddy_manager.go]"]
  node_sidecar["Next.js sidecar<br/>[sidecar_manager.go]"]
end

subgraph group_extensions["Operational capabilities"]
  node_logs["Log and status tools<br/>[logs.go]"]
  node_rollback["Rollback<br/>[rollback.go]"]
  node_prepare["Host preparation<br/>[run.go]"]
  node_cicd["CI workflow generation<br/>[workflow.go]"]
  node_agenttrace["Agent trace and MCP<br/>[trace.go]"]
  node_updater["Self updater<br/>[updater.go]"]
end

node_developer(("Developer"))

node_developer -->|"runs commands"| node_cli
node_cli -->|"initializes project"| node_init
node_cli -->|"analyzes build"| node_build
node_build -->|"generates metadata"| node_buildmeta
node_build -->|"classifies routes"| node_nextcore
node_cli -->|"validates deployment"| node_plan
node_plan -->|"checks configuration"| node_config
node_cli -->|"ships release"| node_ship
node_ship -->|"deploys to VPS"| node_vps
node_vps -.->|"sends release"| node_daemon
node_daemon -.->|"manages services"| node_process
node_daemon -.->|"configures routing"| node_routing
node_daemon -.->|"manages sidecar"| node_sidecar
node_ship -->|"deploys serverless"| node_cloud
node_cloud -->|"provisions AWS"| node_aws
node_cloud -->|"provisions Workers"| node_cloudflare
node_cloud -->|"packages application"| node_packager
node_cloudflare -->|"runs compiled app"| node_worker_runtime
node_cli -->|"streams logs"| node_logs
node_cli -->|"restores release"| node_rollback
node_cli -->|"prepares VPS"| node_prepare
node_cli -->|"generates workflows"| node_cicd
node_cli -->|"offers trace tools"| node_agenttrace
node_daemon -->|"updates daemon"| node_updater

click node_cli "https://github.com/aynaash/nextdeploy/blob/main/cli/main.go"
click node_init "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/init.go"
click node_build "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/build.go"
click node_buildmeta "https://github.com/aynaash/nextdeploy/blob/main/shared/nextbuild/build.go"
click node_nextcore "https://github.com/aynaash/nextdeploy/tree/main/shared/nextcore"
click node_plan "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/plan.go"
click node_ship "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/ship.go"
click node_config "https://github.com/aynaash/nextdeploy/blob/main/shared/config/server_resolve.go"
click node_vps "https://github.com/aynaash/nextdeploy/blob/main/cli/internal/server/server.go"
click node_daemon "https://github.com/aynaash/nextdeploy/blob/main/daemon/cmd/nextdeployd/main.go"
click node_process "https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/process_manager.go"
click node_routing "https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/caddy_manager.go"
click node_sidecar "https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/sidecar_manager.go"
click node_cloud "https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless"
click node_cloudflare "https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless/cloudflare"
click node_aws "https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless/aws"
click node_packager "https://github.com/aynaash/nextdeploy/blob/main/internal/packaging/serverless_packager.go"
click node_worker_runtime "https://github.com/aynaash/nextdeploy/blob/main/shared/nextcompile/runtime_src/context.mjs"
click node_logs "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/logs.go"
click node_rollback "https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/rollback.go"
click node_prepare "https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/prepare/run.go"
click node_cicd "https://github.com/aynaash/nextdeploy/blob/main/cli/internal/cicd/workflow.go"
click node_agenttrace "https://github.com/aynaash/nextdeploy/blob/main/shared/agenttrace/trace.go"
click node_updater "https://github.com/aynaash/nextdeploy/blob/main/shared/updater/updater.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_init,node_plan,node_ship,node_config toneBlue
class node_build,node_buildmeta,node_nextcore toneAmber
class node_vps,node_cloud,node_cloudflare,node_aws,node_packager,node_worker_runtime toneMint
class node_daemon,node_process,node_routing,node_sidecar toneRose
class node_logs,node_rollback,node_prepare,node_cicd,node_agenttrace,node_updater,node_developer toneIndigo
```

## Components

### CLI workflow

- [NextDeploy CLI](https://github.com/aynaash/nextdeploy/blob/main/cli/main.go): `cli/main.go`
- [Project setup](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/init.go): `cli/cmd/init.go`
- [Deployment plan](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/plan.go): `cli/cmd/plan.go`
- [Release shipping](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/ship.go): `cli/cmd/ship.go`
- [Target configuration](https://github.com/aynaash/nextdeploy/blob/main/shared/config/server_resolve.go): `shared/config/server_resolve.go`

### Build intelligence

- [Build analysis](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/build.go): `cli/cmd/build.go`
- [Build metadata](https://github.com/aynaash/nextdeploy/blob/main/shared/nextbuild/build.go): `shared/nextbuild/build.go`
- [Next.js inspection](https://github.com/aynaash/nextdeploy/tree/main/shared/nextcore): `shared/nextcore`

### Deployment targets

- [VPS deployment](https://github.com/aynaash/nextdeploy/blob/main/cli/internal/server/server.go): `cli/internal/server/server.go`
- [AWS and Cloudflare](https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless): `cli/internal/serverless`
- [Cloudflare resources](https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless/cloudflare): `cli/internal/serverless/cloudflare`
- [AWS resources](https://github.com/aynaash/nextdeploy/tree/main/cli/internal/serverless/aws): `cli/internal/serverless/aws`
- [Serverless packaging](https://github.com/aynaash/nextdeploy/blob/main/internal/packaging/serverless_packager.go): `internal/packaging/serverless_packager.go`
- [Worker runtime](https://github.com/aynaash/nextdeploy/blob/main/shared/nextcompile/runtime_src/context.mjs): `shared/nextcompile/runtime_src/context.mjs`

### Runtime operations

- [Deployment daemon](https://github.com/aynaash/nextdeploy/blob/main/daemon/cmd/nextdeployd/main.go): `daemon/cmd/nextdeployd/main.go`
- [Service lifecycle](https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/process_manager.go): `daemon/internal/daemon/process_manager.go`
- [Traffic and HTTPS](https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/caddy_manager.go): `daemon/internal/daemon/caddy_manager.go`
- [Next.js sidecar](https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/daemon/sidecar_manager.go): `daemon/internal/daemon/sidecar_manager.go`

### Operational capabilities

- [Log and status tools](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/logs.go): `cli/cmd/logs.go`
- [Rollback](https://github.com/aynaash/nextdeploy/blob/main/cli/cmd/rollback.go): `cli/cmd/rollback.go`
- [Host preparation](https://github.com/aynaash/nextdeploy/blob/main/daemon/internal/prepare/run.go): `daemon/internal/prepare/run.go`
- [CI workflow generation](https://github.com/aynaash/nextdeploy/blob/main/cli/internal/cicd/workflow.go): `cli/internal/cicd/workflow.go`
- [Agent trace and MCP](https://github.com/aynaash/nextdeploy/blob/main/shared/agenttrace/trace.go): `shared/agenttrace/trace.go`
- [Self updater](https://github.com/aynaash/nextdeploy/blob/main/shared/updater/updater.go): `shared/updater/updater.go`

### Other components

- **Developer**

## Connections

- Developer → NextDeploy CLI: runs commands (evidence: `cli/main.go`)
- NextDeploy CLI → Project setup: initializes project (evidence: `README.md`)
- NextDeploy CLI → Build analysis: analyzes build (evidence: `README.md`)
- Build analysis → Build metadata: generates metadata (evidence: `README.md`)
- Build analysis → Next.js inspection: classifies routes (evidence: `README.md`)
- NextDeploy CLI → Deployment plan: validates deployment (evidence: `README.md`)
- Deployment plan → Target configuration: checks configuration (evidence: `README.md`)
- NextDeploy CLI → Release shipping: ships release (evidence: `README.md`)
- Release shipping → VPS deployment: deploys to VPS (evidence: `README.md`)
- VPS deployment → Deployment daemon: sends release
- Deployment daemon → Service lifecycle: manages services
- Deployment daemon → Traffic and HTTPS: configures routing
- Deployment daemon → Next.js sidecar: manages sidecar
- Release shipping → AWS and Cloudflare: deploys serverless (evidence: `README.md`)
- AWS and Cloudflare → AWS resources: provisions AWS (evidence: `README.md`)
- AWS and Cloudflare → Cloudflare resources: provisions Workers (evidence: `README.md`)
- AWS and Cloudflare → Serverless packaging: packages application (evidence: `README.md`)
- Cloudflare resources → Worker runtime: runs compiled app (evidence: `README.md`)
- NextDeploy CLI → Log and status tools: streams logs (evidence: `README.md`)
- NextDeploy CLI → Rollback: restores release (evidence: `README.md`)
- NextDeploy CLI → Host preparation: prepares VPS (evidence: `README.md`)
- NextDeploy CLI → CI workflow generation: generates workflows (evidence: `README.md`)
- NextDeploy CLI → Agent trace and MCP: offers trace tools (evidence: `README.md`)
- Deployment daemon → Self updater: updates daemon (evidence: `daemon/cmd/nextdeployd/main.go`)
