How ritikaxg/spinup works
Purpose and topology
SpinUp is a control-plane-first cloud developer-workspace platform. A Clerk-authenticated browser request creates or resumes a project; the Next.js control plane provisions an EC2-backed code-server workspace and exposes it through its VM public IP. The monorepo contains the web control plane, VM workspace image/bootstrap, Prisma database package, and starter app artifacts.
Product/API entry points
The browser enters through the landing and project dashboard/detail routes: apps/web/app/page.tsx, apps/web/app/projects/page.tsx, and apps/web/app/projects/[projectId]/page.tsx. Project commands enter API routes at apps/web/app/api/project/route.ts and state polling reads apps/web/app/api/project/[projectId]/route.ts. Clerk protection is applied through apps/web/middleware.ts.
Control-plane orchestration
apps/web/services/projectControlPlane.ts is the primary create/resume/delete coordinator. It validates requests, enforces the V1 one-active-runtime-per-user constraint, acquires runtime/create locks, and drives lifecycle transitions. apps/web/services/projectLifecycleManager.ts persists transitions and lifecycle events; apps/web/services/projectRuntimeTruthSource.ts reconciles runtime-facing truth with persisted state. The lifecycle boundary is explicit: CREATED → ALLOCATING_VM → BOOTING_CONTAINER → READY, with failure, stop, deletion, and retry/resume paths.
Allocation and runtime plane
VM allocation is isolated from product/API code. apps/web/services/ec2Manager.ts obtains/reuses instances, waits for public IP, VM-agent health, and workspace readiness. apps/web/services/asgManager.ts makes Auto Scaling Group capacity decisions, backed by AWS adapters in apps/web/lib/aws/asgClient.ts, apps/web/lib/aws/ec2Commands.ts, and apps/web/lib/aws/s3Commands.ts. The control plane calls the agent over HTTP through apps/web/lib/vmAgent/client.ts; agents run on EC2 port 3000 and start Docker containers rather than exposing Docker control directly to the web service.
Persistence, locking, and recovery
Postgres is the authoritative record for users, projects, rooms, assignments, lifecycle fields, and event history, defined in packages/db/prisma/schema.prisma and exported via packages/db/index.ts. Redis is deliberately a non-authoritative coordination/cache layer for distributed locks, runtime assignment mirrors, and cleanup coordination in apps/web/services/redisManager.ts. Background reconciliation and liveness handling are separated into apps/web/services/controlPlaneReconciler.ts, apps/web/services/runtimeHeartbeatManager.ts, and worker entry point apps/web/scripts/control-plane-worker.ts.
Workspace container bootstrap and artifact persistence
The VM agent launches a project-specific code-server container from the workspace bootstrap layer in apps/vm-base-config. apps/vm-base-config/docker/Dockerfile.codeserver defines the runtime image; apps/vm-base-config/entrypoint.sh initializes each workspace; apps/vm-base-config/scripts/startProjectSync.ts supports project-file synchronization. Containers restore project code from S3 or seed it from framework templates, install dependencies, sync changes back to S3, and run code-server on port 8080. Templates cover Next.js, React, and React Native under apps/vm-base-config/base-app.
UI/runtime observation and infrastructure
The UI treats projects as runtime objects: project cards/actions, boot progress, status display, polling, and IDE embedding live under apps/web/app/components/projects, apps/web/app/hooks/useProjectPolling.ts, and apps/web/app/vmWrapper.tsx. Material infrastructure is Next.js/React/TypeScript, Bun, Docker Compose, Prisma/Postgres, Redis, AWS EC2/ASG/S3, Docker/code-server, and Clerk. Local control-plane dependencies are composed in docker-compose.yml; actual workspace execution remains on the AWS VM/AMI/ASG path.
Components 20
Web Control Plane
- Project UI & Routes · Landing, dashboards, project detail, and project APIs.
apps/web/app/projects/[projectId]/page.tsx - Clerk Middleware
apps/web/middleware.ts - Runtime UI · Polling, status/progress, actions, and IDE embedding.
apps/web/app/components/projects - Project Control Plane · Validates commands, locks active runtime, and coordinates lifecycle.
apps/web/services/projectControlPlane.ts
State & Recovery
- Lifecycle Manager · Persists CREATED through READY and failure/retry transitions.
apps/web/services/projectLifecycleManager.ts - Runtime Truth Source · Reconciles runtime observations with persisted state.
apps/web/services/projectRuntimeTruthSource.ts - Postgres / Prisma · Users, projects, assignments, lifecycle fields, and event history.
packages/db/prisma/schema.prisma - Redis Coordination · Non-authoritative locks, assignment mirrors, and cleanup coordination.
apps/web/services/redisManager.ts - Control Plane Worker · Runs reconciliation and liveness handling.
apps/web/scripts/control-plane-worker.ts - Heartbeat Manager
apps/web/services/runtimeHeartbeatManager.ts - Control Plane Reconciler
apps/web/services/controlPlaneReconciler.ts
AWS Runtime Plane
- EC2 Manager · Obtains instances and waits for IP, agent health, and workspace readiness.
apps/web/services/ec2Manager.ts - ASG Manager
apps/web/services/asgManager.ts - AWS Adapters · EC2, ASG, and S3 command adapters.
apps/web/lib/aws/ec2Commands.ts - VM Agent · Port 3000 agent starts workspace containers without direct Docker access.
apps/web/lib/vmAgent/client.ts - S3 Project Artifacts · Stores synchronized project files.
apps/web/lib/aws/s3Commands.ts
Workspace Bootstrap
- code-server Workspace · Project-specific IDE container, serving code-server on port 8080.
apps/vm-base-config/docker/Dockerfile.codeserver - Workspace Bootstrap · Restores or seeds code, installs dependencies, and synchronizes changes.
apps/vm-base-config/entrypoint.sh - Starter Templates · Next.js, React, and React Native starter applications.
apps/vm-base-config/base-app
Other components
- Browser · Clerk-authenticated developer interface.
Connections 22
- Browser → Clerk Middleware: request
- Clerk Middleware → Project UI & Routes: protected access
- Project UI & Routes → Runtime UI: renders
- Runtime UI → Project Control Plane: project commands / polling
- Project Control Plane → Redis Coordination: acquires locks
- Project Control Plane → Lifecycle Manager: drives transitions
- Lifecycle Manager → Postgres / Prisma: persists state and events
- Project Control Plane → EC2 Manager: allocate / resume / delete
- EC2 Manager → ASG Manager: requests capacity
- ASG Manager → AWS Adapters: ASG decisions
- EC2 Manager → AWS Adapters: instance and IP operations
- EC2 Manager → VM Agent: HTTP provisioning
- VM Agent → code-server Workspace: starts container
- code-server Workspace → Workspace Bootstrap: runs initialization
- Workspace Bootstrap → S3 Project Artifacts: restore and sync files
- Workspace Bootstrap → Starter Templates: seed when no artifact
- Control Plane Worker → Control Plane Reconciler: runs
- Control Plane Worker → Heartbeat Manager: runs
- Control Plane Reconciler → Runtime Truth Source: reconciles observations
- Heartbeat Manager → Runtime Truth Source: reports liveness
- Runtime Truth Source → Lifecycle Manager: corrects persisted state
- code-server Workspace → Runtime UI: IDE via VM public IP